android.view.KeyboardShortcutGroup Java Examples

The following examples show how to use android.view.KeyboardShortcutGroup. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Launcher.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: PopupWindow.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void requestKeyboardShortcuts(List<KeyboardShortcutGroup> list, int deviceId) {
    if (mParentRootView != null) {
        View parentRoot = mParentRootView.get();
        if (parentRoot != null) {
            parentRoot.requestKeyboardShortcuts(list, deviceId);
        }
    }
}
 
Example #3
Source File: EditorActivity.java    From spline with Apache License 2.0 4 votes vote down vote up
@Override
public void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, Menu menu, int deviceId) {
    super.onProvideKeyboardShortcuts(data, menu, deviceId);
}
 
Example #4
Source File: BlueprintActivity.java    From CompositeAndroid with Apache License 2.0 4 votes vote down vote up
@Override
public void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, Menu menu, int deviceId) {
    super.onProvideKeyboardShortcuts(data, menu, deviceId);
}
 
Example #5
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, Menu menu,
        int deviceId) {
    data.addAll(KeyboardShortcuts.createShortcutGroup(this));
}
 
Example #6
Source File: KeyboardShortcuts.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #7
Source File: KeyboardShortcuts.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@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));
}
 
Example #8
Source File: CustomDialog.java    From CustomDialog with Apache License 2.0 2 votes vote down vote up
@Override
public void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, @Nullable Menu menu, int deviceId) {

}
 
Example #9
Source File: ICompositeActivity.java    From CompositeAndroid with Apache License 2.0 votes vote down vote up
void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, Menu menu, int deviceId); 
Example #10
Source File: ICompositeActivity.java    From CompositeAndroid with Apache License 2.0 votes vote down vote up
void super_onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, Menu menu, int deviceId);