Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19f4b66d authored by Gilles Debunne's avatar Gilles Debunne Committed by Android (Google) Code Review
Browse files

Merge "Bug 5228934: added a flag to disable the display of the soft input on focus"

parents d44d276f 550efbfb
Loading
Loading
Loading
Loading
+34 −3
Original line number Diff line number Diff line
@@ -357,6 +357,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

    private SpellChecker mSpellChecker;

    private boolean mShowSoftInputOnFocus = true;

    // The alignment to pass to Layout, or null if not resolved.
    private Layout.Alignment mLayoutAlignment;

@@ -605,6 +607,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                mLinksClickable = a.getBoolean(attr, true);
                break;

//            TODO uncomment when this attribute is made public in the next release
//                 also add TextView_showSoftInputOnFocus to the list of attributes above
//            case com.android.internal.R.styleable.TextView_showSoftInputOnFocus:
//                setShowSoftInputOnFocus(a.getBoolean(attr, true));
//                break;

            case com.android.internal.R.styleable.TextView_drawableLeft:
                drawableLeft = a.getDrawable(attr);
                break;
@@ -2367,6 +2375,29 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        return mLinksClickable;
    }

    /**
     * Sets whether the soft input method will be made visible when this
     * TextView gets focused. The default is true.
     *
     * @attr ref android.R.styleable#TextView_showSoftInputOnFocus
     * @hide
     */
    @android.view.RemotableViewMethod
    public final void setShowSoftInputOnFocus(boolean show) {
        mShowSoftInputOnFocus = show;
    }

    /**
     * Returns whether the soft input method will be made visible when this
     * TextView gets focused. The default is true.
     *
     * @attr ref android.R.styleable#TextView_showSoftInputOnFocus
     * @hide
     */
    public final boolean getShowSoftInputOnFocus() {
        return mShowSoftInputOnFocus;
    }

    /**
     * Returns the list of URLSpans attached to the text
     * (by {@link Linkify} or otherwise) if any.  You can call
@@ -5465,7 +5496,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                                && mLayout != null && onCheckIsTextEditor()) {
                            InputMethodManager imm = InputMethodManager.peekInstance();
                            viewClicked(imm);
                            if (imm != null) {
                            if (imm != null && mShowSoftInputOnFocus) {
                                imm.showSoftInput(this, 0);
                            }
                        }
@@ -8303,7 +8334,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                // Show the IME, except when selecting in read-only text.
                final InputMethodManager imm = InputMethodManager.peekInstance();
                viewClicked(imm);
                if (!mTextIsSelectable) {
                if (!mTextIsSelectable && mShowSoftInputOnFocus) {
                    handled |= imm != null && imm.showSoftInput(this, 0);
                }

@@ -10116,7 +10147,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        final boolean selectionStarted = mSelectionActionMode != null ||
                extractedTextModeWillBeStartedFullScreen;

        if (selectionStarted && !mTextIsSelectable && imm != null) {
        if (selectionStarted && !mTextIsSelectable && imm != null && mShowSoftInputOnFocus) {
            // Show the IME to be able to replace text, except when selecting non editable text.
            imm.showSoftInput(this, 0, null);
        }