aboutsummaryrefslogtreecommitdiffstats
path: root/src/androidmenu.c
diff options
context:
space:
mode:
authorPo Lu2023-02-21 21:07:57 +0800
committerPo Lu2023-02-21 21:07:57 +0800
commit77feba74564c4d58b472b82fec0137091bb5c7e1 (patch)
tree23d08bc1e5e0b11d95a09a7559e8224c9bbd56d0 /src/androidmenu.c
parent8ca4162ecdb174e59d59fc127a1bc4fef7b89fa2 (diff)
downloademacs-77feba74564c4d58b472b82fec0137091bb5c7e1.tar.gz
emacs-77feba74564c4d58b472b82fec0137091bb5c7e1.zip
Update Android port
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu) (addSubmenu, inflateMenuItems): Handle tooltips correctly. * src/android.c (android_scan_directory_tree): Fix limit generation for root directory. * src/androidmenu.c (android_init_emacs_context_menu) (android_menu_show): Implement menu item help text on Android 8.0 and later.
Diffstat (limited to 'src/androidmenu.c')
-rw-r--r--src/androidmenu.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/androidmenu.c b/src/androidmenu.c
index acad775f26a..e1b64b9a545 100644
--- a/src/androidmenu.c
+++ b/src/androidmenu.c
@@ -100,7 +100,8 @@ android_init_emacs_context_menu (void)
100 100
101 FIND_METHOD (add_item, "addItem", "(ILjava/lang/String;ZZZ)V"); 101 FIND_METHOD (add_item, "addItem", "(ILjava/lang/String;ZZZ)V");
102 FIND_METHOD (add_submenu, "addSubmenu", "(Ljava/lang/String;" 102 FIND_METHOD (add_submenu, "addSubmenu", "(Ljava/lang/String;"
103 "Ljava/lang/String;)Lorg/gnu/emacs/EmacsContextMenu;"); 103 "Ljava/lang/String;Ljava/lang/String;)"
104 "Lorg/gnu/emacs/EmacsContextMenu;");
104 FIND_METHOD (add_pane, "addPane", "(Ljava/lang/String;)V"); 105 FIND_METHOD (add_pane, "addPane", "(Ljava/lang/String;)V");
105 FIND_METHOD (parent, "parent", "()Lorg/gnu/emacs/EmacsContextMenu;"); 106 FIND_METHOD (parent, "parent", "()Lorg/gnu/emacs/EmacsContextMenu;");
106 FIND_METHOD (display, "display", "(Lorg/gnu/emacs/EmacsWindow;II)Z"); 107 FIND_METHOD (display, "display", "(Lorg/gnu/emacs/EmacsWindow;II)Z");
@@ -236,12 +237,13 @@ android_menu_show (struct frame *f, int x, int y, int menuflags,
236 Lisp_Object title, const char **error_name) 237 Lisp_Object title, const char **error_name)
237{ 238{
238 jobject context_menu, current_context_menu; 239 jobject context_menu, current_context_menu;
239 jobject title_string, temp; 240 jobject title_string, help_string, temp;
240 size_t i; 241 size_t i;
241 Lisp_Object pane_name, prefix; 242 Lisp_Object pane_name, prefix;
242 const char *pane_string; 243 const char *pane_string;
243 specpdl_ref count, count1; 244 specpdl_ref count, count1;
244 Lisp_Object item_name, enable, def, tem, entry, type, selected; 245 Lisp_Object item_name, enable, def, tem, entry, type, selected;
246 Lisp_Object help;
245 jmethodID method; 247 jmethodID method;
246 jobject store; 248 jobject store;
247 bool rc; 249 bool rc;
@@ -354,6 +356,7 @@ android_menu_show (struct frame *f, int x, int y, int menuflags,
354 def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION); 356 def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION);
355 type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE); 357 type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE);
356 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED); 358 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
359 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
357 360
358 /* This is an actual menu item (or submenu). Add it to the 361 /* This is an actual menu item (or submenu). Add it to the
359 menu. */ 362 menu. */
@@ -365,12 +368,22 @@ android_menu_show (struct frame *f, int x, int y, int menuflags,
365 title_string = (!NILP (item_name) 368 title_string = (!NILP (item_name)
366 ? android_build_string (item_name) 369 ? android_build_string (item_name)
367 : NULL); 370 : NULL);
371 help_string = NULL;
372
373 /* Menu items can have tool tips on Android 26 and
374 later. In this case, set it to the help string. */
375
376 if (android_get_current_api_level () >= 26
377 && STRINGP (help))
378 help_string = android_build_string (help_string);
379
368 store = current_context_menu; 380 store = current_context_menu;
369 current_context_menu 381 current_context_menu
370 = (*android_java_env)->CallObjectMethod (android_java_env, 382 = (*android_java_env)->CallObjectMethod (android_java_env,
371 current_context_menu, 383 current_context_menu,
372 menu_class.add_submenu, 384 menu_class.add_submenu,
373 title_string, NULL); 385 title_string, NULL,
386 help_string);
374 android_exception_check (); 387 android_exception_check ();
375 388
376 if (store != context_menu) 389 if (store != context_menu)
@@ -378,6 +391,9 @@ android_menu_show (struct frame *f, int x, int y, int menuflags,
378 391
379 if (title_string) 392 if (title_string)
380 ANDROID_DELETE_LOCAL_REF (title_string); 393 ANDROID_DELETE_LOCAL_REF (title_string);
394
395 if (help_string)
396 ANDROID_DELETE_LOCAL_REF (help_string);
381 } 397 }
382 else if (NILP (def) && menu_separator_name_p (SSDATA (item_name))) 398 else if (NILP (def) && menu_separator_name_p (SSDATA (item_name)))
383 /* Ignore this separator item. */ 399 /* Ignore this separator item. */