@Override @TargetApi(Build.VERSION_CODES.N) public void onProvideKeyboardShortcuts( List<KeyboardShortcutGroup> data, Menu menu, int deviceId) { ArrayList<KeyboardShortcutInfo> shortcutInfos = new ArrayList<>(); if (mState == State.WORKSPACE) { shortcutInfos.add(new KeyboardShortcutInfo(getString(R.string.all_apps_button_label), KeyEvent.KEYCODE_A, KeyEvent.META_CTRL_ON)); } View currentFocus = getCurrentFocus(); if (new CustomActionsPopup(this, currentFocus).canShow()) { shortcutInfos.add(new KeyboardShortcutInfo(getString(R.string.custom_actions), KeyEvent.KEYCODE_O, KeyEvent.META_CTRL_ON)); } if (currentFocus.getTag() instanceof ItemInfo && DeepShortcutManager.supportsShortcuts((ItemInfo) currentFocus.getTag())) { shortcutInfos.add(new KeyboardShortcutInfo(getString(R.string.action_deep_shortcut), KeyEvent.KEYCODE_S, KeyEvent.META_CTRL_ON)); } if (!shortcutInfos.isEmpty()) { data.add(new KeyboardShortcutGroup(getString(R.string.home_screen), shortcutInfos)); } super.onProvideKeyboardShortcuts(data, menu, deviceId); }
public void onProvideKeyboardShortcuts(final List<KeyboardShortcutGroup> data, final Menu menu, final int deviceId) { verifyMethodCalledFromDelegate( "onProvideKeyboardShortcuts(List<KeyboardShortcutGroup>, Menu, Integer)"); ((CallVoid3<List<KeyboardShortcutGroup>, Menu, Integer>) mSuperListeners.pop()) .call(data, menu, deviceId); }
void onProvideKeyboardShortcuts( final CallVoid3<List<KeyboardShortcutGroup>, Menu, Integer> superCall, final List<KeyboardShortcutGroup> data, final Menu menu, final int deviceId) { synchronized (mSuperListeners) { mSuperListeners.push(superCall); onProvideKeyboardShortcuts(data, menu, deviceId); } }
@RequiresApi(api = Build.VERSION_CODES.N) @Override public void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, @Nullable Menu menu, int deviceId) { mCallback.onProvideKeyboardShortcuts(data, menu, deviceId); }
@Override public void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, Menu menu, int deviceId) { super.onProvideKeyboardShortcuts(data, menu, deviceId); }
@Override public void onProvideKeyboardShortcuts(final List<KeyboardShortcutGroup> data, final Menu menu, final int deviceId) { super.onProvideKeyboardShortcuts(data, menu, deviceId); }
@Override public void onProvideKeyboardShortcuts(final List<KeyboardShortcutGroup> data, final Menu menu, final int deviceId) { delegate.onProvideKeyboardShortcuts(data, menu, deviceId); }
@Override public void super_onProvideKeyboardShortcuts(final List<KeyboardShortcutGroup> data, final Menu menu, final int deviceId) { super.onProvideKeyboardShortcuts(data, menu, deviceId); }
void onProvideKeyboardShortcuts(final List<KeyboardShortcutGroup> data, final Menu menu, final int deviceId);
void super_onProvideKeyboardShortcuts(final List<KeyboardShortcutGroup> data, final Menu menu, final int deviceId);
@Override public void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, Menu menu, int deviceId) { data.addAll(KeyboardShortcuts.createShortcutGroup(this)); }
/** * This method should be called when overriding from * {@link android.app.Activity#onProvideKeyboardShortcuts(List, android.view.Menu, int)} * in an activity. It will return a list of the possible shortcuts. If * someone adds a shortcut they also need to add an explanation in the * appropriate group in this method so the user can see it when this method * is called. * * @param context We need an activity so we can call the strings from our * resource. * @return a list of shortcuts organized into groups. */ @TargetApi(Build.VERSION_CODES.N) public static List<KeyboardShortcutGroup> createShortcutGroup(Context context) { final int ctrlShift = KeyEvent.META_CTRL_ON | KeyEvent.META_SHIFT_ON; List<KeyboardShortcutGroup> shortcutGroups = new ArrayList<>(); KeyboardShortcutGroup tabShortcutGroup = new KeyboardShortcutGroup( context.getString(R.string.keyboard_shortcut_tab_group_header)); addShortcut(context, tabShortcutGroup, R.string.keyboard_shortcut_open_new_tab, KeyEvent.KEYCODE_N, KeyEvent.META_CTRL_ON); addShortcut(context, tabShortcutGroup, R.string.keyboard_shortcut_reopen_new_tab, KeyEvent.KEYCODE_T, ctrlShift); addShortcut(context, tabShortcutGroup, R.string.keyboard_shortcut_new_incognito_tab, KeyEvent.KEYCODE_N, ctrlShift); addShortcut(context, tabShortcutGroup, R.string.keyboard_shortcut_next_tab, KeyEvent.KEYCODE_TAB, KeyEvent.META_CTRL_ON); addShortcut(context, tabShortcutGroup, R.string.keyboard_shortcut_prev_tab, KeyEvent.KEYCODE_TAB, ctrlShift); addShortcut(context, tabShortcutGroup, R.string.keyboard_shortcut_close_tab, KeyEvent.KEYCODE_W, KeyEvent.META_CTRL_ON); shortcutGroups.add(tabShortcutGroup); KeyboardShortcutGroup chromeFeatureShortcutGroup = new KeyboardShortcutGroup( context.getString(R.string.keyboard_shortcut_chrome_feature_group_header)); addShortcut(context, chromeFeatureShortcutGroup, R.string.keyboard_shortcut_open_menu, KeyEvent.KEYCODE_E, KeyEvent.META_ALT_ON); addShortcut(context, chromeFeatureShortcutGroup, R.string.keyboard_shortcut_bookmark_manager, KeyEvent.KEYCODE_B, ctrlShift); addShortcut(context, chromeFeatureShortcutGroup, R.string.keyboard_shortcut_history_manager, KeyEvent.KEYCODE_H, KeyEvent.META_CTRL_ON); addShortcut(context, chromeFeatureShortcutGroup, R.string.keyboard_shortcut_find_bar, KeyEvent.KEYCODE_F, KeyEvent.META_CTRL_ON); addShortcut(context, chromeFeatureShortcutGroup, R.string.keyboard_shortcut_address_bar, KeyEvent.KEYCODE_L, KeyEvent.META_CTRL_ON); shortcutGroups.add(chromeFeatureShortcutGroup); KeyboardShortcutGroup webpageShortcutGroup = new KeyboardShortcutGroup( context.getString(R.string.keyboard_shortcut_webpage_group_header)); addShortcut(context, webpageShortcutGroup, R.string.keyboard_shortcut_print_page, KeyEvent.KEYCODE_P, KeyEvent.META_CTRL_ON); addShortcut(context, webpageShortcutGroup, R.string.keyboard_shortcut_reload_page, KeyEvent.KEYCODE_R, KeyEvent.META_CTRL_ON); addShortcut(context, webpageShortcutGroup, R.string.keyboard_shortcut_reload_no_cache, KeyEvent.KEYCODE_R, ctrlShift); addShortcut(context, webpageShortcutGroup, R.string.keyboard_shortcut_bookmark_page, KeyEvent.KEYCODE_D, KeyEvent.META_CTRL_ON); addShortcut(context, webpageShortcutGroup, R.string.keyboard_shortcut_zoom_in, KeyEvent.KEYCODE_EQUALS, KeyEvent.META_CTRL_ON); addShortcut(context, webpageShortcutGroup, R.string.keyboard_shortcut_zoom_out, KeyEvent.KEYCODE_MINUS, KeyEvent.META_CTRL_ON); addShortcut(context, webpageShortcutGroup, R.string.keyboard_shortcut_reset_zoom, KeyEvent.KEYCODE_0, KeyEvent.META_CTRL_ON); addShortcut(context, webpageShortcutGroup, R.string.keyboard_shortcut_help_center, KeyEvent.KEYCODE_SLASH, ctrlShift); shortcutGroups.add(webpageShortcutGroup); return shortcutGroups; }
@TargetApi(Build.VERSION_CODES.N) private static void addShortcut(Context context, KeyboardShortcutGroup shortcutGroup, int resId, int keyCode, int keyModifier) { shortcutGroup.addItem(new KeyboardShortcutInfo(context.getString(resId), keyCode, keyModifier)); }
@Override public void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, @Nullable Menu menu, int deviceId) { }