Search in sources :

Example 96 with InputConnection

use of android.view.inputmethod.InputConnection in project deltachat-android by deltachat.

the class ComposeText method onCreateInputConnection.

@Override
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
    InputConnection inputConnection = super.onCreateInputConnection(editorInfo);
    if (Prefs.isEnterSendsEnabled(getContext())) {
        editorInfo.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
    }
    if (Build.VERSION.SDK_INT < 21)
        return inputConnection;
    if (mediaListener == null)
        return inputConnection;
    if (inputConnection == null)
        return null;
    // media with mime-types defined by setContentMimeTypes() may be selected in the system keyboard
    // and are passed to onCommitContent() then;
    // from there we use them as stickers.
    EditorInfoCompat.setContentMimeTypes(editorInfo, new String[] { "image/jpeg", "image/png", "image/gif", "image/webp" });
    return InputConnectionCompat.createWrapper(inputConnection, editorInfo, new CommitContentListener(mediaListener));
}
Also used : InputConnection(android.view.inputmethod.InputConnection)

Example 97 with InputConnection

use of android.view.inputmethod.InputConnection in project android-java-chat-push-notification-app by cometchat-pro.

the class CometChatEditText method onCreateInputConnection.

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    final InputConnection ic = super.onCreateInputConnection(outAttrs);
    EditorInfoCompat.setContentMimeTypes(outAttrs, new String[] { "image/png", "image/gif" });
    final InputConnectionCompat.OnCommitContentListener callback = new InputConnectionCompat.OnCommitContentListener() {

        @Override
        public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts) {
            // read and display inputContentInfo asynchronously
            if (BuildCompat.isAtLeastNMR1() && (flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) {
                try {
                    inputContentInfo.requestPermission();
                } catch (Exception e) {
                    // return false if failed
                    return false;
                }
            }
            ContentResolver cr = getContext().getContentResolver();
            String mimeType = cr.getType(inputContentInfo.getLinkUri());
            Log.e(TAG, "onCommitContent: " + inputContentInfo.getLinkUri().getPath() + "\n" + inputContentInfo.getContentUri() + "\n" + mimeType);
            onEditTextMediaListener.OnMediaSelected(inputContentInfo);
            // return true if succeeded
            return true;
        }
    };
    return InputConnectionCompat.createWrapper(ic, outAttrs, callback);
}
Also used : InputConnection(android.view.inputmethod.InputConnection) InputContentInfoCompat(androidx.core.view.inputmethod.InputContentInfoCompat) Bundle(android.os.Bundle) InputConnectionCompat(androidx.core.view.inputmethod.InputConnectionCompat) ContentResolver(android.content.ContentResolver)

Example 98 with InputConnection

use of android.view.inputmethod.InputConnection in project K6nele by Kaljurand.

the class SpeechInputMethodService method onStartInputView.

/**
 * Note that when editing a HTML page, then switching between form fields might fail to call
 * this method with restarting=false, we thus always update the editor info (incl. inputType).
 */
@Override
public void onStartInputView(EditorInfo editorInfo, boolean restarting) {
    super.onStartInputView(editorInfo, restarting);
    Log.i("onStartInputView: " + editorInfo.inputType + "/" + editorInfo.imeOptions + "/" + restarting);
    InputConnection ic = getCurrentInputConnection();
    // TODO: review, e.g. move to after restarting-check
    if (ic == null) {
        toast(R.string.errorFailedGetCurrentInputConnection);
        // switchToLastIme();
        return;
    }
    ((InputConnectionCommandEditor) mCommandEditor).setInputConnection(ic);
    // TODO: quick hack to add app to the matcher, not sure if we can access the class name of the app
    // TODO: use getPackageName() or editorInfo.packageName, but not both
    String packageName = editorInfo.packageName;
    ComponentName app = new ComponentName(packageName, packageName);
    mInputView.init(R.array.keysIme, new CallerInfo(makeExtras(), editorInfo, getPackageName()), true, app);
    // TODO: update this less often (in onStart)
    closeSession();
    if (restarting) {
        return;
    }
    mInputView.setListener(getSpeechInputViewListener(getMyWindow(), app, mRuleManager), editorInfo);
    mShowPartialResults = PreferenceUtils.getPrefBoolean(mPrefs, mRes, R.string.keyImeShowPartialResults, R.bool.defaultImeShowPartialResults);
    // Launch recognition immediately (if set so)
    if (PreferenceUtils.getPrefBoolean(mPrefs, mRes, R.string.keyImeAutoStart, R.bool.defaultImeAutoStart)) {
        Log.i("Auto-starting");
        mInputView.start();
    }
}
Also used : InputConnection(android.view.inputmethod.InputConnection) CallerInfo(ee.ioc.phon.android.speak.model.CallerInfo) ComponentName(android.content.ComponentName) InputConnectionCommandEditor(ee.ioc.phon.android.speechutils.editor.InputConnectionCommandEditor)

Example 99 with InputConnection

use of android.view.inputmethod.InputConnection in project wire-android by wireapp.

the class CursorEditText method onCreateInputConnection.

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    InputConnection conn = super.onCreateInputConnection(outAttrs);
    outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
    return new CursorInputConnection(conn, true);
}
Also used : InputConnection(android.view.inputmethod.InputConnection)

Example 100 with InputConnection

use of android.view.inputmethod.InputConnection in project syncthing-android by syncthing.

the class EnhancedEditText method onCreateInputConnection.

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    InputConnection conn = super.onCreateInputConnection(outAttrs);
    outAttrs.imeOptions &= ~IME_FLAG_NO_ENTER_ACTION;
    return conn;
}
Also used : InputConnection(android.view.inputmethod.InputConnection)

Aggregations

InputConnection (android.view.inputmethod.InputConnection)187 EditorInfo (android.view.inputmethod.EditorInfo)23 KeyEvent (android.view.KeyEvent)17 ExtractedTextRequest (android.view.inputmethod.ExtractedTextRequest)14 InputBinding (android.view.inputmethod.InputBinding)14 InputConnectionWrapper (com.android.internal.view.InputConnectionWrapper)14 Editable (android.text.Editable)12 BaseInputConnection (android.view.inputmethod.BaseInputConnection)12 ViewGroup (android.view.ViewGroup)11 View (android.view.View)8 TextView (android.widget.TextView)8 IBinder (android.os.IBinder)7 RemoteException (android.os.RemoteException)7 InputMethod (android.view.inputmethod.InputMethod)7 LinearLayout (android.widget.LinearLayout)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