Search in sources :

Example 46 with KeyEvent

use of android.view.KeyEvent in project XobotOS by xamarin.

the class Instrumentation method sendCharacterSync.

/**
     * Higher-level method for sending both the down and up key events for a
     * particular character key code.  Equivalent to creating both KeyEvent
     * objects by hand and calling {@link #sendKeySync}.  The event appears
     * as if it came from keyboard 0, the built in one.
     * 
     * @param keyCode The key code of the character to send.
     */
public void sendCharacterSync(int keyCode) {
    sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, keyCode));
    sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, keyCode));
}
Also used : KeyEvent(android.view.KeyEvent)

Example 47 with KeyEvent

use of android.view.KeyEvent in project XobotOS by xamarin.

the class Instrumentation method sendStringSync.

/**
     * Sends the key events corresponding to the text to the app being
     * instrumented.
     * 
     * @param text The text to be sent. 
     */
public void sendStringSync(String text) {
    if (text == null) {
        return;
    }
    KeyCharacterMap keyCharacterMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
    KeyEvent[] events = keyCharacterMap.getEvents(text.toCharArray());
    if (events != null) {
        for (int i = 0; i < events.length; i++) {
            sendKeySync(events[i]);
        }
    }
}
Also used : KeyEvent(android.view.KeyEvent) KeyCharacterMap(android.view.KeyCharacterMap)

Example 48 with KeyEvent

use of android.view.KeyEvent in project XobotOS by xamarin.

the class WebTextView method onEditorAction.

@Override
public void onEditorAction(int actionCode) {
    switch(actionCode) {
        case EditorInfo.IME_ACTION_NEXT:
            if (mWebView.nativeMoveCursorToNextTextInput()) {
                // Preemptively rebuild the WebTextView, so that the action will
                // be set properly.
                mWebView.rebuildWebTextView();
                setDefaultSelection();
                mWebView.invalidate();
            }
            break;
        case EditorInfo.IME_ACTION_DONE:
            super.onEditorAction(actionCode);
            break;
        case EditorInfo.IME_ACTION_GO:
        case EditorInfo.IME_ACTION_SEARCH:
            // Send an enter and hide the soft keyboard
            InputMethodManager.getInstance(mContext).hideSoftInputFromWindow(getWindowToken(), 0);
            sendDomEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
            sendDomEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER));
        default:
            break;
    }
}
Also used : KeyEvent(android.view.KeyEvent)

Example 49 with KeyEvent

use of android.view.KeyEvent in project XobotOS by xamarin.

the class WebView method letPageHandleNavKey.

/**
     * Pass the key directly to the page.  This assumes that
     * nativePageShouldHandleShiftAndArrows() returned true.
     */
private void letPageHandleNavKey(int keyCode, long time, boolean down, int metaState) {
    int keyEventAction;
    int eventHubAction;
    if (down) {
        keyEventAction = KeyEvent.ACTION_DOWN;
        eventHubAction = EventHub.KEY_DOWN;
        playSoundEffect(keyCodeToSoundsEffect(keyCode));
    } else {
        keyEventAction = KeyEvent.ACTION_UP;
        eventHubAction = EventHub.KEY_UP;
    }
    KeyEvent event = new KeyEvent(time, time, keyEventAction, keyCode, 1, (metaState & KeyEvent.META_SHIFT_ON) | (metaState & KeyEvent.META_ALT_ON) | (metaState & KeyEvent.META_SYM_ON), KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0);
    mWebViewCore.sendMessage(eventHubAction, event);
}
Also used : KeyEvent(android.view.KeyEvent) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 50 with KeyEvent

use of android.view.KeyEvent in project XobotOS by xamarin.

the class PasswordEntryKeyboardHelper method sendKeyEventsToTarget.

private void sendKeyEventsToTarget(int character) {
    Handler handler = mTargetView.getHandler();
    KeyEvent[] events = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD).getEvents(new char[] { (char) character });
    if (events != null) {
        final int N = events.length;
        for (int i = 0; i < N; i++) {
            KeyEvent event = events[i];
            event = KeyEvent.changeFlags(event, event.getFlags() | KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE);
            handler.sendMessage(handler.obtainMessage(ViewRootImpl.DISPATCH_KEY, event));
        }
    }
}
Also used : KeyEvent(android.view.KeyEvent) Handler(android.os.Handler)

Aggregations

KeyEvent (android.view.KeyEvent)513 View (android.view.View)145 TextView (android.widget.TextView)109 Intent (android.content.Intent)53 ImageView (android.widget.ImageView)38 DialogInterface (android.content.DialogInterface)36 EditText (android.widget.EditText)36 KeyCharacterMap (android.view.KeyCharacterMap)35 Editable (android.text.Editable)34 OnEditorActionListener (android.widget.TextView.OnEditorActionListener)32 Instrumentation (android.app.Instrumentation)30 OnClickListener (android.view.View.OnClickListener)30 Paint (android.graphics.Paint)27 Button (android.widget.Button)27 TextWatcher (android.text.TextWatcher)24 InputMethodManager (android.view.inputmethod.InputMethodManager)22 AlertDialog (android.app.AlertDialog)21 Message (android.os.Message)21 LayoutInflater (android.view.LayoutInflater)21 Test (org.junit.Test)20