diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsDialog.java | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/java/org/gnu/emacs/EmacsDialog.java b/java/org/gnu/emacs/EmacsDialog.java index de5a37bd5c5..3a5f22021fc 100644 --- a/java/org/gnu/emacs/EmacsDialog.java +++ b/java/org/gnu/emacs/EmacsDialog.java | |||
| @@ -244,23 +244,26 @@ public final class EmacsDialog implements DialogInterface.OnDismissListener | |||
| 244 | AlertDialog dialog; | 244 | AlertDialog dialog; |
| 245 | Window window; | 245 | Window window; |
| 246 | 246 | ||
| 247 | /* First, try to display a dialog using the service context. */ | 247 | if (EmacsActivity.focusedActivities.isEmpty ()) |
| 248 | |||
| 249 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M | ||
| 250 | || Settings.canDrawOverlays (EmacsService.SERVICE)) | ||
| 251 | context = EmacsService.SERVICE; | ||
| 252 | else if (EmacsActivity.focusedActivities.isEmpty ()) | ||
| 253 | { | 248 | { |
| 254 | /* If focusedActivities is empty then this dialog may have | 249 | /* If focusedActivities is empty then this dialog may have |
| 255 | been displayed immediately after a popup dialog is | 250 | been displayed immediately after a popup dialog is |
| 256 | dismissed. */ | 251 | dismissed. Or Emacs might legitimately be in the |
| 252 | background. Try the service context first if possible. */ | ||
| 257 | 253 | ||
| 258 | context = EmacsActivity.lastFocusedActivity; | 254 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M |
| 255 | || Settings.canDrawOverlays (EmacsService.SERVICE)) | ||
| 256 | context = EmacsService.SERVICE; | ||
| 257 | else | ||
| 258 | context = EmacsActivity.lastFocusedActivity; | ||
| 259 | 259 | ||
| 260 | if (context == null) | 260 | if (context == null) |
| 261 | return false; | 261 | return false; |
| 262 | } | 262 | } |
| 263 | else | 263 | else |
| 264 | /* Display using the activity context when Emacs is in the | ||
| 265 | foreground, as this allows the dialog to be dismissed more | ||
| 266 | consistently. */ | ||
| 264 | context = EmacsActivity.focusedActivities.get (0); | 267 | context = EmacsActivity.focusedActivities.get (0); |
| 265 | 268 | ||
| 266 | Log.d (TAG, "display1: using context " + context); | 269 | Log.d (TAG, "display1: using context " + context); |