From 9fe1077b0506f7b425ae3ca355dbc4c62df16aad Mon Sep 17 00:00:00 2001 From: Clara Bayarri Date: Wed, 1 Jun 2016 17:28:14 +0100 Subject: [PATCH] DO NOT MERGE Fix Keyboard Shortcut Helper requires pressing META+/ twice By using a local boolean we were missing out on when the system dismisses the window with the back key. Bug: 28910518 Change-Id: I87b21c11830eaf81e3fd9586be6e3a7bb59c8a1f (cherry picked from commit 3ac0ae076e4baee06804e93adb7b5573d5de67de) --- .../android/systemui/statusbar/KeyboardShortcuts.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java index 79e06c639af28..92115620a81bf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java @@ -72,7 +72,6 @@ public final class KeyboardShortcuts { private static final String TAG = KeyboardShortcuts.class.getSimpleName(); private static final Object sLock = new Object(); private static KeyboardShortcuts sInstance; - private static boolean sIsShowing; private final SparseArray mSpecialCharacterNames = new SparseArray<>(); private final SparseArray mModifierNames = new SparseArray<>(); @@ -131,13 +130,12 @@ public final class KeyboardShortcuts { dismiss(); } getInstance(context).showKeyboardShortcuts(deviceId); - sIsShowing = true; } } public static void toggle(Context context, int deviceId) { synchronized (sLock) { - if (sIsShowing) { + if (isShowing()) { dismiss(); } else { show(context, deviceId); @@ -151,10 +149,14 @@ public final class KeyboardShortcuts { sInstance.dismissKeyboardShortcuts(); sInstance = null; } - sIsShowing = false; } } + private static boolean isShowing() { + return sInstance != null && sInstance.mKeyboardShortcutsDialog != null + && sInstance.mKeyboardShortcutsDialog.isShowing(); + } + private void loadResources(Context context) { mSpecialCharacterNames.put( KeyEvent.KEYCODE_HOME, context.getString(R.string.keyboard_key_home));