[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/android 45b5c9b8b72: Improve radio button appearance in Android
From: |
Po Lu |
Subject: |
feature/android 45b5c9b8b72: Improve radio button appearance in Android menus |
Date: |
Fri, 17 Mar 2023 01:10:37 -0400 (EDT) |
branch: feature/android
commit 45b5c9b8b72a9dd561c7e2d43ead8ce64e79b041
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Improve radio button appearance in Android menus
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu):
New field `lastGroupId'.
(Item): New field `isRadio'.
(addItem): New arg `isRadio'.
(inflateMenuItems): Apply an empty radio button group if
required.
* src/androidmenu.c (android_init_emacs_context_menu): Adjust
accordingly.
(android_menu_show): Likewise.
---
java/org/gnu/emacs/EmacsContextMenu.java | 23 ++++++++++++++++++++---
src/androidmenu.c | 6 ++++--
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/java/org/gnu/emacs/EmacsContextMenu.java
b/java/org/gnu/emacs/EmacsContextMenu.java
index d780641ba70..5bae41bd61d 100644
--- a/java/org/gnu/emacs/EmacsContextMenu.java
+++ b/java/org/gnu/emacs/EmacsContextMenu.java
@@ -55,6 +55,9 @@ public final class EmacsContextMenu
/* The serial ID of the last context menu to be displayed. */
public static int lastMenuEventSerial;
+ /* The last group ID used for a menu item. */
+ public int lastGroupId;
+
private static class Item implements MenuItem.OnMenuItemClickListener
{
public int itemID;
@@ -62,6 +65,7 @@ public final class EmacsContextMenu
public EmacsContextMenu subMenu;
public boolean isEnabled, isCheckable, isChecked;
public EmacsView inflatedView;
+ public boolean isRadio;
@Override
public boolean
@@ -153,12 +157,14 @@ public final class EmacsContextMenu
checkable. Likewise, if ISCHECKED is set, make the item
checked.
- If TOOLTIP is non-NULL, set the menu item tooltip to TOOLTIP. */
+ If TOOLTIP is non-NULL, set the menu item tooltip to TOOLTIP.
+
+ If ISRADIO, then display the check mark as a radio button. */
public void
addItem (int itemID, String itemName, boolean isEnabled,
boolean isCheckable, boolean isChecked,
- String tooltip)
+ String tooltip, boolean isRadio)
{
Item item;
@@ -169,6 +175,7 @@ public final class EmacsContextMenu
item.isCheckable = isCheckable;
item.isChecked = isChecked;
item.tooltip = tooltip;
+ item.isRadio = isRadio;
menuItems.add (item);
}
@@ -244,7 +251,11 @@ public final class EmacsContextMenu
}
else
{
- menuItem = menu.add (item.itemName);
+ if (item.isRadio)
+ menuItem = menu.add (++lastGroupId, Menu.NONE, Menu.NONE,
+ item.itemName);
+ else
+ menuItem = menu.add (item.itemName);
menuItem.setOnMenuItemClickListener (item);
/* If the item ID is zero, then disable the item. */
@@ -260,6 +271,12 @@ public final class EmacsContextMenu
if (item.isChecked)
menuItem.setChecked (true);
+ /* Define an exclusively checkable group if the item is a
+ radio button. */
+
+ if (item.isRadio)
+ menu.setGroupCheckable (lastGroupId, true, true);
+
/* If the tooltip text is set and the system is new enough
to support menu item tooltips, set it on the item. */
diff --git a/src/androidmenu.c b/src/androidmenu.c
index 7d9c33e28b1..f74e7ca6d99 100644
--- a/src/androidmenu.c
+++ b/src/androidmenu.c
@@ -105,7 +105,7 @@ android_init_emacs_context_menu (void)
"Lorg/gnu/emacs/EmacsContextMenu;");
FIND_METHOD (add_item, "addItem", "(ILjava/lang/String;ZZZ"
- "Ljava/lang/String;)V");
+ "Ljava/lang/String;Z)V");
FIND_METHOD (add_submenu, "addSubmenu", "(Ljava/lang/String;"
"Ljava/lang/String;Ljava/lang/String;)"
"Lorg/gnu/emacs/EmacsContextMenu;");
@@ -442,7 +442,9 @@ android_menu_show (struct frame *f, int x, int y, int
menuflags,
(jboolean) !NILP (enable),
(jboolean) checkmark,
(jboolean) !NILP (selected),
- help_string);
+ help_string,
+ (jboolean) (EQ (type,
+ QCradio)));
android_exception_check ();
if (title_string)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- feature/android 45b5c9b8b72: Improve radio button appearance in Android menus,
Po Lu <=