aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorPo Lu2023-07-20 11:21:25 +0800
committerPo Lu2023-07-20 11:21:25 +0800
commit7e8904e796807e3b8bfc20ed45135c53d8a86f50 (patch)
treece88ecb39d19e0f677989b80ad908611831b47e5 /java
parent4d3442ebad5cb1e1005cd5eca7e91c95e767ed65 (diff)
downloademacs-7e8904e796807e3b8bfc20ed45135c53d8a86f50.tar.gz
emacs-7e8904e796807e3b8bfc20ed45135c53d8a86f50.zip
Use context menu header titles on Android
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu): New field `title'. (addSubmenu): New arg TITLE. Set that field. (expandTo): Set MENU's header title if it's a context menu. * src/androidmenu.c (android_init_emacs_context_menu): Adjust signature of `createContextMenu'. (android_menu_show): Use TITLE instead of pane titles if there's only one pane.
Diffstat (limited to 'java')
-rw-r--r--java/org/gnu/emacs/EmacsContextMenu.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/java/org/gnu/emacs/EmacsContextMenu.java b/java/org/gnu/emacs/EmacsContextMenu.java
index eb83016c849..46eddeeda3d 100644
--- a/java/org/gnu/emacs/EmacsContextMenu.java
+++ b/java/org/gnu/emacs/EmacsContextMenu.java
@@ -27,6 +27,7 @@ import android.content.Intent;
27 27
28import android.os.Build; 28import android.os.Build;
29 29
30import android.view.ContextMenu;
30import android.view.Menu; 31import android.view.Menu;
31import android.view.MenuItem; 32import android.view.MenuItem;
32import android.view.View; 33import android.view.View;
@@ -130,18 +131,27 @@ public final class EmacsContextMenu
130 } 131 }
131 }; 132 };
132 133
134 /* List of menu items contained in this menu. */
133 public List<Item> menuItems; 135 public List<Item> menuItems;
136
137 /* The parent context menu, or NULL if none. */
134 private EmacsContextMenu parent; 138 private EmacsContextMenu parent;
135 139
140 /* The title of this context menu, or NULL if none. */
141 private String title;
142
143
144
136 /* Create a context menu with no items inside and the title TITLE, 145 /* Create a context menu with no items inside and the title TITLE,
137 which may be NULL. */ 146 which may be NULL. */
138 147
139 public static EmacsContextMenu 148 public static EmacsContextMenu
140 createContextMenu () 149 createContextMenu (String title)
141 { 150 {
142 EmacsContextMenu menu; 151 EmacsContextMenu menu;
143 152
144 menu = new EmacsContextMenu (); 153 menu = new EmacsContextMenu ();
154 menu.title = title;
145 menu.menuItems = new ArrayList<Item> (); 155 menu.menuItems = new ArrayList<Item> ();
146 156
147 return menu; 157 return menu;
@@ -204,7 +214,7 @@ public final class EmacsContextMenu
204 item.itemID = 0; 214 item.itemID = 0;
205 item.itemName = itemName; 215 item.itemName = itemName;
206 item.tooltip = tooltip; 216 item.tooltip = tooltip;
207 item.subMenu = createContextMenu (); 217 item.subMenu = createContextMenu (itemName);
208 item.subMenu.parent = this; 218 item.subMenu.parent = this;
209 219
210 menuItems.add (item); 220 menuItems.add (item);
@@ -287,12 +297,22 @@ public final class EmacsContextMenu
287 297
288 /* Enter the items in this context menu to MENU. 298 /* Enter the items in this context menu to MENU.
289 Assume that MENU will be displayed in VIEW; this may lead to 299 Assume that MENU will be displayed in VIEW; this may lead to
290 popupMenu being called on VIEW if a submenu is selected. */ 300 popupMenu being called on VIEW if a submenu is selected.
301
302 If MENU is a ContextMenu, set its header title to the one
303 contained in this object. */
291 304
292 public void 305 public void
293 expandTo (Menu menu, EmacsView view) 306 expandTo (Menu menu, EmacsView view)
294 { 307 {
295 inflateMenuItems (menu, view); 308 inflateMenuItems (menu, view);
309
310 /* See if menu is a ContextMenu and a title is set. */
311 if (title == null || !(menu instanceof ContextMenu))
312 return;
313
314 /* Set its title to this.title. */
315 ((ContextMenu) menu).setHeaderTitle (title);
296 } 316 }
297 317
298 /* Return the parent or NULL. */ 318 /* Return the parent or NULL. */