Merge changes from topic "excluded_font_padding" into androidx-main
* changes:
Add support for excluding font padding in Material Text
Add AndroidTextStyle for excluding font padding
diff --git a/wear/protolayout/protolayout-material/api/public_plus_experimental_current.txt b/wear/protolayout/protolayout-material/api/public_plus_experimental_current.txt
index 862495c3..cd20621 100644
--- a/wear/protolayout/protolayout-material/api/public_plus_experimental_current.txt
+++ b/wear/protolayout/protolayout-material/api/public_plus_experimental_current.txt
@@ -159,6 +159,7 @@
public class Text implements androidx.wear.protolayout.LayoutElementBuilders.LayoutElement {
method public static androidx.wear.protolayout.material.Text? fromLayoutElement(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement);
method public androidx.wear.protolayout.ColorBuilders.ColorProp getColor();
+ method @androidx.wear.protolayout.expression.ProtoLayoutExperimental public boolean getExcludeFontPadding();
method public androidx.wear.protolayout.LayoutElementBuilders.FontStyle getFontStyle();
method public float getLineHeight();
method public int getMaxLines();
@@ -175,6 +176,7 @@
ctor public Text.Builder(android.content.Context, String);
method public androidx.wear.protolayout.material.Text build();
method public androidx.wear.protolayout.material.Text.Builder setColor(androidx.wear.protolayout.ColorBuilders.ColorProp);
+ method @androidx.wear.protolayout.expression.ProtoLayoutExperimental public androidx.wear.protolayout.material.Text.Builder setExcludeFontPadding(boolean);
method public androidx.wear.protolayout.material.Text.Builder setItalic(boolean);
method public androidx.wear.protolayout.material.Text.Builder setMaxLines(@IntRange(from=1) int);
method public androidx.wear.protolayout.material.Text.Builder setModifiers(androidx.wear.protolayout.ModifiersBuilders.Modifiers);
diff --git a/wear/protolayout/protolayout-material/build.gradle b/wear/protolayout/protolayout-material/build.gradle
index 536215b..8d0c69d7 100644
--- a/wear/protolayout/protolayout-material/build.gradle
+++ b/wear/protolayout/protolayout-material/build.gradle
@@ -28,6 +28,7 @@
implementation(project(":wear:protolayout:protolayout"))
implementation(project(":wear:protolayout:protolayout-proto"))
implementation(project(":wear:protolayout:protolayout-expression"))
+ implementation("androidx.annotation:annotation-experimental:1.3.0")
androidTestImplementation(libs.junit)
androidTestImplementation(libs.testCore)
androidTestImplementation(libs.testExtJunit)
diff --git a/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/TestCasesGenerator.java b/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/TestCasesGenerator.java
index cb43b9b..3653dc9 100644
--- a/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/TestCasesGenerator.java
+++ b/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/TestCasesGenerator.java
@@ -32,7 +32,9 @@
import androidx.wear.protolayout.LayoutElementBuilders.Box;
import androidx.wear.protolayout.LayoutElementBuilders.LayoutElement;
import androidx.wear.protolayout.LayoutElementBuilders.Row;
+import androidx.wear.protolayout.ModifiersBuilders.Background;
import androidx.wear.protolayout.ModifiersBuilders.Clickable;
+import androidx.wear.protolayout.ModifiersBuilders.Modifiers;
import java.util.HashMap;
import java.util.Map;
@@ -181,7 +183,7 @@
.setChipColors(ChipDefaults.SECONDARY_COLORS)
.setHorizontalAlignment(HORIZONTAL_ALIGN_START)
.setCustomContent(
- new Row.Builder()
+ new LayoutElementBuilders.Row.Builder()
.addContent(
new Text.Builder(context, "text1")
.setTypography(Typography.TYPOGRAPHY_TITLE3)
@@ -278,6 +280,30 @@
testCases.put(
"default_text_golden" + goldenSuffix, new Text.Builder(context, "Testing").build());
testCases.put(
+ "excluded_padding_text_golden" + goldenSuffix,
+ new Row.Builder()
+ .addContent(
+ new Box.Builder()
+ .setModifiers(buildBackgroundColorModifier(Color.YELLOW))
+ .addContent(
+ new Text.Builder(context, "Inc padd ")
+ .setExcludeFontPadding(false)
+ .setTypography(
+ Typography.TYPOGRAPHY_CAPTION1)
+ .build())
+ .build())
+ .addContent(
+ new Box.Builder()
+ .setModifiers(buildBackgroundColorModifier(Color.CYAN))
+ .addContent(
+ new Text.Builder(context, "Excl padd")
+ .setExcludeFontPadding(true)
+ .setTypography(
+ Typography.TYPOGRAPHY_CAPTION1)
+ .build())
+ .build())
+ .build());
+ testCases.put(
"custom_text_golden" + goldenSuffix,
new Text.Builder(context, "Testing text.")
.setItalic(true)
@@ -291,4 +317,10 @@
return testCases;
}
+
+ private static Modifiers buildBackgroundColorModifier(int color) {
+ return new Modifiers.Builder()
+ .setBackground(new Background.Builder().setColor(argb(color)).build())
+ .build();
+ }
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Text.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Text.java
index 132990b..6c8a631 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Text.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Text.java
@@ -24,6 +24,7 @@
import static androidx.wear.protolayout.material.Typography.getFontStyleBuilder;
import static androidx.wear.protolayout.material.Typography.getLineHeightForTypography;
+import android.annotation.SuppressLint;
import android.content.Context;
import androidx.annotation.IntRange;
@@ -40,6 +41,7 @@
import androidx.wear.protolayout.LayoutElementBuilders.TextOverflow;
import androidx.wear.protolayout.ModifiersBuilders.Modifiers;
import androidx.wear.protolayout.expression.Fingerprint;
+import androidx.wear.protolayout.expression.ProtoLayoutExperimental;
import androidx.wear.protolayout.material.Typography.TypographyName;
import androidx.wear.protolayout.proto.LayoutElementProto;
@@ -79,18 +81,20 @@
/** Builder class for {@link Text}. */
public static final class Builder implements LayoutElement.Builder {
@NonNull private final Context mContext;
- @NonNull private String mTextContent = "";
@NonNull private ColorProp mColor = argb(Colors.DEFAULT.getOnPrimary());
private @TypographyName int mTypographyName = TYPOGRAPHY_DISPLAY1;
private boolean mItalic = false;
- private int mMaxLines = 1;
private boolean mUnderline = false;
- @TextAlignment private int mMultilineAlignment = TEXT_ALIGN_CENTER;
- @NonNull private Modifiers mModifiers = new Modifiers.Builder().build();
- private @TextOverflow int mOverflow = TEXT_OVERFLOW_ELLIPSIZE_END;
private boolean mIsScalable = true;
@Nullable private Integer mCustomWeight = null;
+ @NonNull
+ private final LayoutElementBuilders.Text.Builder mElementBuilder =
+ new LayoutElementBuilders.Text.Builder()
+ .setMaxLines(1)
+ .setMultilineAlignment(TEXT_ALIGN_CENTER)
+ .setOverflow(TEXT_OVERFLOW_ELLIPSIZE_END);
+
/**
* Creates a builder for {@link Text}.
*
@@ -99,7 +103,7 @@
*/
public Builder(@NonNull Context context, @NonNull String text) {
mContext = context;
- mTextContent = text;
+ mElementBuilder.setText(text);
}
/**
@@ -152,7 +156,7 @@
/** Sets the maximum lines of text. If not set, 1 will be used. */
@NonNull
public Builder setMaxLines(@IntRange(from = 1) int maxLines) {
- this.mMaxLines = maxLines;
+ this.mElementBuilder.setMaxLines(maxLines);
return this;
}
@@ -164,14 +168,14 @@
*/
@NonNull
public Builder setMultilineAlignment(@TextAlignment int multilineAlignment) {
- this.mMultilineAlignment = multilineAlignment;
+ this.mElementBuilder.setMultilineAlignment(multilineAlignment);
return this;
}
/** Sets the modifiers of text. */
@NonNull
public Builder setModifiers(@NonNull Modifiers modifiers) {
- this.mModifiers = modifiers;
+ this.mElementBuilder.setModifiers(modifiers);
return this;
}
@@ -181,7 +185,7 @@
*/
@NonNull
public Builder setOverflow(@TextOverflow int overflow) {
- this.mOverflow = overflow;
+ this.mElementBuilder.setOverflow(overflow);
return this;
}
@@ -195,6 +199,24 @@
return this;
}
+ /**
+ * Sets whether the {@link Text} excludes extra top and bottom padding above the normal
+ * ascent and descent. The default is false.
+ */
+ // TODO(b/252767963): Coordinate the transition of the default from false->true along with
+ // other impacted UI Libraries - needs care as will have an impact on layout and needs to be
+ // communicated clearly.
+ @NonNull
+ @SuppressLint("MissingGetterMatchingBuilder")
+ @ProtoLayoutExperimental
+ public Builder setExcludeFontPadding(boolean excludeFontPadding) {
+ this.mElementBuilder.setAndroidTextStyle(
+ new LayoutElementBuilders.AndroidTextStyle.Builder()
+ .setExcludeFontPadding(excludeFontPadding)
+ .build());
+ return this;
+ }
+
/** Constructs and returns {@link Text} with the provided content and look. */
@NonNull
@Override
@@ -207,17 +229,10 @@
if (mCustomWeight != null) {
fontStyleBuilder.setWeight(mCustomWeight);
}
-
- LayoutElementBuilders.Text.Builder text =
- new LayoutElementBuilders.Text.Builder()
- .setText(mTextContent)
- .setFontStyle(fontStyleBuilder.build())
- .setLineHeight(getLineHeightForTypography(mTypographyName))
- .setMaxLines(mMaxLines)
- .setMultilineAlignment(mMultilineAlignment)
- .setModifiers(mModifiers)
- .setOverflow(mOverflow);
- return new Text(text.build());
+ mElementBuilder
+ .setFontStyle(fontStyleBuilder.build())
+ .setLineHeight(getLineHeightForTypography(mTypographyName));
+ return new Text(mElementBuilder.build());
}
}
@@ -284,6 +299,15 @@
}
/**
+ * Returns whether the Text has extra top and bottom padding above the normal ascent and descent
+ * excluded.
+ */
+ @ProtoLayoutExperimental
+ public boolean getExcludeFontPadding() {
+ return checkNotNull(mText.getAndroidTextStyle()).getExcludeFontPadding();
+ }
+
+ /**
* Returns Material Text object from the given LayoutElement (e.g. one retrieved from a
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to Material Text. Otherwise, it will return null.
diff --git a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/TextTest.java b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/TextTest.java
index 3f424d0..a63dd69 100644
--- a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/TextTest.java
+++ b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/TextTest.java
@@ -45,6 +45,7 @@
import androidx.wear.protolayout.ModifiersBuilders.Background;
import androidx.wear.protolayout.ModifiersBuilders.ElementMetadata;
import androidx.wear.protolayout.ModifiersBuilders.Modifiers;
+import androidx.wear.protolayout.expression.ProtoLayoutExperimental;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -111,19 +112,20 @@
public void testWrongTag() {
Box box =
new Box.Builder()
- .setModifiers(
- new Modifiers.Builder()
- .setMetadata(
- new ElementMetadata.Builder()
- .setTagData("test".getBytes(UTF_8))
- .build())
- .build())
- .build();
+ .setModifiers(
+ new Modifiers.Builder()
+ .setMetadata(
+ new ElementMetadata.Builder()
+ .setTagData("test".getBytes(UTF_8))
+ .build())
+ .build())
+ .build();
assertThat(Text.fromLayoutElement(box)).isNull();
}
@Test
+ @ProtoLayoutExperimental
public void testText() {
String textContent = "Testing text.";
Modifiers modifiers =
@@ -142,6 +144,7 @@
.setOverflow(TEXT_OVERFLOW_ELLIPSIZE_END)
.setMultilineAlignment(TEXT_ALIGN_END)
.setWeight(FONT_WEIGHT_BOLD)
+ .setExcludeFontPadding(true)
.build();
FontStyle expectedFontStyle =
@@ -162,6 +165,7 @@
assertThat(Text.fromLayoutElement(text)).isEqualTo(text);
}
+ @ProtoLayoutExperimental
private void assertTextIsEqual(
Text actualText,
String expectedTextContent,
@@ -176,6 +180,7 @@
assertThat(actualText.getMaxLines()).isEqualTo(2);
assertThat(actualText.getLineHeight())
.isEqualTo(getLineHeightForTypography(TYPOGRAPHY_TITLE1).getValue());
+ assertThat(actualText.getExcludeFontPadding()).isTrue();
}
private void assertFontStyle(
diff --git a/wear/protolayout/protolayout-proto/src/main/proto/layout.proto b/wear/protolayout/protolayout-proto/src/main/proto/layout.proto
index 9e083fc..c9e3f38 100644
--- a/wear/protolayout/protolayout-proto/src/main/proto/layout.proto
+++ b/wear/protolayout/protolayout-proto/src/main/proto/layout.proto
@@ -145,8 +145,8 @@
// An Android platform specific text style configuration options for styling and
// compatibility.
message AndroidTextStyle {
- // Whether the Text excludes extra top and bottom padding above the normal
- // ascent and descent. The default is false.
+ // Whether the Text excludes padding specified by the font, i.e. extra top and bottom padding
+ // above the normal ascent and descent. The default is false.
bool exclude_font_padding = 1;
}
diff --git a/wear/protolayout/protolayout/api/public_plus_experimental_current.txt b/wear/protolayout/protolayout/api/public_plus_experimental_current.txt
index ec7bdbf..d36a172 100644
--- a/wear/protolayout/protolayout/api/public_plus_experimental_current.txt
+++ b/wear/protolayout/protolayout/api/public_plus_experimental_current.txt
@@ -359,6 +359,16 @@
field public static final int VERTICAL_ALIGN_UNDEFINED = 0; // 0x0
}
+ @androidx.wear.protolayout.expression.ProtoLayoutExperimental public static final class LayoutElementBuilders.AndroidTextStyle {
+ method public boolean getExcludeFontPadding();
+ }
+
+ public static final class LayoutElementBuilders.AndroidTextStyle.Builder {
+ ctor public LayoutElementBuilders.AndroidTextStyle.Builder();
+ method public androidx.wear.protolayout.LayoutElementBuilders.AndroidTextStyle build();
+ method public androidx.wear.protolayout.LayoutElementBuilders.AndroidTextStyle.Builder setExcludeFontPadding(boolean);
+ }
+
public static final class LayoutElementBuilders.Arc implements androidx.wear.protolayout.LayoutElementBuilders.LayoutElement {
method public androidx.wear.protolayout.DimensionBuilders.DegreesProp? getAnchorAngle();
method public androidx.wear.protolayout.LayoutElementBuilders.ArcAnchorTypeProp? getAnchorType();
@@ -696,6 +706,7 @@
}
public static final class LayoutElementBuilders.SpanText implements androidx.wear.protolayout.LayoutElementBuilders.Span {
+ method @androidx.wear.protolayout.expression.ProtoLayoutExperimental public androidx.wear.protolayout.LayoutElementBuilders.AndroidTextStyle? getAndroidTextStyle();
method public androidx.wear.protolayout.LayoutElementBuilders.FontStyle? getFontStyle();
method public androidx.wear.protolayout.ModifiersBuilders.SpanModifiers? getModifiers();
method public androidx.wear.protolayout.TypeBuilders.StringProp? getText();
@@ -704,6 +715,7 @@
public static final class LayoutElementBuilders.SpanText.Builder implements androidx.wear.protolayout.LayoutElementBuilders.Span.Builder {
ctor public LayoutElementBuilders.SpanText.Builder();
method public androidx.wear.protolayout.LayoutElementBuilders.SpanText build();
+ method @androidx.wear.protolayout.expression.ProtoLayoutExperimental public androidx.wear.protolayout.LayoutElementBuilders.SpanText.Builder setAndroidTextStyle(androidx.wear.protolayout.LayoutElementBuilders.AndroidTextStyle);
method public androidx.wear.protolayout.LayoutElementBuilders.SpanText.Builder setFontStyle(androidx.wear.protolayout.LayoutElementBuilders.FontStyle);
method public androidx.wear.protolayout.LayoutElementBuilders.SpanText.Builder setModifiers(androidx.wear.protolayout.ModifiersBuilders.SpanModifiers);
method public androidx.wear.protolayout.LayoutElementBuilders.SpanText.Builder setText(androidx.wear.protolayout.TypeBuilders.StringProp);
@@ -744,6 +756,7 @@
}
public static final class LayoutElementBuilders.Text implements androidx.wear.protolayout.LayoutElementBuilders.LayoutElement {
+ method @androidx.wear.protolayout.expression.ProtoLayoutExperimental public androidx.wear.protolayout.LayoutElementBuilders.AndroidTextStyle? getAndroidTextStyle();
method public androidx.wear.protolayout.LayoutElementBuilders.FontStyle? getFontStyle();
method public androidx.wear.protolayout.TypeBuilders.StringLayoutConstraint? getLayoutConstraintsForDynamicText();
method public androidx.wear.protolayout.DimensionBuilders.SpProp? getLineHeight();
@@ -757,6 +770,7 @@
public static final class LayoutElementBuilders.Text.Builder implements androidx.wear.protolayout.LayoutElementBuilders.LayoutElement.Builder {
ctor public LayoutElementBuilders.Text.Builder();
method public androidx.wear.protolayout.LayoutElementBuilders.Text build();
+ method @androidx.wear.protolayout.expression.ProtoLayoutExperimental public androidx.wear.protolayout.LayoutElementBuilders.Text.Builder setAndroidTextStyle(androidx.wear.protolayout.LayoutElementBuilders.AndroidTextStyle);
method public androidx.wear.protolayout.LayoutElementBuilders.Text.Builder setFontStyle(androidx.wear.protolayout.LayoutElementBuilders.FontStyle);
method public androidx.wear.protolayout.LayoutElementBuilders.Text.Builder setLayoutConstraintsForDynamicText(androidx.wear.protolayout.TypeBuilders.StringLayoutConstraint);
method public androidx.wear.protolayout.LayoutElementBuilders.Text.Builder setLineHeight(androidx.wear.protolayout.DimensionBuilders.SpProp);
diff --git a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/LayoutElementBuilders.java b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/LayoutElementBuilders.java
index feccdaf6..7e98f63a 100644
--- a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/LayoutElementBuilders.java
+++ b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/LayoutElementBuilders.java
@@ -697,6 +697,96 @@
}
}
+ /**
+ * An Android platform specific text style configuration options for styling and compatibility.
+ *
+ * @since 1.2
+ */
+ @ProtoLayoutExperimental
+ public static final class AndroidTextStyle {
+ private final LayoutElementProto.AndroidTextStyle mImpl;
+ @Nullable private final Fingerprint mFingerprint;
+
+ AndroidTextStyle(LayoutElementProto.AndroidTextStyle impl,
+ @Nullable Fingerprint fingerprint) {
+ this.mImpl = impl;
+ this.mFingerprint = fingerprint;
+ }
+
+ /**
+ * Gets whether the {@link Text} excludes padding specified by the font, i.e. extra top and
+ * bottom padding above the normal ascent and descent. The default is false.
+ *
+ * @since 1.2
+ */
+ public boolean getExcludeFontPadding() {
+ return mImpl.getExcludeFontPadding();
+ }
+
+ /** Get the fingerprint for this object, or null if unknown. */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @Nullable
+ public Fingerprint getFingerprint() {
+ return mFingerprint;
+ }
+
+ /** Creates a new wrapper instance from the proto. */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public static AndroidTextStyle fromProto(
+ @NonNull LayoutElementProto.AndroidTextStyle proto,
+ @Nullable Fingerprint fingerprint) {
+ return new AndroidTextStyle(proto, fingerprint);
+ }
+
+ @NonNull
+ static AndroidTextStyle fromProto(@NonNull LayoutElementProto.AndroidTextStyle proto) {
+ return fromProto(proto, null);
+ }
+
+ /** Returns the internal proto instance. */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public LayoutElementProto.AndroidTextStyle toProto() {
+ return mImpl;
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "AndroidTextStyle{" + "excludeFontPadding=" + getExcludeFontPadding() + "}";
+ }
+
+ /** Builder for {@link AndroidTextStyle} */
+ public static final class Builder {
+ private final LayoutElementProto.AndroidTextStyle.Builder mImpl =
+ LayoutElementProto.AndroidTextStyle.newBuilder();
+ private final Fingerprint mFingerprint = new Fingerprint(408674745);
+
+ public Builder() {}
+
+ /**
+ * Sets whether the {@link Text} excludes padding specified by the font, i.e. extra
+ * top and bottom padding above the normal ascent and descent. The default is false.
+ *
+ * @since 1.2
+ */
+ @SuppressLint("MissingGetterMatchingBuilder")
+ @NonNull
+ public Builder setExcludeFontPadding(boolean excludeFontPadding) {
+ mImpl.setExcludeFontPadding(excludeFontPadding);
+ mFingerprint.recordPropertyUpdate(1, Boolean.hashCode(excludeFontPadding));
+ return this;
+ }
+
+ /** Builds an instance from accumulated values. */
+ @NonNull
+ public AndroidTextStyle build() {
+ return new AndroidTextStyle(mImpl.build(), mFingerprint);
+ }
+ }
+ }
+
/** A text string. */
public static final class Text implements LayoutElement {
private final LayoutElementProto.Text mImpl;
@@ -818,6 +908,22 @@
}
}
+ /**
+ * Gets an Android platform specific text style configuration options for styling and
+ * compatibility.
+ *
+ * @since 1.2
+ */
+ @ProtoLayoutExperimental
+ @Nullable
+ public AndroidTextStyle getAndroidTextStyle() {
+ if (mImpl.hasAndroidTextStyle()) {
+ return AndroidTextStyle.fromProto(mImpl.getAndroidTextStyle());
+ } else {
+ return null;
+ }
+ }
+
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
@Nullable
@@ -1017,6 +1123,21 @@
return this;
}
+ /**
+ * Sets an Android platform specific text style configuration options for styling and
+ * compatibility.
+ *
+ * @since 1.2
+ */
+ @ProtoLayoutExperimental
+ @NonNull
+ public Builder setAndroidTextStyle(@NonNull AndroidTextStyle androidTextStyle) {
+ mImpl.setAndroidTextStyle(androidTextStyle.toProto());
+ mFingerprint.recordPropertyUpdate(
+ 8, checkNotNull(androidTextStyle.getFingerprint()).aggregateValueAsInt());
+ return this;
+ }
+
@Override
@NonNull
public Text build() {
@@ -1897,6 +2018,22 @@
}
}
+ /**
+ * Gets an Android platform specific text style configuration options for styling and
+ * compatibility.
+ *
+ * @since 1.2
+ */
+ @ProtoLayoutExperimental
+ @Nullable
+ public AndroidTextStyle getAndroidTextStyle() {
+ if (mImpl.hasAndroidTextStyle()) {
+ return AndroidTextStyle.fromProto(mImpl.getAndroidTextStyle());
+ } else {
+ return null;
+ }
+ }
+
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
@Nullable
@@ -1977,6 +2114,21 @@
return this;
}
+ /**
+ * Sets an Android platform specific text style configuration options for styling and
+ * compatibility.
+ *
+ * @since 1.2
+ */
+ @ProtoLayoutExperimental
+ @NonNull
+ public Builder setAndroidTextStyle(@NonNull AndroidTextStyle androidTextStyle) {
+ mImpl.setAndroidTextStyle(androidTextStyle.toProto());
+ mFingerprint.recordPropertyUpdate(
+ 4, checkNotNull(androidTextStyle.getFingerprint()).aggregateValueAsInt());
+ return this;
+ }
+
@Override
@NonNull
public SpanText build() {