Search in sources :

Example 51 with InputConnection

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);
        }
    }
}
Also used : InputConnection(android.view.inputmethod.InputConnection) Spannable(android.text.Spannable)

Example 52 with InputConnection

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

Example 53 with InputConnection

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();
}
Also used : InputConnection(android.view.inputmethod.InputConnection) EditorInfo(android.view.inputmethod.EditorInfo) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) Point(android.graphics.Point)

Example 54 with InputConnection

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

Example 55 with InputConnection

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

Aggregations

InputConnection (android.view.inputmethod.InputConnection)81 EditorInfo (android.view.inputmethod.EditorInfo)20 InputBinding (android.view.inputmethod.InputBinding)14 InputConnectionWrapper (com.android.internal.view.InputConnectionWrapper)14 KeyEvent (android.view.KeyEvent)9 ViewGroup (android.view.ViewGroup)9 ExtractedTextRequest (android.view.inputmethod.ExtractedTextRequest)9 Editable (android.text.Editable)8 View (android.view.View)8 BaseInputConnection (android.view.inputmethod.BaseInputConnection)8 IBinder (android.os.IBinder)7 InputMethod (android.view.inputmethod.InputMethod)7 LinearLayout (android.widget.LinearLayout)7 TextView (android.widget.TextView)7 IInputContext (com.android.internal.view.IInputContext)7 IInputMethod (com.android.internal.view.IInputMethod)7 EditableInputConnection (com.android.internal.widget.EditableInputConnection)7 FileDescriptor (java.io.FileDescriptor)7 PrintWriter (java.io.PrintWriter)7 Spannable (android.text.Spannable)6