use of android.view.KeyCharacterMap in project XobotOS by xamarin.
the class TextKeyListener method getKeyListener.
private KeyListener getKeyListener(KeyEvent event) {
KeyCharacterMap kmap = event.getKeyCharacterMap();
int kind = kmap.getKeyboardType();
if (kind == KeyCharacterMap.ALPHA) {
return QwertyKeyListener.getInstance(mAutoText, mAutoCap);
} else if (kind == KeyCharacterMap.NUMERIC) {
return MultiTapKeyListener.getInstance(mAutoText, mAutoCap);
} else if (kind == KeyCharacterMap.FULL || kind == KeyCharacterMap.SPECIAL_FUNCTION) {
// these applications should be modified to use KeyCharacterMap.VIRTUAL_KEYBOARD.
return QwertyKeyListener.getInstanceForFullKeyboard();
}
return NullKeyListener.getInstance();
}
use of android.view.KeyCharacterMap in project android_frameworks_base by DirtyUnicorns.
the class ToolbarActionBar method onKeyShortcut.
@Override
public boolean onKeyShortcut(int keyCode, KeyEvent event) {
Menu menu = mDecorToolbar.getMenu();
if (menu != null) {
final KeyCharacterMap kmap = KeyCharacterMap.load(event != null ? event.getDeviceId() : KeyCharacterMap.VIRTUAL_KEYBOARD);
menu.setQwertyMode(kmap.getKeyboardType() != KeyCharacterMap.NUMERIC);
menu.performShortcut(keyCode, event, 0);
}
// keyboard shortcuts.
return true;
}
use of android.view.KeyCharacterMap in project android_frameworks_base by DirtyUnicorns.
the class KeyUtils method chordMenuKey.
/**
* Simulates chording the menu key.
*
* @param test The test case that is being run.
* @param shortcutKey The shortcut key to tap while chording the menu key.
*/
public static void chordMenuKey(ActivityInstrumentationTestCase test, char shortcutKey) {
final Instrumentation inst = test.getInstrumentation();
final KeyEvent pushMenuKey = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MENU);
final KeyCharacterMap keyCharMap = KeyCharacterMap.load(pushMenuKey.getDeviceId());
final KeyEvent shortcutKeyEvent = keyCharMap.getEvents(new char[] { shortcutKey })[0];
final int shortcutKeyCode = shortcutKeyEvent.getKeyCode();
inst.sendKeySync(pushMenuKey);
inst.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, shortcutKeyCode));
inst.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, shortcutKeyCode));
inst.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MENU));
}
use of android.view.KeyCharacterMap in project android_frameworks_base by AOSPA.
the class TextKeyListener method getKeyListener.
private KeyListener getKeyListener(KeyEvent event) {
KeyCharacterMap kmap = event.getKeyCharacterMap();
int kind = kmap.getKeyboardType();
if (kind == KeyCharacterMap.ALPHA) {
return QwertyKeyListener.getInstance(mAutoText, mAutoCap);
} else if (kind == KeyCharacterMap.NUMERIC) {
return MultiTapKeyListener.getInstance(mAutoText, mAutoCap);
} else if (kind == KeyCharacterMap.FULL || kind == KeyCharacterMap.SPECIAL_FUNCTION) {
// these applications should be modified to use KeyCharacterMap.VIRTUAL_KEYBOARD.
return QwertyKeyListener.getInstanceForFullKeyboard();
}
return NullKeyListener.getInstance();
}
use of android.view.KeyCharacterMap in project android_frameworks_base by AOSPA.
the class KeyUtils method chordMenuKey.
/**
* Simulates chording the menu key.
*
* @param test The test case that is being run.
* @param shortcutKey The shortcut key to tap while chording the menu key.
*/
public static void chordMenuKey(ActivityInstrumentationTestCase test, char shortcutKey) {
final Instrumentation inst = test.getInstrumentation();
final KeyEvent pushMenuKey = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MENU);
final KeyCharacterMap keyCharMap = KeyCharacterMap.load(pushMenuKey.getDeviceId());
final KeyEvent shortcutKeyEvent = keyCharMap.getEvents(new char[] { shortcutKey })[0];
final int shortcutKeyCode = shortcutKeyEvent.getKeyCode();
inst.sendKeySync(pushMenuKey);
inst.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, shortcutKeyCode));
inst.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, shortcutKeyCode));
inst.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MENU));
}
Aggregations