Search in sources :

Example 56 with InputConnection

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

the class TypefaceActionEditText method onCreateInputConnection.

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

Example 57 with InputConnection

use of android.view.inputmethod.InputConnection in project XobotOS by xamarin.

the class TextView method onCreateInputConnection.

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    if (onCheckIsTextEditor() && isEnabled()) {
        if (mInputMethodState == null) {
            mInputMethodState = new InputMethodState();
        }
        outAttrs.inputType = mInputType;
        if (mInputContentType != null) {
            outAttrs.imeOptions = mInputContentType.imeOptions;
            outAttrs.privateImeOptions = mInputContentType.privateImeOptions;
            outAttrs.actionLabel = mInputContentType.imeActionLabel;
            outAttrs.actionId = mInputContentType.imeActionId;
            outAttrs.extras = mInputContentType.extras;
        } else {
            outAttrs.imeOptions = EditorInfo.IME_NULL;
        }
        if (focusSearch(FOCUS_DOWN) != null) {
            outAttrs.imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_NEXT;
        }
        if (focusSearch(FOCUS_UP) != null) {
            outAttrs.imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS;
        }
        if ((outAttrs.imeOptions & EditorInfo.IME_MASK_ACTION) == EditorInfo.IME_ACTION_UNSPECIFIED) {
            if ((outAttrs.imeOptions & EditorInfo.IME_FLAG_NAVIGATE_NEXT) != 0) {
                // An action has not been set, but the enter key will move to
                // the next focus, so set the action to that.
                outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
            } else {
                // An action has not been set, and there is no focus to move
                // to, so let's just supply a "done" action.
                outAttrs.imeOptions |= EditorInfo.IME_ACTION_DONE;
            }
            if (!shouldAdvanceFocusOnEnter()) {
                outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_ENTER_ACTION;
            }
        }
        if (isMultilineInputType(outAttrs.inputType)) {
            // Multi-line text editors should always show an enter key.
            outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_ENTER_ACTION;
        }
        outAttrs.hintText = mHint;
        if (mText instanceof Editable) {
            InputConnection ic = new EditableInputConnection(this);
            outAttrs.initialSelStart = getSelectionStart();
            outAttrs.initialSelEnd = getSelectionEnd();
            outAttrs.initialCapsMode = ic.getCursorCapsMode(mInputType);
            return ic;
        }
    }
    return null;
}
Also used : BaseInputConnection(android.view.inputmethod.BaseInputConnection) EditableInputConnection(com.android.internal.widget.EditableInputConnection) InputConnection(android.view.inputmethod.InputConnection) EditableInputConnection(com.android.internal.widget.EditableInputConnection) Editable(android.text.Editable)

Example 58 with InputConnection

use of android.view.inputmethod.InputConnection in project XobotOS by xamarin.

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.
     *
     * @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(SystemClock.uptimeMillis(), eventTime, 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)

Example 59 with InputConnection

use of android.view.inputmethod.InputConnection in project XobotOS by xamarin.

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 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) LinearLayout(android.widget.LinearLayout)

Example 60 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 conn;
}
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