Search in sources :

Example 11 with EditorInfo

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

the class InputMethodManagerService method handleMessage.

@Override
public boolean handleMessage(Message msg) {
    SomeArgs args;
    switch(msg.what) {
        case MSG_SHOW_IM_SUBTYPE_PICKER:
            final boolean showAuxSubtypes;
            switch(msg.arg1) {
                case InputMethodManager.SHOW_IM_PICKER_MODE_AUTO:
                    // This is undocumented so far, but IMM#showInputMethodPicker() has been
                    // implemented so that auxiliary subtypes will be excluded when the soft
                    // keyboard is invisible.
                    showAuxSubtypes = mInputShown;
                    break;
                case InputMethodManager.SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES:
                    showAuxSubtypes = true;
                    break;
                case InputMethodManager.SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_SUBTYPES:
                    showAuxSubtypes = false;
                    break;
                default:
                    Slog.e(TAG, "Unknown subtype picker mode = " + msg.arg1);
                    return false;
            }
            showInputMethodMenu(showAuxSubtypes);
            return true;
        case MSG_SHOW_IM_SUBTYPE_ENABLER:
            showInputMethodAndSubtypeEnabler((String) msg.obj);
            return true;
        case MSG_SHOW_IM_CONFIG:
            showConfigureInputMethods();
            return true;
        case MSG_UNBIND_INPUT:
            try {
                ((IInputMethod) msg.obj).unbindInput();
            } catch (RemoteException e) {
            // There is nothing interesting about the method dying.
            }
            return true;
        case MSG_BIND_INPUT:
            args = (SomeArgs) msg.obj;
            try {
                ((IInputMethod) args.arg1).bindInput((InputBinding) args.arg2);
            } catch (RemoteException e) {
            }
            args.recycle();
            return true;
        case MSG_SHOW_SOFT_INPUT:
            args = (SomeArgs) msg.obj;
            try {
                if (DEBUG)
                    Slog.v(TAG, "Calling " + args.arg1 + ".showSoftInput(" + msg.arg1 + ", " + args.arg2 + ")");
                ((IInputMethod) args.arg1).showSoftInput(msg.arg1, (ResultReceiver) args.arg2);
            } catch (RemoteException e) {
            }
            args.recycle();
            return true;
        case MSG_HIDE_SOFT_INPUT:
            args = (SomeArgs) msg.obj;
            try {
                if (DEBUG)
                    Slog.v(TAG, "Calling " + args.arg1 + ".hideSoftInput(0, " + args.arg2 + ")");
                ((IInputMethod) args.arg1).hideSoftInput(0, (ResultReceiver) args.arg2);
            } catch (RemoteException e) {
            }
            args.recycle();
            return true;
        case MSG_HIDE_CURRENT_INPUT_METHOD:
            synchronized (mMethodMap) {
                hideCurrentInputLocked(0, null);
            }
            return true;
        case MSG_ATTACH_TOKEN:
            args = (SomeArgs) msg.obj;
            try {
                if (DEBUG)
                    Slog.v(TAG, "Sending attach of token: " + args.arg2);
                ((IInputMethod) args.arg1).attachToken((IBinder) args.arg2);
            } catch (RemoteException e) {
            }
            args.recycle();
            return true;
        case MSG_CREATE_SESSION:
            {
                args = (SomeArgs) msg.obj;
                IInputMethod method = (IInputMethod) args.arg1;
                InputChannel channel = (InputChannel) args.arg2;
                try {
                    method.createSession(channel, (IInputSessionCallback) args.arg3);
                } catch (RemoteException e) {
                } finally {
                    // because the remote proxy will get its own copy when unparceled.
                    if (channel != null && Binder.isProxy(method)) {
                        channel.dispose();
                    }
                }
                args.recycle();
                return true;
            }
        case MSG_START_INPUT:
            {
                int missingMethods = msg.arg1;
                args = (SomeArgs) msg.obj;
                try {
                    SessionState session = (SessionState) args.arg1;
                    setEnabledSessionInMainThread(session);
                    session.method.startInput((IInputContext) args.arg2, missingMethods, (EditorInfo) args.arg3);
                } catch (RemoteException e) {
                }
                args.recycle();
                return true;
            }
        case MSG_RESTART_INPUT:
            {
                int missingMethods = msg.arg1;
                args = (SomeArgs) msg.obj;
                try {
                    SessionState session = (SessionState) args.arg1;
                    setEnabledSessionInMainThread(session);
                    session.method.restartInput((IInputContext) args.arg2, missingMethods, (EditorInfo) args.arg3);
                } catch (RemoteException e) {
                }
                args.recycle();
                return true;
            }
        case MSG_UNBIND_CLIENT:
            try {
                ((IInputMethodClient) msg.obj).onUnbindMethod(msg.arg1, msg.arg2);
            } catch (RemoteException e) {
            // There is nothing interesting about the last client dying.
            }
            return true;
        case MSG_BIND_CLIENT:
            {
                args = (SomeArgs) msg.obj;
                IInputMethodClient client = (IInputMethodClient) args.arg1;
                InputBindResult res = (InputBindResult) args.arg2;
                try {
                    client.onBindMethod(res);
                } catch (RemoteException e) {
                    Slog.w(TAG, "Client died receiving input method " + args.arg2);
                } finally {
                    // because the remote proxy will get its own copy when unparceled.
                    if (res.channel != null && Binder.isProxy(client)) {
                        res.channel.dispose();
                    }
                }
                args.recycle();
                return true;
            }
        case MSG_SET_ACTIVE:
            try {
                ((ClientState) msg.obj).client.setActive(msg.arg1 != 0);
            } catch (RemoteException e) {
                Slog.w(TAG, "Got RemoteException sending setActive(false) notification to pid " + ((ClientState) msg.obj).pid + " uid " + ((ClientState) msg.obj).uid);
            }
            return true;
        case MSG_SET_INTERACTIVE:
            handleSetInteractive(msg.arg1 != 0);
            return true;
        case MSG_SWITCH_IME:
            handleSwitchInputMethod(msg.arg1 != 0);
            return true;
        case MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER:
            {
                final int sequenceNumber = msg.arg1;
                final ClientState clientState = (ClientState) msg.obj;
                try {
                    clientState.client.setUserActionNotificationSequenceNumber(sequenceNumber);
                } catch (RemoteException e) {
                    Slog.w(TAG, "Got RemoteException sending " + "setUserActionNotificationSequenceNumber(" + sequenceNumber + ") notification to pid " + clientState.pid + " uid " + clientState.uid);
                }
                return true;
            }
        // --------------------------------------------------------------
        case MSG_HARD_KEYBOARD_SWITCH_CHANGED:
            mHardKeyboardListener.handleHardKeyboardStatusChange(msg.arg1 == 1);
            return true;
        case MSG_SYSTEM_UNLOCK_USER:
            final int userId = msg.arg1;
            onUnlockUser(userId);
            return true;
    }
    return false;
}
Also used : IInputSessionCallback(com.android.internal.view.IInputSessionCallback) InputBindResult(com.android.internal.view.InputBindResult) IInputContext(com.android.internal.view.IInputContext) IInputMethod(com.android.internal.view.IInputMethod) EditorInfo(android.view.inputmethod.EditorInfo) SomeArgs(com.android.internal.os.SomeArgs) IInputMethodClient(com.android.internal.view.IInputMethodClient) InputChannel(android.view.InputChannel) RemoteException(android.os.RemoteException)

Example 12 with EditorInfo

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

the class InputMethodService method startExtractingText.

void startExtractingText(boolean inputChanged) {
    final ExtractEditText eet = mExtractEditText;
    if (eet != null && getCurrentInputStarted() && isFullscreenMode()) {
        mExtractedToken++;
        ExtractedTextRequest req = new ExtractedTextRequest();
        req.token = mExtractedToken;
        req.flags = InputConnection.GET_TEXT_WITH_STYLES;
        req.hintMaxLines = 10;
        req.hintMaxChars = 10000;
        InputConnection ic = getCurrentInputConnection();
        mExtractedText = ic == null ? null : ic.getExtractedText(req, InputConnection.GET_EXTRACTED_TEXT_MONITOR);
        if (mExtractedText == null || ic == null) {
            Log.e(TAG, "Unexpected null in startExtractingText : mExtractedText = " + mExtractedText + ", input connection = " + ic);
        }
        final EditorInfo ei = getCurrentInputEditorInfo();
        try {
            eet.startInternalChanges();
            onUpdateExtractingVisibility(ei);
            onUpdateExtractingViews(ei);
            int inputType = ei.inputType;
            if ((inputType & EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) {
                if ((inputType & EditorInfo.TYPE_TEXT_FLAG_IME_MULTI_LINE) != 0) {
                    inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
                }
            }
            eet.setInputType(inputType);
            eet.setHint(ei.hintText);
            if (mExtractedText != null) {
                eet.setEnabled(true);
                eet.setExtractedText(mExtractedText);
            } else {
                eet.setEnabled(false);
                eet.setText("");
            }
        } finally {
            eet.finishInternalChanges();
        }
        if (inputChanged) {
            onExtractingInputChanged(ei);
        }
    }
}
Also used : InputConnection(android.view.inputmethod.InputConnection) EditorInfo(android.view.inputmethod.EditorInfo) ExtractedTextRequest(android.view.inputmethod.ExtractedTextRequest)

Example 13 with EditorInfo

use of android.view.inputmethod.EditorInfo in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class TestsDvorakEmail method createKeyboardLayoutSet.

@Override
protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, final EditorInfo editorInfo, final boolean voiceInputKeyEnabled, final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
    final EditorInfo emailField = new EditorInfo();
    emailField.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
    return super.createKeyboardLayoutSet(subtype, emailField, voiceInputKeyEnabled, languageSwitchKeyEnabled, splitLayoutEnabled);
}
Also used : EditorInfo(android.view.inputmethod.EditorInfo)

Example 14 with EditorInfo

use of android.view.inputmethod.EditorInfo in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class ActionTestsBase method doTestActionKey.

protected void doTestActionKey(final String tag, final InputMethodSubtype subtype, final int actionId, final ExpectedActionKey expectedKey) {
    final EditorInfo editorInfo = new EditorInfo();
    editorInfo.imeOptions = actionId;
    doTestActionKey(tag, subtype, editorInfo, expectedKey);
}
Also used : EditorInfo(android.view.inputmethod.EditorInfo)

Example 15 with EditorInfo

use of android.view.inputmethod.EditorInfo in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class InputLogic method handleNonFunctionalEvent.

/**
     * Handle an event that is not a functional event.
     *
     * These events are generally events that cause input, but in some cases they may do other
     * things like trigger an editor action.
     *
     * @param event The event to handle.
     * @param inputTransaction The transaction in progress.
     */
private void handleNonFunctionalEvent(final Event event, final InputTransaction inputTransaction, final LatinIME.UIHandler handler) {
    inputTransaction.setDidAffectContents();
    switch(event.mCodePoint) {
        case Constants.CODE_ENTER:
            final EditorInfo editorInfo = getCurrentInputEditorInfo();
            final int imeOptionsActionId = InputTypeUtils.getImeOptionsActionIdFromEditorInfo(editorInfo);
            if (InputTypeUtils.IME_ACTION_CUSTOM_LABEL == imeOptionsActionId) {
                // Either we have an actionLabel and we should performEditorAction with
                // actionId regardless of its value.
                performEditorAction(editorInfo.actionId);
            } else if (EditorInfo.IME_ACTION_NONE != imeOptionsActionId) {
                // We didn't have an actionLabel, but we had another action to execute.
                // EditorInfo.IME_ACTION_NONE explicitly means no action. In contrast,
                // EditorInfo.IME_ACTION_UNSPECIFIED is the default value for an action, so it
                // means there should be an action and the app didn't bother to set a specific
                // code for it - presumably it only handles one. It does not have to be treated
                // in any specific way: anything that is not IME_ACTION_NONE should be sent to
                // performEditorAction.
                performEditorAction(imeOptionsActionId);
            } else {
                // No action label, and the action from imeOptions is NONE: this is a regular
                // enter key that should input a carriage return.
                handleNonSpecialCharacterEvent(event, inputTransaction, handler);
            }
            break;
        default:
            handleNonSpecialCharacterEvent(event, inputTransaction, handler);
            break;
    }
}
Also used : EditorInfo(android.view.inputmethod.EditorInfo)

Aggregations

EditorInfo (android.view.inputmethod.EditorInfo)43 InputConnection (android.view.inputmethod.InputConnection)20 IInputContext (com.android.internal.view.IInputContext)12 IInputMethod (com.android.internal.view.IInputMethod)12 SomeArgs (com.android.internal.os.SomeArgs)11 ExtractedTextRequest (android.view.inputmethod.ExtractedTextRequest)8 IBinder (android.os.IBinder)7 InputBinding (android.view.inputmethod.InputBinding)7 InputMethod (android.view.inputmethod.InputMethod)7 InputConnectionWrapper (com.android.internal.view.InputConnectionWrapper)7 FileDescriptor (java.io.FileDescriptor)7 PrintWriter (java.io.PrintWriter)7 RemoteException (android.os.RemoteException)5 InputChannel (android.view.InputChannel)5 IInputMethodClient (com.android.internal.view.IInputMethodClient)5 IInputSessionCallback (com.android.internal.view.IInputSessionCallback)5 InputBindResult (com.android.internal.view.InputBindResult)5 SettingsValues (com.android.inputmethod.latin.settings.SettingsValues)3 ViewGroup (android.view.ViewGroup)2 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)2