Search in sources :

Example 51 with KeyCharacterMap

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();
}
Also used : KeyCharacterMap(android.view.KeyCharacterMap)

Example 52 with KeyCharacterMap

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;
}
Also used : Menu(android.view.Menu) KeyCharacterMap(android.view.KeyCharacterMap)

Example 53 with KeyCharacterMap

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));
}
Also used : KeyEvent(android.view.KeyEvent) Instrumentation(android.app.Instrumentation) KeyCharacterMap(android.view.KeyCharacterMap)

Example 54 with KeyCharacterMap

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();
}
Also used : KeyCharacterMap(android.view.KeyCharacterMap)

Example 55 with KeyCharacterMap

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));
}
Also used : KeyEvent(android.view.KeyEvent) Instrumentation(android.app.Instrumentation) KeyCharacterMap(android.view.KeyCharacterMap)

Aggregations

KeyCharacterMap (android.view.KeyCharacterMap)66 KeyEvent (android.view.KeyEvent)35 Instrumentation (android.app.Instrumentation)6 ActivityNotFoundException (android.content.ActivityNotFoundException)5 Intent (android.content.Intent)5 RemoteException (android.os.RemoteException)5 IWindowManager (android.view.IWindowManager)5 FallbackAction (android.view.KeyCharacterMap.FallbackAction)5 Menu (android.view.Menu)5 WindowManager (android.view.WindowManager)5 LayoutParams (android.view.WindowManager.LayoutParams)4 IStatusBarService (com.android.internal.statusbar.IStatusBarService)4 IDeviceIdleController (android.os.IDeviceIdleController)3 RecognizerIntent (android.speech.RecognizerIntent)3 LargeTest (android.test.suitebuilder.annotation.LargeTest)3 IShortcutService (com.android.internal.policy.IShortcutService)3 ContentResolver (android.content.ContentResolver)2 View (android.view.View)2 ITelephony (com.android.internal.telephony.ITelephony)2 SuppressLint (android.annotation.SuppressLint)1