Java 类android.view.KeyboardShortcutInfo 实例源码

项目:LaunchEnr    文件:Launcher.java   
@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);
}
项目:365browser    文件:KeyboardShortcuts.java   
@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));
}