use of android.view.inputmethod.InputConnection in project platform_frameworks_base by android.
the class InputMethodService method onExtractedSetSpan.
/**
* @hide
*/
public void onExtractedSetSpan(Object span, int start, int end, int flags) {
InputConnection conn = getCurrentInputConnection();
if (conn != null) {
if (!conn.setSelection(start, end))
return;
CharSequence text = conn.getSelectedText(InputConnection.GET_TEXT_WITH_STYLES);
if (text instanceof Spannable) {
((Spannable) text).setSpan(span, 0, text.length(), flags);
conn.setComposingRegion(start, end);
conn.commitText(text, 1);
}
}
}
use of android.view.inputmethod.InputConnection in project platform_frameworks_base by android.
the class InputMethodService method onExtractedReplaceText.
/**
* @hide
*/
public void onExtractedReplaceText(int start, int end, CharSequence text) {
InputConnection conn = getCurrentInputConnection();
if (conn != null) {
conn.setComposingRegion(start, end);
conn.commitText(text, 1);
}
}
use of android.view.inputmethod.InputConnection in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class InputTestsBase method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mEditText = new MyEditText(getContext());
final int inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
mEditText.setInputType(inputType);
mEditText.setEnabled(true);
mLastCursorPos = 0;
if (null == Looper.myLooper()) {
Looper.prepare();
}
setupService();
mLatinIME = getService();
setDebugMode(true);
mPreviousBigramPredictionSettings = setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS, true, true);
mPreviousAutoCorrectSetting = setBooleanPreference(Settings.PREF_AUTO_CORRECTION, DEFAULT_AUTO_CORRECTION, DEFAULT_AUTO_CORRECTION);
mLatinIME.onCreate();
EditorInfo ei = new EditorInfo();
final InputConnection ic = mEditText.onCreateInputConnection(ei);
final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final ViewGroup vg = new FrameLayout(getContext());
mInputView = inflater.inflate(R.layout.input_view, vg);
ei = enrichEditorInfo(ei);
mLatinIME.onCreateInputMethodInterface().startInput(ic, ei);
mLatinIME.setInputView(mInputView);
mLatinIME.onBindInput();
mLatinIME.onCreateInputView();
mLatinIME.onStartInputView(ei, false);
mInputConnection = ic;
changeLanguage("en_US");
// Run messages to avoid the messages enqueued by startInputView() and its friends
// to run on a later call and ruin things. We need to wait first because some of them
// can be posted with a delay (notably, MSG_RESUME_SUGGESTIONS)
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS_MILLIS);
runMessages();
}
use of android.view.inputmethod.InputConnection in project double-espresso by JakeWharton.
the class EditorAction method perform.
@Override
public void perform(UiController uiController, View view) {
EditorInfo editorInfo = new EditorInfo();
InputConnection inputConnection = view.onCreateInputConnection(editorInfo);
if (inputConnection == null) {
throw new PerformException.Builder().withActionDescription(this.toString()).withViewDescription(HumanReadables.describe(view)).withCause(new IllegalStateException("View does not support input methods")).build();
}
int actionId = editorInfo.actionId != 0 ? editorInfo.actionId : editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION;
if (actionId == EditorInfo.IME_ACTION_NONE) {
throw new PerformException.Builder().withActionDescription(this.getDescription()).withViewDescription(HumanReadables.describe(view)).withCause(new IllegalStateException("No available action on view")).build();
}
if (!inputConnection.performEditorAction(actionId)) {
throw new PerformException.Builder().withActionDescription(this.getDescription()).withViewDescription(HumanReadables.describe(view)).withCause(new RuntimeException(String.format("Failed to perform action %#x. Input connection no longer valid", actionId))).build();
}
}
use of android.view.inputmethod.InputConnection in project XobotOS by xamarin.
the class WebView method onCreateInputConnection.
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
InputConnection connection = super.onCreateInputConnection(outAttrs);
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_FULLSCREEN;
return connection;
}
Aggregations