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

Commit 7ff3798f authored by Clara Bayarri's avatar Clara Bayarri
Browse files

State a fixed order for modifiers in the Shorcuts Helper

The current implementation takes the modifiers as stores in a
SparseArray, indexed by their KeyCode so they are showing up in
KeyCode order on the helper. We want to force order them into
something that makes more sense.

Bug: 29545953
Change-Id: Iad9b8a014075afdf9cf911c6393efde2ef9a7640
parent 71ea683b
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -85,6 +85,12 @@ public final class KeyboardShortcuts {
    private final SparseArray<String> mModifierNames = new SparseArray<>();
    private final SparseArray<Drawable> mSpecialCharacterDrawables = new SparseArray<>();
    private final SparseArray<Drawable> mModifierDrawables = new SparseArray<>();
    // Ordered list of modifiers that are supported. All values in this array must exist in
    // mModifierNames.
    private final int[] mModifierList = new int[] {
            KeyEvent.META_META_ON, KeyEvent.META_CTRL_ON, KeyEvent.META_ALT_ON,
            KeyEvent.META_SHIFT_ON, KeyEvent.META_SYM_ON, KeyEvent.META_FUNCTION_ON
    };

    private final Handler mHandler = new Handler(Looper.getMainLooper());
    private final Context mContext;
@@ -724,8 +730,8 @@ public final class KeyboardShortcuts {
        if (modifiers == 0) {
            return shortcutKeys;
        }
        for(int i = 0; i < mModifierNames.size(); ++i) {
            final int supportedModifier = mModifierNames.keyAt(i);
        for(int i = 0; i < mModifierList.length; ++i) {
            final int supportedModifier = mModifierList[i];
            if ((modifiers & supportedModifier) != 0) {
                shortcutKeys.add(new StringDrawableContainer(
                        mModifierNames.get(supportedModifier),