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

Commit b22faf52 authored by Evan Rosky's avatar Evan Rosky
Browse files

Allow ToolbarActionBar to pass-through unhandled keyShortcuts

It was consuming all keyShortcuts which broke system hotkeys
like shift+tab.

In order to prevent the decor/phonewindow from creating menus,
this creates a dummy view in onCreatePanelView.

This also includes a change to Activity to not send KEYCODE_TAB
keystrokes to the defaulthandler. This was preventing keyboard
navigation from working on any activity that had a default
search fallback.

Bug: 32482282
Bug: 18021345
Test: Added a CTS test (ToolbarTest#testKeyShortcuts) for toolbar
      keyShortcuts. Verified Tab-navigation works in Play Store.
Change-Id: I5c732a2b21219157818bed49576debd20d5a8178
parent 082d21c1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2727,6 +2727,10 @@ public class Activity extends ContextThemeWrapper
                return true;
            }
            return false;
        } else if (keyCode == KeyEvent.KEYCODE_TAB) {
            // Don't consume TAB here since it's used for navigation. Arrow keys
            // aren't considered "typing keys" so they already won't get consumed.
            return false;
        } else {
            // Common code for DEFAULT_KEYS_DIALER & DEFAULT_KEYS_SEARCH_*
            boolean clearSpannable = false;
+13 −5
Original line number Diff line number Diff line
@@ -472,12 +472,9 @@ public class ToolbarActionBar extends ActionBar {
            final KeyCharacterMap kmap = KeyCharacterMap.load(
                    event != null ? event.getDeviceId() : KeyCharacterMap.VIRTUAL_KEYBOARD);
            menu.setQwertyMode(kmap.getKeyboardType() != KeyCharacterMap.NUMERIC);
            menu.performShortcut(keyCode, event, 0);
            return menu.performShortcut(keyCode, event, 0);
        }
        // This action bar always returns true for handling keyboard shortcuts.
        // This will block the window from preparing a temporary panel to handle
        // keyboard shortcuts.
        return true;
        return false;
    }

    @Override
@@ -520,6 +517,17 @@ public class ToolbarActionBar extends ActionBar {
            }
            return result;
        }

        @Override
        public View onCreatePanelView(int featureId) {
            if (featureId == Window.FEATURE_OPTIONS_PANEL) {
                // This gets called by PhoneWindow.preparePanel. Since this already manages
                // its own panel, we return a dummy view here to prevent PhoneWindow from
                // preparing a default one.
                return new View(mDecorToolbar.getContext());
            }
            return super.onCreatePanelView(featureId);
        }
    }

    private final class ActionMenuPresenterCallback implements MenuPresenter.Callback {