diff options
| author | 2024-02-03 04:35:11 +0000 | |
|---|---|---|
| committer | 2024-02-03 04:35:11 +0000 | |
| commit | 71de38a812f5e6a2f154a59e4f8ce0437da44940 (patch) | |
| tree | 33adca72f2b950b7ad253c432528b1dc222d72e6 | |
| parent | 2ad775493d6fc6baf7fd6bf4116ed1e43ae23f1a (diff) | |
| parent | fcc558746b127459c5321e775b40955e1aa164da (diff) | |
Merge "Add XML attribute for newly added Layout APIs." into main
| -rw-r--r-- | core/api/current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/widget/TextView.java | 14 | ||||
| -rw-r--r-- | core/res/res/values/attrs.xml | 12 | ||||
| -rw-r--r-- | core/res/res/values/public-staging.xml | 2 |
4 files changed, 24 insertions, 5 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index eb39a361c6fc..e2c2f274e3b2 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -1796,6 +1796,7 @@ package android { field public static final int updatePeriodMillis = 16843344; // 0x1010250 field public static final int use32bitAbi = 16844053; // 0x1010515 field public static final int useAppZygote = 16844183; // 0x1010597 + field @FlaggedApi("com.android.text.flags.use_bounds_for_width") public static final int useBoundsForWidth; field public static final int useDefaultMargins = 16843641; // 0x1010379 field public static final int useEmbeddedDex = 16844190; // 0x101059e field public static final int useIntrinsicSizeAsMinimum = 16843536; // 0x1010310 diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 90d51402f5b1..9a4106d930b4 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -1259,6 +1259,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener int lastBaselineToBottomHeight = -1; float lineHeight = -1f; int lineHeightUnit = -1; + boolean hasUseBoundForWidthValue = false; readTextAppearance(context, a, attributes, true /* styleArray */); @@ -1613,6 +1614,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener lineHeight = a.getDimensionPixelSize(attr, -1); } break; + case com.android.internal.R.styleable.TextView_useBoundsForWidth: + mUseBoundsForWidth = a.getBoolean(attr, false); + hasUseBoundForWidthValue = true; } } @@ -1639,10 +1643,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mUseFallbackLineSpacing = FALLBACK_LINE_SPACING_NONE; } - if (CompatChanges.isChangeEnabled(USE_BOUNDS_FOR_WIDTH)) { - mUseBoundsForWidth = ClientFlags.useBoundsForWidth(); - } else { - mUseBoundsForWidth = false; + if (!hasUseBoundForWidthValue) { + if (CompatChanges.isChangeEnabled(USE_BOUNDS_FOR_WIDTH)) { + mUseBoundsForWidth = ClientFlags.useBoundsForWidth(); + } else { + mUseBoundsForWidth = false; + } } // TODO(b/179693024): Use a ChangeId instead. diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 2eb28eb555e8..f154b571b3e4 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -5783,7 +5783,17 @@ <enum name="none" value="0" /> <!-- Justification by stretching word spacing. --> <enum name="inter_word" value = "1" /> - </attr> + <!-- Justification by stretching letter spacing. --> + <!-- @FlaggedApi("com.android.text.flags.inter_character_justification") --> + <enum name="inter_character" value = "2" /> + </attr> + <!-- Whether to use width of bounding box as a source of automatic line breaking and + drawing. + If this value is false, the TextView determines the View width, drawing offset and + automatic line breaking based on total advances as text widths. By setting true, + use glyph bound's as a source of text width. --> + <!-- @FlaggedApi("com.android.text.flags.use_bounds_for_width") --> + <attr name="useBoundsForWidth" format="boolean" /> </declare-styleable> <declare-styleable name="TextViewAppearance"> <!-- Base text color, typeface, size, and style. --> diff --git a/core/res/res/values/public-staging.xml b/core/res/res/values/public-staging.xml index 830e99ca907b..72bfa8ac9113 100644 --- a/core/res/res/values/public-staging.xml +++ b/core/res/res/values/public-staging.xml @@ -143,6 +143,8 @@ <public name="fragmentAdvancedPattern"/> <!-- @FlaggedApi("android.content.pm.relative_reference_intent_filters") --> <public name="fragmentSuffix"/> + <!-- @FlaggedApi("com.android.text.flags.use_bounds_for_width") --> + <public name="useBoundsForWidth"/> </staging-public-group> <staging-public-group type="id" first-id="0x01bc0000"> |