Search in sources :

Example 71 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project SmartAndroidSource by jaychou2012.

the class SearchView method setImeVisibility.

private void setImeVisibility(final boolean visible) {
    if (visible) {
        post(mShowImeRunnable);
    } else {
        removeCallbacks(mShowImeRunnable);
        InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.hideSoftInputFromWindow(getWindowToken(), 0);
        }
    }
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 72 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project Jota-Text-Editor-old by jiro-aqua.

the class TextView method onCreateInputConnection.

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    if (onCheckIsTextEditor()) {
        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 ((outAttrs.imeOptions & EditorInfo.IME_MASK_ACTION) == EditorInfo.IME_ACTION_UNSPECIFIED) {
            if (focusSearch(FOCUS_DOWN) != null) {
                // 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 ((outAttrs.inputType & (InputType.TYPE_MASK_CLASS | InputType.TYPE_TEXT_FLAG_MULTI_LINE)) == (InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE)) {
            // 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);
            // patch by matthias.gruenewald@googlemail.com
            if (!mDontUseSoftkeyWithHardkey || getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
                InputMethodManager imm = InputMethodManager.peekInstance();
                if (imm != null) {
                    imm.showSoftInput(this, 0);
                }
            }
            return ic;
        }
    }
    return null;
}
Also used : BaseInputConnection(android.view.inputmethod.BaseInputConnection) InputConnection(android.view.inputmethod.InputConnection) Editable(android.text.Editable) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 73 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project Jota-Text-Editor-old by jiro-aqua.

the class TextView method onKeyUp.

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    // Jota Text Editor
    //        if (!isEnabled()) {
    //            return super.onKeyUp(keyCode, event);
    //        }
    hideControllers();
    stopTextSelectionMode();
    switch(keyCode) {
        case KeyEvent.KEYCODE_DPAD_CENTER:
            /*
                 * If there is a click listener, just call through to
                 * super, which will invoke it.
                 *
                 * If there isn't a click listener, try to show the soft
                 * input method.  (It will also
                 * call performClick(), but that won't do anything in
                 * this case.)
                 */
            if (mOnClickListener == null) {
                if (mMovement != null && mText instanceof Editable && mLayout != null && onCheckIsTextEditor()) {
                    // patch by matthias.gruenewald@googlemail.com
                    if (!mDontUseSoftkeyWithHardkey || getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
                        InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                        imm.showSoftInput(this, 0);
                    }
                }
            }
            // Jota Text Editor
            return false;
        case KeyEvent.KEYCODE_ENTER:
            //                mEnterKeyIsDown = false;// Jota Text Editor
            if (mInputContentType != null && mInputContentType.onEditorActionListener != null && mInputContentType.enterDown) {
                mInputContentType.enterDown = false;
                if (mInputContentType.onEditorActionListener.onEditorAction(this, EditorInfo.IME_NULL, event)) {
                    return true;
                }
            }
            if ((event.getFlags() & KeyEvent.FLAG_EDITOR_ACTION) != 0 || shouldAdvanceFocusOnEnter()) {
                /*
                     * If there is a click listener, just call through to
                     * super, which will invoke it.
                     *
                     * If there isn't a click listener, try to advance focus,
                     * but still call through to super, which will reset the
                     * pressed state and longpress state.  (It will also
                     * call performClick(), but that won't do anything in
                     * this case.)
                     */
                if (mOnClickListener == null) {
                    View v = focusSearch(FOCUS_DOWN);
                    if (v != null) {
                        if (!v.requestFocus(FOCUS_DOWN)) {
                            throw new IllegalStateException("focus search returned a view " + "that wasn't able to take focus!");
                        }
                        //                            super.onKeyUp(keyCode, event);
                        return true;
                    } else if ((event.getFlags() & KeyEvent.FLAG_EDITOR_ACTION) != 0) {
                        // No target for next focus, but make sure the IME
                        // if this came from it.
                        InputMethodManager imm = InputMethodManager.peekInstance();
                        if (imm != null) {
                            imm.hideSoftInputFromWindow(getWindowToken(), 0);
                        }
                    }
                }
                //                    return super.onKeyUp(keyCode, event);
                return false;
            }
            break;
    }
    if (mInput != null)
        if (mInput.onKeyUp(this, (Editable) mText, keyCode, event))
            return true;
    if (mMovement != null && mLayout != null)
        if (mMovement.onKeyUp(this, (Spannable) mText, keyCode, event))
            return true;
    return super.onKeyUp(keyCode, event);
}
Also used : Editable(android.text.Editable) InputMethodManager(android.view.inputmethod.InputMethodManager) RemoteView(android.widget.RemoteViews.RemoteView) View(android.view.View) Spannable(android.text.Spannable)

Example 74 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project Jota-Text-Editor-old by jiro-aqua.

the class TextView method reportExtractedText.

boolean reportExtractedText() {
    final InputMethodState ims = mInputMethodState;
    if (ims != null) {
        final boolean contentChanged = ims.mContentChanged;
        if (contentChanged || ims.mSelectionModeChanged) {
            ims.mContentChanged = false;
            ims.mSelectionModeChanged = false;
            final ExtractedTextRequest req = mInputMethodState.mExtracting;
            if (req != null) {
                InputMethodManager imm = InputMethodManager.peekInstance();
                if (imm != null) {
                    if (DEBUG_EXTRACT)
                        Log.v(TAG, "Retrieving extracted start=" + ims.mChangedStart + " end=" + ims.mChangedEnd + " delta=" + ims.mChangedDelta);
                    if (ims.mChangedStart < 0 && !contentChanged) {
                        ims.mChangedStart = EXTRACT_NOTHING;
                    }
                    if (extractTextInternal(req, ims.mChangedStart, ims.mChangedEnd, ims.mChangedDelta, ims.mTmpExtracted)) {
                        if (DEBUG_EXTRACT)
                            Log.v(TAG, "Reporting extracted start=" + ims.mTmpExtracted.partialStartOffset + " end=" + ims.mTmpExtracted.partialEndOffset + ": " + ims.mTmpExtracted.text);
                        imm.updateExtractedText(this, req.token, mInputMethodState.mTmpExtracted);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : ExtractedTextRequest(android.view.inputmethod.ExtractedTextRequest) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 75 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project Jota-Text-Editor-old by jiro-aqua.

the class TextView method setInputType.

/**
     * Set the type of the content with a constant as defined for
     * {@link EditorInfo#inputType}.  This will take care of changing
     * the key listener, by calling {@link #setKeyListener(KeyListener)}, to
     * match the given content type.  If the given content type is
     * {@link EditorInfo#TYPE_NULL} then a soft keyboard will
     * not be displayed for this text view.
     *
     * @see #getInputType()
     * @see #setRawInputType(int)
     * @see android.text.InputType
     * @attr ref android.R.styleable#TextView_inputType
     */
public void setInputType(int type) {
    final boolean wasPassword = isPasswordInputType(mInputType);
    final boolean wasVisiblePassword = isVisiblePasswordInputType(mInputType);
    setInputType(type, false);
    final boolean isPassword = isPasswordInputType(type);
    final boolean isVisiblePassword = isVisiblePasswordInputType(type);
    boolean forceUpdate = false;
    if (isPassword) {
        setTransformationMethod(PasswordTransformationMethod.getInstance());
        setTypefaceByIndex(MONOSPACE, 0);
    } else if (isVisiblePassword) {
        if (mTransformation == PasswordTransformationMethod.getInstance()) {
            forceUpdate = true;
        }
        setTypefaceByIndex(MONOSPACE, 0);
    } else if (wasPassword || wasVisiblePassword) {
        // not in password mode, clean up typeface and transformation
        setTypefaceByIndex(-1, -1);
        if (mTransformation == PasswordTransformationMethod.getInstance()) {
            forceUpdate = true;
        }
    }
    boolean multiLine = (type & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE)) == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE);
    // were previously in password mode.
    if (mSingleLine == multiLine || forceUpdate) {
        // Change single line mode, but only change the transformation if
        // we are not in password mode.
        applySingleLine(!multiLine, !isPassword);
    }
    InputMethodManager imm = InputMethodManager.peekInstance();
    if (imm != null)
        imm.restartInput(this);
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager)

Aggregations

InputMethodManager (android.view.inputmethod.InputMethodManager)631 View (android.view.View)120 TextView (android.widget.TextView)67 Paint (android.graphics.Paint)43 Spannable (android.text.Spannable)34 Editable (android.text.Editable)33 EditText (android.widget.EditText)33 ImageView (android.widget.ImageView)31 Intent (android.content.Intent)29 RemoteException (android.os.RemoteException)23 KeyEvent (android.view.KeyEvent)22 TextPaint (android.text.TextPaint)21 Point (android.graphics.Point)18 InputMethodInfo (android.view.inputmethod.InputMethodInfo)18 AdapterView (android.widget.AdapterView)18 Button (android.widget.Button)16 RemoteView (android.widget.RemoteViews.RemoteView)16 Resources (android.content.res.Resources)15 ListView (android.widget.ListView)15 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)14