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

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

Merge "Added a new flag in TextView to disable Suggestions."

parents 6895c499 f3a135bf
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -866,6 +866,7 @@ package android {
    field public static final int subtitleTextStyle = 16843513; // 0x10102f9
    field public static final int suggestActionMsg = 16843228; // 0x10101dc
    field public static final int suggestActionMsgColumn = 16843229; // 0x10101dd
    field public static final int suggestionsEnabled = 16843630; // 0x101036e
    field public static final int summary = 16843241; // 0x10101e9
    field public static final int summaryColumn = 16843426; // 0x10102a2
    field public static final int summaryOff = 16843248; // 0x10101f0
@@ -25227,6 +25228,7 @@ package android.widget {
    method public android.text.style.URLSpan[] getUrls();
    method public boolean hasSelection();
    method public boolean isInputMethodTarget();
    method public boolean isSuggestionsEnabled();
    method public boolean isTextSelectable();
    method public int length();
    method public boolean moveCursorToVisibleOffset();
@@ -25298,6 +25300,7 @@ package android.widget {
    method public void setSingleLine();
    method public void setSingleLine(boolean);
    method public final void setSpannableFactory(android.text.Spannable.Factory);
    method public void setSuggestionsEnabled(boolean);
    method public final void setText(java.lang.CharSequence);
    method public void setText(java.lang.CharSequence, android.widget.TextView.BufferType);
    method public final void setText(char[], int, int);
+37 −5
Original line number Diff line number Diff line
@@ -16,11 +16,6 @@

package android.widget;

import com.android.internal.util.FastMath;
import com.android.internal.widget.EditableInputConnection;

import org.xmlpull.v1.XmlPullParserException;

import android.R;
import android.content.ClipData;
import android.content.ClipData.Item;
@@ -129,6 +124,11 @@ import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.widget.RemoteViews.RemoteView;

import com.android.internal.util.FastMath;
import com.android.internal.widget.EditableInputConnection;

import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.lang.ref.WeakReference;
import java.text.BreakIterator;
@@ -320,6 +320,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    private int mTextEditSuggestionItemLayout;
    private SuggestionsPopupWindow mSuggestionsPopupWindow;
    private SuggestionRangeSpan mSuggestionRangeSpan;
    private boolean mSuggestionsEnabled = true;

    private int mCursorDrawableRes;
    private final Drawable[] mCursorDrawable = new Drawable[2];
@@ -806,6 +807,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            case com.android.internal.R.styleable.TextView_textIsSelectable:
                mTextIsSelectable = a.getBoolean(attr, false);
                break;

            case com.android.internal.R.styleable.TextView_suggestionsEnabled:
                mSuggestionsEnabled = a.getBoolean(attr, true);
                break;
            }
        }
        a.recycle();
@@ -8601,6 +8606,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }

    void showSuggestions() {
        if (!mSuggestionsEnabled || !isTextEditable()) return;

        if (mSuggestionsPopupWindow == null) {
            mSuggestionsPopupWindow = new SuggestionsPopupWindow();
        }
@@ -8614,6 +8621,31 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        }
    }

    /**
     * Some parts of the text can have alternate suggestion text attached. This is typically done by
     * the IME by adding {@link SuggestionSpan}s to the text.
     *
     * When suggestions are enabled (default), this list of suggestions will be displayed when the
     * user double taps on these parts of the text. No suggestions are displayed when this value is
     * false. Use {@link #setSuggestionsEnabled(boolean)} to change this value.
     *
     * @return true if the suggestions popup window is enabled.
     *
     * @attr ref android.R.styleable#TextView_suggestionsEnabled
     */
    public boolean isSuggestionsEnabled() {
        return mSuggestionsEnabled;
    }

    /**
     * Enables or disables the suggestion popup. See {@link #isSuggestionsEnabled()}.
     *
     * @param enabled Whether or not suggestions are enabled.
     */
    public void setSuggestionsEnabled(boolean enabled) {
        mSuggestionsEnabled = enabled;
    }

    /**
     * If provided, this ActionMode.Callback will be used to create the ActionMode when text
     * selection is initiated in this View.
+6 −0
Original line number Diff line number Diff line
@@ -823,6 +823,10 @@
     Default value is false. EditText content is always selectable. -->
    <attr name="textIsSelectable" format="boolean" />

    <!-- When true, IME suggestions will be displayed when the user double taps on editable text.
     The default value is true. -->
    <attr name="suggestionsEnabled" format="boolean" />

    <!-- Where to ellipsize text. -->
    <attr name="ellipsize">
        <enum name="none" value="0" />
@@ -2877,6 +2881,8 @@

        <!-- Indicates that the content of a non-editable text can be selected. -->
        <attr name="textIsSelectable" />
        <!-- Suggestions will be displayed when the user double taps on editable text. -->
        <attr name="suggestionsEnabled" />
    </declare-styleable>
    <!-- An <code>input-extras</code> is a container for extra data to supply to
         an input method.  Contains
+1 −0
Original line number Diff line number Diff line
@@ -1670,5 +1670,6 @@
  <public type="attr" name="horizontalDirection" />

  <public type="attr" name="fullBackupAgent" />
  <public type="attr" name="suggestionsEnabled" />

</resources>