diff options
| author | Po Lu <luangruo@yahoo.com> | 2023-02-11 10:26:34 +0800 |
|---|---|---|
| committer | Po Lu <luangruo@yahoo.com> | 2023-02-11 10:26:34 +0800 |
| commit | ab48881a2fb72df016f2a00bc107e5a35a411a9d (patch) | |
| tree | f2cc50a7ac906e40562e080a725ac98daf9ed484 /java/org/gnu/emacs/EmacsDialog.java | |
| parent | c4c34f72a123c4177a21c934c4e414cfe9e3c553 (diff) | |
Fix displaying popup menus from a menu entry on Android
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity, onDestroy)
(onWindowFocusChanged): Keep track of the last focused activity.
* java/org/gnu/emacs/EmacsDialog.java (display1): Use it if
there is no current focus.
Diffstat (limited to 'java/org/gnu/emacs/EmacsDialog.java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsDialog.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/java/org/gnu/emacs/EmacsDialog.java b/java/org/gnu/emacs/EmacsDialog.java index 7d88a23c58f..bd5e9ba8ee7 100644 --- a/java/org/gnu/emacs/EmacsDialog.java +++ b/java/org/gnu/emacs/EmacsDialog.java @@ -230,11 +230,31 @@ public class EmacsDialog implements DialogInterface.OnDismissListener AlertDialog dialog; if (EmacsActivity.focusedActivities.isEmpty ()) - return false; + { + /* If focusedActivities is empty then this dialog may have + been displayed immediately after a popup dialog is + dismissed. */ + + activity = EmacsActivity.lastFocusedActivity; + + if (activity == null) + return false; + } + else + activity = EmacsActivity.focusedActivities.get (0); - activity = EmacsActivity.focusedActivities.get (0); dialog = dismissDialog = toAlertDialog (activity); - dismissDialog.show (); + + try + { + dismissDialog.show (); + } + catch (Exception exception) + { + /* This can happen when the system decides Emacs is not in the + foreground any longer. */ + return false; + } /* If there are less than four buttons, then they must be individually enabled or disabled after the dialog is |
