aboutsummaryrefslogtreecommitdiffstats
path: root/src/androidterm.c
diff options
context:
space:
mode:
authorPo Lu2024-03-11 21:40:47 +0800
committerPo Lu2024-03-11 21:41:14 +0800
commita7a37341cad230448e487d0ffa343eeeb8a66a65 (patch)
treeab06b5826c5ae7bdd5b3dcc85b3ecba8dbee8c84 /src/androidterm.c
parent75cfc6c73faa1561018b1212156964a7919c69fe (diff)
downloademacs-a7a37341cad230448e487d0ffa343eeeb8a66a65.tar.gz
emacs-a7a37341cad230448e487d0ffa343eeeb8a66a65.zip
Implement notification callbacks on Android
* doc/lispref/os.texi (Desktop Notifications): Document that :on-cancel, :on-action and :actions are now supported on Android. * java/org/gnu/emacs/EmacsActivity.java (onNewIntent): New function. * java/org/gnu/emacs/EmacsDesktopNotification.java (NOTIFICATION_ACTION, NOTIFICATION_TAG, NOTIFICATION_DISMISSED): New constants. <actions, titles>: New fields. (insertActions): New function. (display1, display): Insert actions on Jelly Bean and up, and arrange to be notified when the notification is dismissed. (CancellationReceiver): New class. * java/org/gnu/emacs/EmacsNative.java (sendNotificationDeleted) (sendNotificationAction): New functions. * src/android.c (sendDndDrag, sendDndUri, sendDndText): Correct return types. (sendNotificationDeleted, sendNotificationAction) (android_exception_check_5, android_exception_check_6): New functions. * src/android.h: * src/androidgui.h (struct android_notification_event): New structure. (union android_event): New member for notification events. * src/androidselect.c (android_init_emacs_desktop_notification): Update JNI signatures. (android_notifications_notify_1, Fandroid_notifications_notify): New arguments ACTIONS, ACTION_CB and CANCEL_CB. Convert and record them as appropriate. (android_notification_deleted, android_notification_action): New functions. (syms_of_androidselect): Prepare a hash table of outstanding notifications. <QCactions, QCon_action, QCon_cancel> New defsyms. * src/androidterm.c (handle_one_android_event) <ANDROID_NOTIFICATION_DELETED> <ANDROID_NOTIFICATION_ACTION>: Dispatch event contents to androidselect.c for processing. * src/androidterm.h: * src/androidvfs.c (java_string_class): Export. * src/keyboard.c (kbd_buffer_get_event) <NOTIFICATION_EVENT>: Call callback specified by the event. * src/termhooks.h (enum event_kind) [HAVE_ANDROID]: New enum NOTIFICATION_EVENT.
Diffstat (limited to 'src/androidterm.c')
-rw-r--r--src/androidterm.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/androidterm.c b/src/androidterm.c
index baf26abe322..f68f8a9ef62 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -1761,6 +1761,26 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1761 free (event->dnd.uri_or_string); 1761 free (event->dnd.uri_or_string);
1762 goto OTHER; 1762 goto OTHER;
1763 1763
1764 case ANDROID_NOTIFICATION_DELETED:
1765 case ANDROID_NOTIFICATION_ACTION:
1766
1767 if (event->notification.type == ANDROID_NOTIFICATION_DELETED)
1768 android_notification_deleted (&event->notification, &inev.ie);
1769 else
1770 {
1771 Lisp_Object action;
1772
1773 action = android_decode_utf16 (event->notification.action,
1774 event->notification.length);
1775 android_notification_action (&event->notification, &inev.ie,
1776 action);
1777 }
1778
1779 /* Free dynamically allocated data. */
1780 free (event->notification.tag);
1781 free (event->notification.action);
1782 goto OTHER;
1783
1764 default: 1784 default:
1765 goto OTHER; 1785 goto OTHER;
1766 } 1786 }
@@ -4740,7 +4760,7 @@ android_sync_edit (void)
4740 4760
4741/* Return a copy of the specified Java string and its length in 4761/* Return a copy of the specified Java string and its length in
4742 *LENGTH. Use the JNI environment ENV. Value is NULL if copying 4762 *LENGTH. Use the JNI environment ENV. Value is NULL if copying
4743 *the string fails. */ 4763 the string fails. */
4744 4764
4745static unsigned short * 4765static unsigned short *
4746android_copy_java_string (JNIEnv *env, jstring string, size_t *length) 4766android_copy_java_string (JNIEnv *env, jstring string, size_t *length)