1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-23 22:36:32 +02:00

Mobile: Resolves #10374: Add more options when long pressing the icon on mobile (#11517)

This commit is contained in:
Laurent Cozic
2024-12-16 10:49:46 +01:00
committed by GitHub
parent dc96811940
commit 3983a3a52f
9 changed files with 116 additions and 28 deletions

View File

@@ -4,6 +4,8 @@ import { Dispatch } from 'redux';
import CommandService from '@joplin/lib/services/CommandService';
import Logger from '@joplin/utils/Logger';
import { DeviceEventEmitter } from 'react-native';
import { GotoNoteOptions } from './commands/util/goToNote';
import { AttachFileAction } from './components/screens/Note/commands/attachFile';
const logger = Logger.create('setupQuickActions');
@@ -19,9 +21,17 @@ export default async (dispatch: Dispatch) => {
return null;
}
// List of iOS icons:
// https://github.com/EvanBacon/expo-quick-actions?tab=readme-ov-file#system-icons
//
// Note: on Android, anything beyond the fourth menu item appears to be ignored, at least on
// emulator.
QuickActions.setShortcutItems([
{ type: 'New note', title: _('New note'), icon: 'Compose', userInfo },
{ type: 'New to-do', title: _('New to-do'), icon: 'Add', userInfo },
{ type: 'newNote', title: _('New note'), icon: 'Compose', userInfo },
{ type: 'newTodo', title: _('New to-do'), icon: 'Add', userInfo },
{ type: 'newPhoto', title: _('New photo'), icon: 'CapturePhoto', userInfo },
{ type: 'newResource', title: _('New attachment'), icon: 'Bookmark', userInfo },
{ type: 'newDrawing', title: _('New drawing'), icon: 'Favorite', userInfo },
]);
try {
@@ -50,6 +60,18 @@ const quickActionHandler = (dispatch: Dispatch) => async (data: TData) => {
dispatch({ type: 'NAV_BACK' });
dispatch({ type: 'SIDE_MENU_CLOSE' });
const isTodo = data.type === 'New to-do' ? 1 : 0;
await CommandService.instance().execute('newNote', '', isTodo);
const isTodo = data.type === 'newTodo' ? 1 : 0;
const options: GotoNoteOptions = {
attachFileAction: null,
};
if (data.type === 'newPhoto') {
options.attachFileAction = AttachFileAction.TakePhoto;
} else if (data.type === 'newResource') {
options.attachFileAction = AttachFileAction.AttachFile;
} else if (data.type === 'newDrawing') {
options.attachFileAction = AttachFileAction.AttachDrawing;
}
await CommandService.instance().execute('newNote', '', isTodo, options);
};