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

Commit 8edac58e authored by Raph Levien's avatar Raph Levien
Browse files

Remove indents from TextView

On more careful reflection, the "indents" feature was not ready for
inclusion in the public API. It is still available at a lower level
in StaticLayout.

Also fix a minor typo in the doc for breakStrategy.

Bug: 20641996
Change-Id: I5cd976a536c48615980860396b1564b51b19e14a
parent c20c1eec
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -215,6 +215,8 @@ package android {
  public static final class R.attr {
    ctor public R.attr();
    field public static final int __removeBeforeMRelease_leftIndents = 16844016; // 0x10104f0
    field public static final int __removeBeforeMRelease_rightIndents = 16844017; // 0x10104f1
    field public static final int __reserved0 = 16844020; // 0x10104f4
    field public static final int __reserved1 = 16844019; // 0x10104f3
    field public static final int __reserved2 = 16843999; // 0x10104df
@@ -801,7 +803,6 @@ package android {
    field public static final int layout_x = 16843135; // 0x101017f
    field public static final int layout_y = 16843136; // 0x1010180
    field public static final int left = 16843181; // 0x10101ad
    field public static final int leftIndents = 16844016; // 0x10104f0
    field public static final int letterSpacing = 16843958; // 0x10104b6
    field public static final int lineSpacingExtra = 16843287; // 0x1010217
    field public static final int lineSpacingMultiplier = 16843288; // 0x1010218
@@ -1026,7 +1027,6 @@ package android {
    field public static final int reversible = 16843851; // 0x101044b
    field public static final int revisionCode = 16843989; // 0x10104d5
    field public static final int right = 16843183; // 0x10101af
    field public static final int rightIndents = 16844017; // 0x10104f1
    field public static final int ringtonePreferenceStyle = 16842899; // 0x1010093
    field public static final int ringtoneType = 16843257; // 0x10101f9
    field public static final int rotation = 16843558; // 0x1010326
@@ -41560,7 +41560,6 @@ package android.widget {
    method public int getInputType();
    method public final android.text.method.KeyListener getKeyListener();
    method public final android.text.Layout getLayout();
    method public int[] getLeftIndents();
    method public float getLetterSpacing();
    method public int getLineBounds(int, android.graphics.Rect);
    method public int getLineCount();
@@ -41583,7 +41582,6 @@ package android.widget {
    method public android.text.TextPaint getPaint();
    method public int getPaintFlags();
    method public java.lang.String getPrivateImeOptions();
    method public int[] getRightIndents();
    method public int getSelectionEnd();
    method public int getSelectionStart();
    method public int getShadowColor();
@@ -41663,7 +41661,6 @@ package android.widget {
    method public void setImeActionLabel(java.lang.CharSequence, int);
    method public void setImeOptions(int);
    method public void setIncludeFontPadding(boolean);
    method public void setIndents(int[], int[]);
    method public void setInputExtras(int) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public void setInputType(int);
    method public void setKeyListener(android.text.method.KeyListener);
+2 −5
Original line number Diff line number Diff line
@@ -290,6 +290,8 @@ package android {
  public static final class R.attr {
    ctor public R.attr();
    field public static final int __removeBeforeMRelease_leftIndents = 16844016; // 0x10104f0
    field public static final int __removeBeforeMRelease_rightIndents = 16844017; // 0x10104f1
    field public static final int __reserved0 = 16844020; // 0x10104f4
    field public static final int __reserved1 = 16844019; // 0x10104f3
    field public static final int __reserved2 = 16843999; // 0x10104df
@@ -876,7 +878,6 @@ package android {
    field public static final int layout_x = 16843135; // 0x101017f
    field public static final int layout_y = 16843136; // 0x1010180
    field public static final int left = 16843181; // 0x10101ad
    field public static final int leftIndents = 16844016; // 0x10104f0
    field public static final int letterSpacing = 16843958; // 0x10104b6
    field public static final int lineSpacingExtra = 16843287; // 0x1010217
    field public static final int lineSpacingMultiplier = 16843288; // 0x1010218
@@ -1101,7 +1102,6 @@ package android {
    field public static final int reversible = 16843851; // 0x101044b
    field public static final int revisionCode = 16843989; // 0x10104d5
    field public static final int right = 16843183; // 0x10101af
    field public static final int rightIndents = 16844017; // 0x10104f1
    field public static final int ringtonePreferenceStyle = 16842899; // 0x1010093
    field public static final int ringtoneType = 16843257; // 0x10101f9
    field public static final int rotation = 16843558; // 0x1010326
@@ -44150,7 +44150,6 @@ package android.widget {
    method public int getInputType();
    method public final android.text.method.KeyListener getKeyListener();
    method public final android.text.Layout getLayout();
    method public int[] getLeftIndents();
    method public float getLetterSpacing();
    method public int getLineBounds(int, android.graphics.Rect);
    method public int getLineCount();
@@ -44173,7 +44172,6 @@ package android.widget {
    method public android.text.TextPaint getPaint();
    method public int getPaintFlags();
    method public java.lang.String getPrivateImeOptions();
    method public int[] getRightIndents();
    method public int getSelectionEnd();
    method public int getSelectionStart();
    method public int getShadowColor();
@@ -44253,7 +44251,6 @@ package android.widget {
    method public void setImeActionLabel(java.lang.CharSequence, int);
    method public void setImeOptions(int);
    method public void setIncludeFontPadding(boolean);
    method public void setIndents(int[], int[]);
    method public void setInputExtras(int) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public void setInputType(int);
    method public void setKeyListener(android.text.method.KeyListener);
+0 −65
Original line number Diff line number Diff line
@@ -241,8 +241,6 @@ import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
 * @attr ref android.R.styleable#TextView_fontFeatureSettings
 * @attr ref android.R.styleable#TextView_breakStrategy
 * @attr ref android.R.styleable#TextView_hyphenationFrequency
 * @attr ref android.R.styleable#TextView_leftIndents
 * @attr ref android.R.styleable#TextView_rightIndents
 */
@RemoteView
public class TextView extends View implements ViewTreeObserver.OnPreDrawListener {
@@ -559,8 +557,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

    private int mBreakStrategy;
    private int mHyphenationFrequency;
    private int[] mLeftIndents;
    private int[] mRightIndents;

    private int mMaximum = Integer.MAX_VALUE;
    private int mMaxMode = LINES;
@@ -1165,16 +1161,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            case com.android.internal.R.styleable.TextView_hyphenationFrequency:
                mHyphenationFrequency = a.getInt(attr, Layout.HYPHENATION_FREQUENCY_NONE);
                break;

            case com.android.internal.R.styleable.TextView_leftIndents:
                TypedArray margins = res.obtainTypedArray(a.getResourceId(attr, View.NO_ID));
                mLeftIndents = parseDimensionArray(margins);
                break;

            case com.android.internal.R.styleable.TextView_rightIndents:
                margins = res.obtainTypedArray(a.getResourceId(attr, View.NO_ID));
                mRightIndents = parseDimensionArray(margins);
                break;
            }
        }
        a.recycle();
@@ -3094,51 +3080,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        return mHyphenationFrequency;
    }

    /**
     * Set indents. Arguments are arrays holding an indent amount, one per line, measured in
     * pixels. For lines past the last element in the array, the last element repeats.
     *
     * @param leftIndents array of indent values for left margin, in pixels
     * @param rightIndents array of indent values for right margin, in pixels
     *
     * @see #getLeftIndents()
     * @see #getRightIndents()
     *
     * @attr ref android.R.styleable#TextView_leftIndents
     * @attr ref android.R.styleable#TextView_rightIndents
     */
    public void setIndents(@Nullable int[] leftIndents, @Nullable int[] rightIndents) {
        mLeftIndents = leftIndents;
        mRightIndents = rightIndents;
        if (mLayout != null) {
            nullLayouts();
            requestLayout();
            invalidate();
        }
    }

    /**
     * Get left indents. See {#link setMargins} for more details.
     *
     * @return left indents
     * @see #setIndents(int[], int[])
     * @attr ref android.R.styleable#TextView_leftIndents
     */
    public int[] getLeftIndents() {
        return mLeftIndents;
    }

    /**
     * Get right indents. See {#link setMargins} for more details.
     *
     * @return right indents
     * @see #setIndents(int[], int[])
     * @attr ref android.R.styleable#TextView_rightIndents
     */
    public int[] getRightIndents() {
        return mRightIndents;
    }

    /**
     * Sets font feature settings.  The format is the same as the CSS
     * font-feature-settings attribute:
@@ -6685,9 +6626,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                        .setIncludePad(mIncludePad)
                        .setBreakStrategy(mBreakStrategy)
                        .setHyphenationFrequency(mHyphenationFrequency);
                if (mLeftIndents != null || mRightIndents != null) {
                    builder.setIndents(mLeftIndents, mRightIndents);
                }
                if (shouldEllipsize) {
                    builder.setEllipsize(mEllipsize)
                            .setEllipsizedWidth(ellipsisWidth)
@@ -6776,9 +6714,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                    .setIncludePad(mIncludePad)
                    .setBreakStrategy(mBreakStrategy)
                    .setHyphenationFrequency(mHyphenationFrequency);
            if (mLeftIndents != null || mRightIndents != null) {
                builder.setIndents(mLeftIndents, mRightIndents);
            }
            if (shouldEllipsize) {
                builder.setEllipsize(effectiveEllipsize)
                        .setEllipsizedWidth(ellipsisWidth)
+5 −5
Original line number Diff line number Diff line
@@ -4384,7 +4384,7 @@ i
            <enum name="simple" value="0" />
            <!-- Line breaking uses high-quality strategy, including hyphenation. -->
            <enum name="high_quality" value="1" />
            <!-- Line breaking stratgegy balances line lengths. -->
            <!-- Line breaking strategy balances line lengths. -->
            <enum name="balanced" value="2" />
        </attr>
        <!-- Frequency of automatic hyphenation. -->
@@ -4398,10 +4398,10 @@ i
            screens with limited space for text. -->
            <enum name="full" value="2" />
        </attr>
        <!-- Array of indents, one dimension value per line, left side. -->
        <attr name="leftIndents" format="reference" />
        <!-- Array of indents, one dimension value per line, right side. -->
        <attr name="rightIndents" format="reference" />
        <!-- Placeholder for a deleted attribute. This should be removed before M release. -->
        <attr name="__removeBeforeMRelease_leftIndents" format="reference" />
        <!-- Placeholder for a deleted attribute. This should be removed before M release. -->
        <attr name="__removeBeforeMRelease_rightIndents" format="reference" />
    </declare-styleable>
    <declare-styleable name="TextViewAppearance">
        <!-- Base text color, typeface, size, and style. -->
+3 −2
Original line number Diff line number Diff line
@@ -2683,8 +2683,9 @@

  <public type="attr" name="lockTaskMode" />

  <public type="attr" name="leftIndents" />
  <public type="attr" name="rightIndents" />
  <!-- Placeholder for a removed attribute. Remove this before M release. -->
  <public type="attr" name="__removeBeforeMRelease_leftIndents" />
  <public type="attr" name="__removeBeforeMRelease_rightIndents" />

  <public type="attr" name="showForAllUsers" />