AutoSize TextView (part 11) - fix final APIs
* public attr "autoSizeText" becomes "autoSizeTextType"
(inlined with all other methods and naming)
* documentation for autoSizetextType "uniform" re-worked:
"The TextView scales text size both horizontally and
vertically to fit within the container"
* converted comments into Javadoc for
TextView#AUTO_SIZE_TEXT_TYPE_NONE and
TextView#AUTO_SIZE_TEXT_TYPE_UNIFORM
* better documented attr "autoSizePresetSizes" to specify
it is a resource array of dimensions
* various small fixes in comments
Bug: 35755149
Bug: 35763485
Bug: 35764658
Bug: 32221168
Test: run cts-dev -m CtsWidgetTestCases -t \
android.widget.cts.TextViewTest
Change-Id: I36afd399e005521b6e85922aa9e1e4418bb960e1
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="600dp"
|
||||
android:text="@string/long_text"
|
||||
android:autoSizeText="uniform"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:autoSizeMinTextSize="10px"
|
||||
android:textSize="20px"
|
||||
android:autoSizeStepGranularity="1px"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="600dp"
|
||||
android:text="@string/long_text"
|
||||
android:autoSizeText="uniform"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:autoSizeMinTextSize="10px"
|
||||
android:textSize="110px"
|
||||
android:autoSizeStepGranularity="1px"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="600dp"
|
||||
android:text="@string/long_text"
|
||||
android:autoSizeText="uniform"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:autoSizeMinTextSize="10px"
|
||||
android:textSize="1010px"
|
||||
android:autoSizeStepGranularity="1px"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="600dp"
|
||||
android:text="@string/long_text"
|
||||
android:autoSizeText="uniform"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:autoSizeMinTextSize="10px"
|
||||
android:textSize="10010px"
|
||||
android:autoSizeStepGranularity="1px"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="600dp"
|
||||
android:text="@string/long_text"
|
||||
android:autoSizeText="uniform"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:autoSizeMinTextSize="10px"
|
||||
android:textSize="100010px"
|
||||
android:autoSizeStepGranularity="1px"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="600dp"
|
||||
android:text="@string/long_text"
|
||||
android:autoSizeText="uniform"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:autoSizeMinTextSize="10px"
|
||||
android:textSize="310px"
|
||||
android:autoSizeStepGranularity="1px"/>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="600dp"
|
||||
android:text="@string/long_text"
|
||||
android:autoSizeText="uniform"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:autoSizeMinTextSize="10px"
|
||||
android:textSize="15px"
|
||||
android:autoSizeStepGranularity="1px"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="600dp"
|
||||
android:text="@string/long_text"
|
||||
android:autoSizeText="uniform"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:autoSizeMinTextSize="10px"
|
||||
android:textSize="60px"
|
||||
android:autoSizeStepGranularity="1px"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="600dp"
|
||||
android:text="@string/long_text"
|
||||
android:autoSizeText="uniform"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:autoSizeMinTextSize="10px"
|
||||
android:textSize="510px"
|
||||
android:autoSizeStepGranularity="1px"/>
|
||||
|
||||
@@ -89,7 +89,7 @@ public class TextViewAutoSizeLayoutPerfTest {
|
||||
|
||||
while (state.keepRunning()) {
|
||||
TextView textView = new TextView(activity);
|
||||
// TextView#onMeasure() gets called, which triggers TextView#autoSizeText()
|
||||
// TextView#onLayout() gets called, which triggers TextView#autoSizeText()
|
||||
// which is the method we want to benchmark.
|
||||
textView.requestLayout();
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ package android {
|
||||
field public static final int autoSizeMinTextSize = 16844088; // 0x1010538
|
||||
field public static final int autoSizePresetSizes = 16844087; // 0x1010537
|
||||
field public static final int autoSizeStepGranularity = 16844086; // 0x1010536
|
||||
field public static final int autoSizeText = 16844085; // 0x1010535
|
||||
field public static final int autoSizeTextType = 16844085; // 0x1010535
|
||||
field public static final int autoStart = 16843445; // 0x10102b5
|
||||
field public static final deprecated int autoText = 16843114; // 0x101016a
|
||||
field public static final int autoUrlDetect = 16843404; // 0x101028c
|
||||
|
||||
@@ -418,7 +418,7 @@ package android {
|
||||
field public static final int autoSizeMinTextSize = 16844088; // 0x1010538
|
||||
field public static final int autoSizePresetSizes = 16844087; // 0x1010537
|
||||
field public static final int autoSizeStepGranularity = 16844086; // 0x1010536
|
||||
field public static final int autoSizeText = 16844085; // 0x1010535
|
||||
field public static final int autoSizeTextType = 16844085; // 0x1010535
|
||||
field public static final int autoStart = 16843445; // 0x10102b5
|
||||
field public static final deprecated int autoText = 16843114; // 0x101016a
|
||||
field public static final int autoUrlDetect = 16843404; // 0x101028c
|
||||
@@ -25932,9 +25932,9 @@ package android.media.tv {
|
||||
method public static final boolean isProgramUri(android.net.Uri);
|
||||
field public static final java.lang.String AUTHORITY = "android.media.tv";
|
||||
field public static final java.lang.String EXTRA_COLUMN_NAME = "android.media.tv.extra.COLUMN_NAME";
|
||||
field public static final java.lang.String EXTRA_EXISTING_COLUMN_NAMES = "android.media.tv.extra.EXISTING_COLUMN_NAMES";
|
||||
field public static final java.lang.String EXTRA_DATA_TYPE = "android.media.tv.extra.DATA_TYPE";
|
||||
field public static final java.lang.String EXTRA_DEFAULT_VALUE = "android.media.tv.extra.DEFAULT_VALUE";
|
||||
field public static final java.lang.String EXTRA_EXISTING_COLUMN_NAMES = "android.media.tv.extra.EXISTING_COLUMN_NAMES";
|
||||
field public static final java.lang.String METHOD_ADD_COLUMN = "add_column";
|
||||
field public static final java.lang.String METHOD_GET_COLUMNS = "get_columns";
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ package android {
|
||||
field public static final int autoSizeMinTextSize = 16844088; // 0x1010538
|
||||
field public static final int autoSizePresetSizes = 16844087; // 0x1010537
|
||||
field public static final int autoSizeStepGranularity = 16844086; // 0x1010536
|
||||
field public static final int autoSizeText = 16844085; // 0x1010535
|
||||
field public static final int autoSizeTextType = 16844085; // 0x1010535
|
||||
field public static final int autoStart = 16843445; // 0x10102b5
|
||||
field public static final deprecated int autoText = 16843114; // 0x101016a
|
||||
field public static final int autoUrlDetect = 16843404; // 0x101028c
|
||||
|
||||
@@ -266,7 +266,7 @@ import java.util.Locale;
|
||||
* @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_autoSizeText
|
||||
* @attr ref android.R.styleable#TextView_autoSizeTextType
|
||||
* @attr ref android.R.styleable#TextView_autoSizeMinTextSize
|
||||
* @attr ref android.R.styleable#TextView_autoSizeMaxTextSize
|
||||
* @attr ref android.R.styleable#TextView_autoSizeStepGranularity
|
||||
@@ -691,18 +691,24 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
*/
|
||||
private int mDeviceProvisionedState = DEVICE_PROVISIONED_UNKNOWN;
|
||||
|
||||
// The TextView does not auto-size text (default).
|
||||
/**
|
||||
* The TextView does not auto-size text (default).
|
||||
*/
|
||||
public static final int AUTO_SIZE_TEXT_TYPE_NONE = 0;
|
||||
// The TextView performs uniform horizontal and vertical text size scaling to fit within the
|
||||
// container.
|
||||
|
||||
/**
|
||||
* The TextView scales text size both horizontally and vertically to fit within the
|
||||
* container.
|
||||
*/
|
||||
public static final int AUTO_SIZE_TEXT_TYPE_UNIFORM = 1;
|
||||
|
||||
/** @hide */
|
||||
@IntDef({AUTO_SIZE_TEXT_TYPE_NONE, AUTO_SIZE_TEXT_TYPE_UNIFORM})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface AutoSizeTextType {}
|
||||
// Default minimum size for auto-sizing text in scaled pixels. {@see #setAutoSizeMinTextSize}.
|
||||
// Default minimum size for auto-sizing text in scaled pixels.
|
||||
private static final int DEFAULT_AUTO_SIZE_MIN_TEXT_SIZE_IN_SP = 12;
|
||||
// Default maximum size for auto-sizing text in scaled pixels. {@see #setAutoSizeMaxTextSize}.
|
||||
// Default maximum size for auto-sizing text in scaled pixels.
|
||||
private static final int DEFAULT_AUTO_SIZE_MAX_TEXT_SIZE_IN_SP = 112;
|
||||
// Default value for the step size in pixels.
|
||||
private static final int DEFAULT_AUTO_SIZE_GRANULARITY_IN_PX = 1;
|
||||
@@ -1308,7 +1314,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
mHyphenationFrequency = a.getInt(attr, Layout.HYPHENATION_FREQUENCY_NONE);
|
||||
break;
|
||||
|
||||
case com.android.internal.R.styleable.TextView_autoSizeText:
|
||||
case com.android.internal.R.styleable.TextView_autoSizeTextType:
|
||||
mAutoSizeTextType = a.getInt(attr, AUTO_SIZE_TEXT_TYPE_NONE);
|
||||
break;
|
||||
|
||||
@@ -1660,7 +1666,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
* {@link TextView#AUTO_SIZE_TEXT_TYPE_NONE} or
|
||||
* {@link TextView#AUTO_SIZE_TEXT_TYPE_UNIFORM}
|
||||
*
|
||||
* @attr ref android.R.styleable#TextView_autoSizeText
|
||||
* @attr ref android.R.styleable#TextView_autoSizeTextType
|
||||
*
|
||||
* @see #getAutoSizeTextType()
|
||||
*/
|
||||
@@ -1709,7 +1715,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
*
|
||||
* @throws IllegalArgumentException if any of the configuration params are invalid.
|
||||
*
|
||||
* @attr ref android.R.styleable#TextView_autoSizeText
|
||||
* @attr ref android.R.styleable#TextView_autoSizeTextType
|
||||
* @attr ref android.R.styleable#TextView_autoSizeMinTextSize
|
||||
* @attr ref android.R.styleable#TextView_autoSizeMaxTextSize
|
||||
* @attr ref android.R.styleable#TextView_autoSizeStepGranularity
|
||||
@@ -1753,7 +1759,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
*
|
||||
* @throws IllegalArgumentException if all of the <code>presetSizes</code> are invalid.
|
||||
*
|
||||
* @attr ref android.R.styleable#TextView_autoSizeText
|
||||
* @attr ref android.R.styleable#TextView_autoSizeTextType
|
||||
* @attr ref android.R.styleable#TextView_autoSizePresetSizes
|
||||
*
|
||||
* @see #setAutoSizeTextTypeWithDefaults(int)
|
||||
@@ -1806,7 +1812,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
* {@link TextView#AUTO_SIZE_TEXT_TYPE_NONE} or
|
||||
* {@link TextView#AUTO_SIZE_TEXT_TYPE_UNIFORM}
|
||||
*
|
||||
* @attr ref android.R.styleable#TextView_autoSizeText
|
||||
* @attr ref android.R.styleable#TextView_autoSizeTextType
|
||||
*
|
||||
* @see #setAutoSizeTextTypeWithDefaults(int)
|
||||
* @see #setAutoSizeTextTypeUniformWithConfiguration(int, int, int, int)
|
||||
|
||||
@@ -4721,18 +4721,19 @@
|
||||
</attr>
|
||||
<!-- Specify the type of auto-size. Note that this feature is not supported by EditText,
|
||||
works only for TextView -->
|
||||
<attr name="autoSizeText" format="enum">
|
||||
<attr name="autoSizeTextType" format="enum">
|
||||
<!-- No auto-sizing (default). -->
|
||||
<enum name="none" value="0" />
|
||||
<!-- Uniform horizontal and vertical scaling. -->
|
||||
<!-- Uniform horizontal and vertical text size scaling to fit within the
|
||||
container -->
|
||||
<enum name="uniform" value="1" />
|
||||
</attr>
|
||||
<!-- Specify the auto-size step size if <code>autoSizeText</code> is set to
|
||||
<code>xy</code>. The default is 1px. Overwrites
|
||||
<!-- Specify the auto-size step size if <code>autoSizeTextType</code> is set to
|
||||
<code>uniform</code>. The default is 1px. Overwrites
|
||||
<code>autoSizePresetSizes</code> if set. -->
|
||||
<attr name="autoSizeStepGranularity" format="dimension" />
|
||||
<!-- Array of dimensions to be used in conjunction with
|
||||
<code>autoSizeText</code> set to <code>xy</code>. Overwrites
|
||||
<!-- Resource array of dimensions to be used in conjunction with
|
||||
<code>autoSizeTextType</code> set to <code>uniform</code>. Overrides
|
||||
<code>autoSizeStepGranularity</code> if set. -->
|
||||
<attr name="autoSizePresetSizes"/>
|
||||
<!-- The minimum text size constraint to be used when auto-sizing text -->
|
||||
|
||||
@@ -2765,7 +2765,7 @@
|
||||
<public name="font" />
|
||||
<public name="fontWeight" />
|
||||
<public name="tooltipText" />
|
||||
<public name="autoSizeText" />
|
||||
<public name="autoSizeTextType" />
|
||||
<public name="autoSizeStepGranularity" />
|
||||
<public name="autoSizePresetSizes" />
|
||||
<public name="autoSizeMinTextSize" />
|
||||
|
||||
Reference in New Issue
Block a user