Search in sources :

Example 71 with InputConnection

use of android.view.inputmethod.InputConnection in project android_frameworks_base by ResurrectionRemix.

the class IInputMethodWrapper method executeMessage.

@Override
public void executeMessage(Message msg) {
    InputMethod inputMethod = mInputMethod.get();
    // Need a valid reference to the inputMethod for everything except a dump.
    if (inputMethod == null && msg.what != DO_DUMP) {
        Log.w(TAG, "Input method reference was null, ignoring message: " + msg.what);
        return;
    }
    boolean formalText = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.FORMAL_TEXT_INPUT, 0, UserHandle.USER_CURRENT_OR_SELF) == 1;
    switch(msg.what) {
        case DO_DUMP:
            {
                AbstractInputMethodService target = mTarget.get();
                if (target == null) {
                    return;
                }
                SomeArgs args = (SomeArgs) msg.obj;
                try {
                    target.dump((FileDescriptor) args.arg1, (PrintWriter) args.arg2, (String[]) args.arg3);
                } catch (RuntimeException e) {
                    ((PrintWriter) args.arg2).println("Exception: " + e);
                }
                synchronized (args.arg4) {
                    ((CountDownLatch) args.arg4).countDown();
                }
                args.recycle();
                return;
            }
        case DO_ATTACH_TOKEN:
            {
                inputMethod.attachToken((IBinder) msg.obj);
                return;
            }
        case DO_SET_INPUT_CONTEXT:
            {
                inputMethod.bindInput((InputBinding) msg.obj);
                return;
            }
        case DO_UNSET_INPUT_CONTEXT:
            inputMethod.unbindInput();
            return;
        case DO_START_INPUT:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                int missingMethods = msg.arg1;
                IInputContext inputContext = (IInputContext) args.arg1;
                InputConnection ic = inputContext != null ? new InputConnectionWrapper(mTarget, inputContext, missingMethods) : null;
                EditorInfo info = (EditorInfo) args.arg2;
                info.makeCompatible(mTargetSdkVersion);
                info.formalTextInput(formalText);
                inputMethod.startInput(ic, info);
                args.recycle();
                return;
            }
        case DO_RESTART_INPUT:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                int missingMethods = msg.arg1;
                IInputContext inputContext = (IInputContext) args.arg1;
                InputConnection ic = inputContext != null ? new InputConnectionWrapper(mTarget, inputContext, missingMethods) : null;
                EditorInfo info = (EditorInfo) args.arg2;
                info.makeCompatible(mTargetSdkVersion);
                info.formalTextInput(formalText);
                inputMethod.restartInput(ic, info);
                args.recycle();
                return;
            }
        case DO_CREATE_SESSION:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                inputMethod.createSession(new InputMethodSessionCallbackWrapper(mContext, (InputChannel) args.arg1, (IInputSessionCallback) args.arg2));
                args.recycle();
                return;
            }
        case DO_SET_SESSION_ENABLED:
            inputMethod.setSessionEnabled((InputMethodSession) msg.obj, msg.arg1 != 0);
            return;
        case DO_REVOKE_SESSION:
            inputMethod.revokeSession((InputMethodSession) msg.obj);
            return;
        case DO_SHOW_SOFT_INPUT:
            inputMethod.showSoftInput(msg.arg1, (ResultReceiver) msg.obj);
            return;
        case DO_HIDE_SOFT_INPUT:
            inputMethod.hideSoftInput(msg.arg1, (ResultReceiver) msg.obj);
            return;
        case DO_CHANGE_INPUTMETHOD_SUBTYPE:
            inputMethod.changeInputMethodSubtype((InputMethodSubtype) msg.obj);
            return;
    }
    Log.w(TAG, "Unhandled message code: " + msg.what);
}
Also used : IInputContext(com.android.internal.view.IInputContext) InputConnectionWrapper(com.android.internal.view.InputConnectionWrapper) FileDescriptor(java.io.FileDescriptor) InputConnection(android.view.inputmethod.InputConnection) IBinder(android.os.IBinder) EditorInfo(android.view.inputmethod.EditorInfo) SomeArgs(com.android.internal.os.SomeArgs) IInputMethod(com.android.internal.view.IInputMethod) InputMethod(android.view.inputmethod.InputMethod) InputBinding(android.view.inputmethod.InputBinding) PrintWriter(java.io.PrintWriter)

Example 72 with InputConnection

use of android.view.inputmethod.InputConnection in project android_frameworks_base by ResurrectionRemix.

the class IInputMethodWrapper method bindInput.

@Override
public void bindInput(InputBinding binding) {
    // This IInputContext is guaranteed to implement all the methods.
    final int missingMethodFlags = 0;
    InputConnection ic = new InputConnectionWrapper(mTarget, IInputContext.Stub.asInterface(binding.getConnectionToken()), missingMethodFlags);
    InputBinding nu = new InputBinding(ic, binding);
    mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_INPUT_CONTEXT, nu));
}
Also used : InputConnection(android.view.inputmethod.InputConnection) InputConnectionWrapper(com.android.internal.view.InputConnectionWrapper) InputBinding(android.view.inputmethod.InputBinding)

Example 73 with InputConnection

use of android.view.inputmethod.InputConnection in project android_frameworks_base by ResurrectionRemix.

the class InputMethodService method updateFullscreenMode.

/**
     * Re-evaluate whether the input method should be running in fullscreen
     * mode, and update its UI if this has changed since the last time it
     * was evaluated.  This will call {@link #onEvaluateFullscreenMode()} to
     * determine whether it should currently run in fullscreen mode.  You
     * can use {@link #isFullscreenMode()} to determine if the input method
     * is currently running in fullscreen mode.
     */
public void updateFullscreenMode() {
    boolean fullScreenOverride = Settings.System.getIntForUser(getContentResolver(), Settings.System.DISABLE_FULLSCREEN_KEYBOARD, 0, UserHandle.USER_CURRENT_OR_SELF) != 0;
    boolean isFullscreen;
    if (fullScreenOverride) {
        isFullscreen = false;
    } else {
        isFullscreen = mShowInputRequested && onEvaluateFullscreenMode();
    }
    boolean changed = mLastShowInputRequested != mShowInputRequested;
    if (mIsFullscreen != isFullscreen || !mFullscreenApplied) {
        changed = true;
        mIsFullscreen = isFullscreen;
        InputConnection ic = getCurrentInputConnection();
        if (ic != null)
            ic.reportFullscreenMode(isFullscreen);
        mFullscreenApplied = true;
        initialize();
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mFullscreenArea.getLayoutParams();
        if (isFullscreen) {
            mFullscreenArea.setBackgroundDrawable(mThemeAttrs.getDrawable(com.android.internal.R.styleable.InputMethodService_imeFullscreenBackground));
            lp.height = 0;
            lp.weight = 1;
        } else {
            mFullscreenArea.setBackgroundDrawable(null);
            lp.height = LinearLayout.LayoutParams.WRAP_CONTENT;
            lp.weight = 0;
        }
        ((ViewGroup) mFullscreenArea.getParent()).updateViewLayout(mFullscreenArea, lp);
        if (isFullscreen) {
            if (mExtractView == null) {
                View v = onCreateExtractTextView();
                if (v != null) {
                    setExtractView(v);
                }
            }
            startExtractingText(false);
        }
        updateExtractFrameVisibility();
    }
    if (changed) {
        onConfigureWindow(mWindow.getWindow(), isFullscreen, !mShowInputRequested);
        mLastShowInputRequested = mShowInputRequested;
    }
}
Also used : InputConnection(android.view.inputmethod.InputConnection) ViewGroup(android.view.ViewGroup) View(android.view.View) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 74 with InputConnection

use of android.view.inputmethod.InputConnection in project android_frameworks_base by ResurrectionRemix.

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 75 with InputConnection

use of android.view.inputmethod.InputConnection in project android_frameworks_base by ResurrectionRemix.

the class InputMethodService method sendDownUpKeyEvents.

/**
     * Send the given key event code (as defined by {@link KeyEvent}) to the
     * current input connection is a key down + key up event pair.  The sent
     * events have {@link KeyEvent#FLAG_SOFT_KEYBOARD KeyEvent.FLAG_SOFT_KEYBOARD}
     * set, so that the recipient can identify them as coming from a software
     * input method, and
     * {@link KeyEvent#FLAG_KEEP_TOUCH_MODE KeyEvent.FLAG_KEEP_TOUCH_MODE}, so
     * that they don't impact the current touch mode of the UI.
     *
     * <p>Note that it's discouraged to send such key events in normal operation;
     * this is mainly for use with {@link android.text.InputType#TYPE_NULL} type
     * text fields, or for non-rich input methods. A reasonably capable software
     * input method should use the
     * {@link android.view.inputmethod.InputConnection#commitText} family of methods
     * to send text to an application, rather than sending key events.</p>
     *
     * @param keyEventCode The raw key code to send, as defined by
     * {@link KeyEvent}.
     */
public void sendDownUpKeyEvents(int keyEventCode) {
    InputConnection ic = getCurrentInputConnection();
    if (ic == null)
        return;
    long eventTime = SystemClock.uptimeMillis();
    ic.sendKeyEvent(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, keyEventCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
    ic.sendKeyEvent(new KeyEvent(eventTime, SystemClock.uptimeMillis(), KeyEvent.ACTION_UP, keyEventCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
}
Also used : InputConnection(android.view.inputmethod.InputConnection) KeyEvent(android.view.KeyEvent)

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