use of android.view.inputmethod.BaseInputConnection in project android_frameworks_base by ParanoidAndroid.
the class AbsListView method onCreateInputConnection.
/**
* Return an InputConnection for editing of the filter text.
*/
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
if (isTextFilterEnabled()) {
// XXX we need to have the text filter created, so we can get an
// InputConnection to proxy to. Unfortunately this means we pretty
// much need to make it as soon as a list view gets focus.
createTextFilter(false);
if (mPublicInputConnection == null) {
mDefInputConnection = new BaseInputConnection(this, false);
mPublicInputConnection = new InputConnectionWrapper(mTextFilter.onCreateInputConnection(outAttrs), true) {
@Override
public boolean reportFullscreenMode(boolean enabled) {
// the "real" one the IME is talking with.
return mDefInputConnection.reportFullscreenMode(enabled);
}
@Override
public boolean performEditorAction(int editorAction) {
// the one that does this.
if (editorAction == EditorInfo.IME_ACTION_DONE) {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(getWindowToken(), 0);
}
return true;
}
return false;
}
@Override
public boolean sendKeyEvent(KeyEvent event) {
// no ViewAncestor to dispatch events with.
return mDefInputConnection.sendKeyEvent(event);
}
};
}
outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_FILTER;
outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE;
return mPublicInputConnection;
}
return null;
}
use of android.view.inputmethod.BaseInputConnection in project libgdx by libgdx.
the class GLSurfaceView20API18 method onCreateInputConnection.
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
// add this line, the IME can show the selectable words when use chinese input method editor.
if (outAttrs != null) {
outAttrs.imeOptions = outAttrs.imeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
}
BaseInputConnection connection = new BaseInputConnection(this, false) {
@Override
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
int sdkVersion = android.os.Build.VERSION.SDK_INT;
if (sdkVersion >= 16) {
/*
* In Jelly Bean, they don't send key events for delete. Instead, they send beforeLength = 1, afterLength = 0. So,
* we'll just simulate what it used to do.
*/
if (beforeLength == 1 && afterLength == 0) {
sendDownUpKeyEventForBackwardCompatibility(KeyEvent.KEYCODE_DEL);
return true;
}
}
return super.deleteSurroundingText(beforeLength, afterLength);
}
@TargetApi(16)
private void sendDownUpKeyEventForBackwardCompatibility(final int code) {
final long eventTime = SystemClock.uptimeMillis();
super.sendKeyEvent(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, code, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
super.sendKeyEvent(new KeyEvent(SystemClock.uptimeMillis(), eventTime, KeyEvent.ACTION_UP, code, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
}
};
return connection;
}
use of android.view.inputmethod.BaseInputConnection in project remote-desktop-clients by iiordanov.
the class RemoteCanvas method onCreateInputConnection.
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
android.util.Log.d(TAG, "onCreateInputConnection called");
BaseInputConnection bic = new BaseInputConnection(this, false);
outAttrs.actionLabel = null;
outAttrs.inputType = InputType.TYPE_NULL;
String currentIme = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
android.util.Log.d(TAG, "currentIme: " + currentIme);
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_FULLSCREEN;
return bic;
}
use of android.view.inputmethod.BaseInputConnection in project cordova-android-chromeview by thedracle.
the class BackButtonMultiPageTest method testViaBackButtonOnLayout.
public void testViaBackButtonOnLayout() {
testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
sleep();
String url = testView.getUrl();
assertTrue(url.endsWith("sample2.html"));
testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample3.html");
sleep();
url = testView.getUrl();
assertTrue(url.endsWith("sample3.html"));
BaseInputConnection viewConnection = new BaseInputConnection(containerView, true);
KeyEvent backDown = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
KeyEvent backUp = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK);
viewConnection.sendKeyEvent(backDown);
viewConnection.sendKeyEvent(backUp);
sleep();
url = testView.getUrl();
assertTrue(url.endsWith("sample2.html"));
viewConnection.sendKeyEvent(backDown);
viewConnection.sendKeyEvent(backUp);
sleep();
url = testView.getUrl();
assertTrue(url.endsWith("index.html"));
}
use of android.view.inputmethod.BaseInputConnection in project libgdx by libgdx.
the class GLSurfaceView20 method onCreateInputConnection.
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
// add this line, the IME can show the selectable words when use chinese input method editor.
if (outAttrs != null) {
outAttrs.imeOptions = outAttrs.imeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
}
BaseInputConnection connection = new BaseInputConnection(this, false) {
@Override
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
int sdkVersion = android.os.Build.VERSION.SDK_INT;
if (sdkVersion >= 16) {
/*
* In Jelly Bean, they don't send key events for delete. Instead, they send beforeLength = 1, afterLength = 0. So,
* we'll just simulate what it used to do.
*/
if (beforeLength == 1 && afterLength == 0) {
sendDownUpKeyEventForBackwardCompatibility(KeyEvent.KEYCODE_DEL);
return true;
}
}
return super.deleteSurroundingText(beforeLength, afterLength);
}
@TargetApi(16)
private void sendDownUpKeyEventForBackwardCompatibility(final int code) {
final long eventTime = SystemClock.uptimeMillis();
super.sendKeyEvent(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, code, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
super.sendKeyEvent(new KeyEvent(SystemClock.uptimeMillis(), eventTime, KeyEvent.ACTION_UP, code, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
}
};
return connection;
}
Aggregations