Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3c2c6cb authored by Clara Bayarri's avatar Clara Bayarri Committed by Android (Google) Code Review
Browse files

Merge "Fix Keyboard Shortcut Helper requires pressing META+/ twice"

parents b8b56b9b 3ac0ae07
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -74,7 +74,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<String> mSpecialCharacterNames = new SparseArray<>();
    private final SparseArray<String> mModifierNames = new SparseArray<>();
@@ -136,13 +135,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);
@@ -158,10 +156,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));