use of android.view.KeyboardShortcutInfo in project android_frameworks_base by AOSPA.
the class KeyboardShortcuts method getSystemShortcuts.
private KeyboardShortcutGroup getSystemShortcuts() {
final KeyboardShortcutGroup systemGroup = new KeyboardShortcutGroup(mContext.getString(R.string.keyboard_shortcut_group_system), true);
systemGroup.addItem(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_system_home), KeyEvent.KEYCODE_ENTER, KeyEvent.META_META_ON));
systemGroup.addItem(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_system_back), KeyEvent.KEYCODE_DEL, KeyEvent.META_META_ON));
systemGroup.addItem(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_system_recents), KeyEvent.KEYCODE_TAB, KeyEvent.META_ALT_ON));
systemGroup.addItem(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_system_notifications), KeyEvent.KEYCODE_N, KeyEvent.META_META_ON));
systemGroup.addItem(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_system_shortcuts_helper), KeyEvent.KEYCODE_SLASH, KeyEvent.META_META_ON));
systemGroup.addItem(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_system_switch_input), KeyEvent.KEYCODE_SPACE, KeyEvent.META_META_ON));
return systemGroup;
}
use of android.view.KeyboardShortcutInfo in project android_frameworks_base by ResurrectionRemix.
the class Activity method onProvideKeyboardShortcuts.
@Override
public void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, Menu menu, int deviceId) {
if (menu == null) {
return;
}
KeyboardShortcutGroup group = null;
int menuSize = menu.size();
for (int i = 0; i < menuSize; ++i) {
final MenuItem item = menu.getItem(i);
final CharSequence title = item.getTitle();
final char alphaShortcut = item.getAlphabeticShortcut();
if (title != null && alphaShortcut != MIN_VALUE) {
if (group == null) {
final int resource = mApplication.getApplicationInfo().labelRes;
group = new KeyboardShortcutGroup(resource != 0 ? getString(resource) : null);
}
group.addItem(new KeyboardShortcutInfo(title, alphaShortcut, KeyEvent.META_CTRL_ON));
}
}
if (group != null) {
data.add(group);
}
}
use of android.view.KeyboardShortcutInfo in project android_frameworks_base by DirtyUnicorns.
the class KeyboardShortcuts method getSystemShortcuts.
private KeyboardShortcutGroup getSystemShortcuts() {
final KeyboardShortcutGroup systemGroup = new KeyboardShortcutGroup(mContext.getString(R.string.keyboard_shortcut_group_system), true);
systemGroup.addItem(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_system_home), KeyEvent.KEYCODE_ENTER, KeyEvent.META_META_ON));
systemGroup.addItem(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_system_back), KeyEvent.KEYCODE_DEL, KeyEvent.META_META_ON));
systemGroup.addItem(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_system_recents), KeyEvent.KEYCODE_TAB, KeyEvent.META_ALT_ON));
systemGroup.addItem(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_system_notifications), KeyEvent.KEYCODE_N, KeyEvent.META_META_ON));
systemGroup.addItem(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_system_shortcuts_helper), KeyEvent.KEYCODE_SLASH, KeyEvent.META_META_ON));
systemGroup.addItem(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_system_switch_input), KeyEvent.KEYCODE_SPACE, KeyEvent.META_META_ON));
return systemGroup;
}
use of android.view.KeyboardShortcutInfo in project android_frameworks_base by crdroidandroid.
the class Activity method onProvideKeyboardShortcuts.
@Override
public void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, Menu menu, int deviceId) {
if (menu == null) {
return;
}
KeyboardShortcutGroup group = null;
int menuSize = menu.size();
for (int i = 0; i < menuSize; ++i) {
final MenuItem item = menu.getItem(i);
final CharSequence title = item.getTitle();
final char alphaShortcut = item.getAlphabeticShortcut();
if (title != null && alphaShortcut != MIN_VALUE) {
if (group == null) {
final int resource = mApplication.getApplicationInfo().labelRes;
group = new KeyboardShortcutGroup(resource != 0 ? getString(resource) : null);
}
group.addItem(new KeyboardShortcutInfo(title, alphaShortcut, KeyEvent.META_CTRL_ON));
}
}
if (group != null) {
data.add(group);
}
}
use of android.view.KeyboardShortcutInfo in project android_frameworks_base by crdroidandroid.
the class KeyboardShortcuts method populateKeyboardShortcuts.
private void populateKeyboardShortcuts(LinearLayout keyboardShortcutsLayout, List<KeyboardShortcutGroup> keyboardShortcutGroups) {
LayoutInflater inflater = LayoutInflater.from(mContext);
final int keyboardShortcutGroupsSize = keyboardShortcutGroups.size();
TextView shortcutsKeyView = (TextView) inflater.inflate(R.layout.keyboard_shortcuts_key_view, null, false);
shortcutsKeyView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
final int shortcutKeyTextItemMinWidth = shortcutsKeyView.getMeasuredHeight();
// Needed to be able to scale the image items to the same height as the text items.
final int shortcutKeyIconItemHeightWidth = shortcutsKeyView.getMeasuredHeight() - shortcutsKeyView.getPaddingTop() - shortcutsKeyView.getPaddingBottom();
for (int i = 0; i < keyboardShortcutGroupsSize; i++) {
KeyboardShortcutGroup group = keyboardShortcutGroups.get(i);
TextView categoryTitle = (TextView) inflater.inflate(R.layout.keyboard_shortcuts_category_title, keyboardShortcutsLayout, false);
categoryTitle.setText(group.getLabel());
categoryTitle.setTextColor(group.isSystemGroup() ? Utils.getColorAccent(mContext) : mContext.getColor(R.color.ksh_application_group_color));
keyboardShortcutsLayout.addView(categoryTitle);
LinearLayout shortcutContainer = (LinearLayout) inflater.inflate(R.layout.keyboard_shortcuts_container, keyboardShortcutsLayout, false);
final int itemsSize = group.getItems().size();
for (int j = 0; j < itemsSize; j++) {
KeyboardShortcutInfo info = group.getItems().get(j);
List<StringDrawableContainer> shortcutKeys = getHumanReadableShortcutKeys(info);
if (shortcutKeys == null) {
// Ignore shortcuts we can't display keys for.
Log.w(TAG, "Keyboard Shortcut contains unsupported keys, skipping.");
continue;
}
View shortcutView = inflater.inflate(R.layout.keyboard_shortcut_app_item, shortcutContainer, false);
if (info.getIcon() != null) {
ImageView shortcutIcon = (ImageView) shortcutView.findViewById(R.id.keyboard_shortcuts_icon);
shortcutIcon.setImageIcon(info.getIcon());
shortcutIcon.setVisibility(View.VISIBLE);
}
TextView shortcutKeyword = (TextView) shortcutView.findViewById(R.id.keyboard_shortcuts_keyword);
shortcutKeyword.setText(info.getLabel());
if (info.getIcon() != null) {
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) shortcutKeyword.getLayoutParams();
lp.removeRule(RelativeLayout.ALIGN_PARENT_START);
shortcutKeyword.setLayoutParams(lp);
}
ViewGroup shortcutItemsContainer = (ViewGroup) shortcutView.findViewById(R.id.keyboard_shortcuts_item_container);
final int shortcutKeysSize = shortcutKeys.size();
for (int k = 0; k < shortcutKeysSize; k++) {
StringDrawableContainer shortcutRepresentation = shortcutKeys.get(k);
if (shortcutRepresentation.mDrawable != null) {
ImageView shortcutKeyIconView = (ImageView) inflater.inflate(R.layout.keyboard_shortcuts_key_icon_view, shortcutItemsContainer, false);
Bitmap bitmap = Bitmap.createBitmap(shortcutKeyIconItemHeightWidth, shortcutKeyIconItemHeightWidth, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
shortcutRepresentation.mDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
shortcutRepresentation.mDrawable.draw(canvas);
shortcutKeyIconView.setImageBitmap(bitmap);
shortcutKeyIconView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
shortcutKeyIconView.setAccessibilityDelegate(new ShortcutKeyAccessibilityDelegate(shortcutRepresentation.mString));
shortcutItemsContainer.addView(shortcutKeyIconView);
} else if (shortcutRepresentation.mString != null) {
TextView shortcutKeyTextView = (TextView) inflater.inflate(R.layout.keyboard_shortcuts_key_view, shortcutItemsContainer, false);
shortcutKeyTextView.setMinimumWidth(shortcutKeyTextItemMinWidth);
shortcutKeyTextView.setText(shortcutRepresentation.mString);
shortcutKeyTextView.setAccessibilityDelegate(new ShortcutKeyAccessibilityDelegate(shortcutRepresentation.mString));
shortcutItemsContainer.addView(shortcutKeyTextView);
}
}
shortcutContainer.addView(shortcutView);
}
keyboardShortcutsLayout.addView(shortcutContainer);
if (i < keyboardShortcutGroupsSize - 1) {
View separator = inflater.inflate(R.layout.keyboard_shortcuts_category_separator, keyboardShortcutsLayout, false);
keyboardShortcutsLayout.addView(separator);
}
}
}
Aggregations