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));
}
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]);
}
}
}
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;
}
}
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);
}
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));
}
}
}
Aggregations