General updates to Material library code
Bug: 332538381
Test: Existing
Change-Id: Ib11c282d404da4a055770e46c86bc8b9bf471e1e
diff --git a/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Button.java b/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Button.java
index 026314d..886fcc5 100644
--- a/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Button.java
+++ b/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Button.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 The Android Open Source Project
+ * Copyright 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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 a5c592e..f7398ed 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
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package androidx.wear.protolayout.material;
import static androidx.wear.protolayout.ColorBuilders.argb;
diff --git a/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/layouts/TestCasesGenerator.java b/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/layouts/TestCasesGenerator.java
index 78cb89a..261749c 100644
--- a/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/layouts/TestCasesGenerator.java
+++ b/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/layouts/TestCasesGenerator.java
@@ -57,6 +57,7 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
public class TestCasesGenerator {
private TestCasesGenerator() {}
@@ -918,7 +919,7 @@
return testCases.entrySet().stream()
.collect(
toImmutableMap(
- Map.Entry::getKey,
+ Entry::getKey,
entry -> Layout.fromLayoutElement(entry.getValue())));
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Button.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Button.java
index 56ef3bc..83ec3f1 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Button.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Button.java
@@ -40,7 +40,6 @@
import androidx.annotation.Dimension;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.OptIn;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.ColorBuilders.ColorProp;
@@ -52,7 +51,6 @@
import androidx.wear.protolayout.ModifiersBuilders.Clickable;
import androidx.wear.protolayout.TypeBuilders.StringProp;
import androidx.wear.protolayout.expression.Fingerprint;
-import androidx.wear.protolayout.expression.ProtoLayoutExperimental;
import androidx.wear.protolayout.material.Typography.TypographyName;
import androidx.wear.protolayout.materialcore.Button.Builder.ButtonType;
import androidx.wear.protolayout.proto.LayoutElementProto;
@@ -287,7 +285,6 @@
}
@NonNull
- @OptIn(markerClass = ProtoLayoutExperimental.class)
private LayoutElement getCorrectContent() {
LayoutElement.Builder content;
switch (mType) {
@@ -345,7 +342,8 @@
}
}
- private static @TypographyName int getDefaultTypographyForSize(@NonNull DpProp size) {
+ @TypographyName
+ private static int getDefaultTypographyForSize(@NonNull DpProp size) {
if (size.getValue() == LARGE_SIZE.getValue()) {
return Typography.TYPOGRAPHY_TITLE1;
} else if (size.getValue() == EXTRA_LARGE_SIZE.getValue()) {
@@ -459,6 +457,7 @@
case METADATA_TAG_IMAGE:
case METADATA_TAG_CUSTOM_CONTENT:
break;
+ default: // fall out
}
if (contentColor == null) {
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ButtonDefaults.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ButtonDefaults.java
index 0f6f057..e34b352 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ButtonDefaults.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ButtonDefaults.java
@@ -36,13 +36,13 @@
/** The recommended size for extra large {@link Button}. */
@NonNull public static final DpProp EXTRA_LARGE_SIZE = dp(88);
- /** Returns the recommended icon size for the given size of a {@link Button}. */
+ /** Returns the recommended icon size for the given size of {@link Button}. */
@NonNull
public static DpProp recommendedIconSize(@NonNull DpProp buttonSize) {
return recommendedIconSize(buttonSize.getValue());
}
- /** Returns the recommended icon size for the given size of a {@link Button}. */
+ /** Returns the recommended icon size for the given size of {@link Button}. */
@NonNull
public static DpProp recommendedIconSize(@Dimension(unit = DP) float buttonSize) {
return dp(buttonSize / 2);
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Chip.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Chip.java
index 2b144b2..e256216 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Chip.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Chip.java
@@ -37,7 +37,6 @@
import androidx.annotation.Dimension;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.OptIn;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.ColorBuilders.ColorProp;
@@ -52,7 +51,6 @@
import androidx.wear.protolayout.ModifiersBuilders.Clickable;
import androidx.wear.protolayout.TypeBuilders.StringProp;
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;
@@ -98,7 +96,7 @@
mElement = element;
}
- /** Builder class for {@link androidx.wear.protolayout.material.Chip}. */
+ /** Builder class for {@link Chip}. */
public static final class Builder implements LayoutElement.Builder {
@NonNull private final Context mContext;
@Nullable private LayoutElement mCustomContent;
@@ -151,7 +149,7 @@
}
/**
- * Sets the width of {@link TitleChip}. If not set, default value will be set to fill the
+ * Sets the width of {@link Chip}. If not set, default value will be set to fill the
* screen.
*/
@NonNull
@@ -370,8 +368,7 @@
}
}
- @OptIn(markerClass = ProtoLayoutExperimental.class)
- @SuppressWarnings("deprecation")
+ @SuppressWarnings("deprecation") // ELLIPSIZE_END as existing API
private void setCorrectContent() {
if (mImageResourceId != null) {
Image icon =
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ChipColors.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ChipColors.java
index 673d6b8..069a260 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ChipColors.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ChipColors.java
@@ -43,7 +43,7 @@
* @param iconColor The color to be used for an icon in {@link Chip}. Should be in ARGB format.
* @param contentColor The text color to be used for a main text in {@link Chip}. Should be in
* ARGB format.
- * @param secondaryContentColor The text color to be used for a label text in {@link Chip}
+ * @param secondaryContentColor The text color to be used for a label text in {@link Chip}.
* Should be in ARGB format.
*/
public ChipColors(
@@ -62,8 +62,8 @@
*
* @param backgroundColor The background color to be used for {@link Chip}. Should be in ARGB
* format.
- * @param contentColor The content color to be used for all items inside {@link Chip} Should be
- * in ARGB format.
+ * @param contentColor The content color to be used for all items inside {@link Chip}. Should
+ * be in ARGB format.
*/
public ChipColors(@ColorInt int backgroundColor, @ColorInt int contentColor) {
mBackgroundColor = argb(backgroundColor);
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Colors.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Colors.java
index 01a008f..ee465ae 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Colors.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Colors.java
@@ -53,10 +53,10 @@
@NonNull
public static final Colors DEFAULT = new Colors(PRIMARY, ON_PRIMARY, SURFACE, ON_SURFACE);
- private @ColorInt final int mPrimary;
- private @ColorInt final int mOnPrimary;
- private @ColorInt final int mSurface;
- private @ColorInt final int mOnSurface;
+ @ColorInt private final int mPrimary;
+ @ColorInt private final int mOnPrimary;
+ @ColorInt private final int mSurface;
+ @ColorInt private final int mOnSurface;
/**
* Constructor for {@link Colors} object.
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/CompactChip.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/CompactChip.java
index 40ac894..f0b418f 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/CompactChip.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/CompactChip.java
@@ -16,7 +16,6 @@
package androidx.wear.protolayout.material;
-import static androidx.wear.protolayout.DimensionBuilders.WrappedDimensionProp;
import static androidx.wear.protolayout.DimensionBuilders.wrap;
import static androidx.wear.protolayout.LayoutElementBuilders.HORIZONTAL_ALIGN_CENTER;
import static androidx.wear.protolayout.LayoutElementBuilders.HORIZONTAL_ALIGN_START;
@@ -36,6 +35,7 @@
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters;
+import androidx.wear.protolayout.DimensionBuilders.WrappedDimensionProp;
import androidx.wear.protolayout.LayoutElementBuilders.LayoutElement;
import androidx.wear.protolayout.ModifiersBuilders.Clickable;
import androidx.wear.protolayout.TypeBuilders.StringProp;
@@ -47,8 +47,8 @@
* ProtoLayout component {@link CompactChip} that represents clickable object with the text.
*
* <p>The CompactChip is Stadium shape and has a max height designed to take no more than one line
- * of text of {@link Typography#TYPOGRAPHY_CAPTION1} style. Width of the chip is adjustable to the
- * text size.
+ * of text of {@link Typography#TYPOGRAPHY_CAPTION1} style with included margin for tap target to
+ * meet accessibility requirements. Width of the chip is adjustable to the text size.
*
* <p>The recommended set of {@link ChipColors} styles can be obtained from {@link ChipDefaults}.,
* e.g. {@link ChipDefaults#COMPACT_PRIMARY_COLORS} to get a color scheme for a primary {@link
@@ -80,7 +80,7 @@
this.mElement = element;
}
- /** Builder class for {@link androidx.wear.protolayout.material.CompactChip}. */
+ /** Builder class for {@link CompactChip}. */
public static final class Builder implements LayoutElement.Builder {
@NonNull private final Context mContext;
@Nullable private String mText;
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 264f3a0..f50c11f 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
@@ -30,7 +30,6 @@
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.OptIn;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.ColorBuilders.ColorProp;
@@ -44,7 +43,6 @@
import androidx.wear.protolayout.TypeBuilders.StringLayoutConstraint;
import androidx.wear.protolayout.TypeBuilders.StringProp;
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;
@@ -85,14 +83,13 @@
public static final class Builder implements LayoutElement.Builder {
@NonNull private final Context mContext;
@NonNull private ColorProp mColor = argb(Colors.DEFAULT.getOnPrimary());
- private @TypographyName int mTypographyName = TYPOGRAPHY_DISPLAY1;
+ @TypographyName private int mTypographyName = TYPOGRAPHY_DISPLAY1;
private boolean mItalic = false;
private boolean mUnderline = false;
private boolean mIsScalable = true;
@Nullable private Integer mCustomWeight = null;
@NonNull
- @OptIn(markerClass = ProtoLayoutExperimental.class)
@SuppressWarnings(
"deprecation") // Default value from initial release is TEXT_OVERFLOW_ELLIPSIZE_END
// so we can't change it as it would be a breaking change for developers.
@@ -151,6 +148,9 @@
* Sets whether the text size will change if user has changed the default font size. If not
* set, true will be used.
*/
+ // Text size is always set in SP, however, by setting this field, we do calculation to
+ // interpret it like DP. When getting the text font's size in getters, there is no way to
+ // know whether that size was scaled or not.
Builder setIsScalable(boolean isScalable) {
this.mIsScalable = isScalable;
return this;
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/TitleChip.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/TitleChip.java
index 92140a6..c6fc2be 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/TitleChip.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/TitleChip.java
@@ -31,7 +31,6 @@
import androidx.annotation.Dimension;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.OptIn;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters;
@@ -41,7 +40,6 @@
import androidx.wear.protolayout.ModifiersBuilders.Clickable;
import androidx.wear.protolayout.TypeBuilders.StringProp;
import androidx.wear.protolayout.expression.Fingerprint;
-import androidx.wear.protolayout.expression.ProtoLayoutExperimental;
import androidx.wear.protolayout.proto.LayoutElementProto;
/**
@@ -194,7 +192,6 @@
/** Constructs and returns {@link TitleChip} with the provided content and look. */
@NonNull
@Override
- @OptIn(markerClass = ProtoLayoutExperimental.class)
public TitleChip build() {
Chip.Builder chipBuilder =
new Chip.Builder(mContext, mClickable, mDeviceParameters)
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Typography.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Typography.java
index ed2914b..a297558 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Typography.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Typography.java
@@ -34,6 +34,7 @@
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DimensionBuilders;
import androidx.wear.protolayout.DimensionBuilders.SpProp;
import androidx.wear.protolayout.LayoutElementBuilders.FontStyle;
@@ -83,7 +84,7 @@
/** Typography for small caption text. */
public static final int TYPOGRAPHY_CAPTION3 = 12;
- @RestrictTo(RestrictTo.Scope.LIBRARY)
+ @RestrictTo(Scope.LIBRARY)
@Retention(RetentionPolicy.SOURCE)
@IntDef({
TYPOGRAPHY_DISPLAY1,
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/LayoutDefaults.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/LayoutDefaults.java
index bb68851..7695bc8 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/LayoutDefaults.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/LayoutDefaults.java
@@ -60,7 +60,7 @@
* The default spacer above primary label in {@link PrimaryLayout} to make space for Tile icon
* on round devices.
*/
- static final DpProp PRIMARY_LAYOUT_PRIMARY_LABEL_SPACER_HEIGHT_ROUND_DP = dp(0);
+ @NonNull static final DpProp PRIMARY_LAYOUT_PRIMARY_LABEL_SPACER_HEIGHT_ROUND_DP = dp(0);
/**
* The default percentage for the horizontal padding for primary or secondary label in the
@@ -72,7 +72,7 @@
* The default spacer above primary label in {@link PrimaryLayout} to make space for Tile icon
* on square devices.
*/
- static final DpProp PRIMARY_LAYOUT_PRIMARY_LABEL_SPACER_HEIGHT_SQUARE_DP = dp(4);
+ @NonNull static final DpProp PRIMARY_LAYOUT_PRIMARY_LABEL_SPACER_HEIGHT_SQUARE_DP = dp(4);
/**
* The default percentage for the horizontal margin for primary chip in the {@link
@@ -134,7 +134,8 @@
* <p>It is recommended to use this on smaller screen sizes or when there's a lot of content in
* the layout.
*/
- public static final DpProp EDGE_CONTENT_LAYOUT_CONTENT_AND_SECONDARY_LABEL_SPACING_DP = dp(8);
+ @NonNull public static final DpProp EDGE_CONTENT_LAYOUT_CONTENT_AND_SECONDARY_LABEL_SPACING_DP =
+ dp(8);
/**
* The default spacer width that should be between main content and secondary label if set in
@@ -142,14 +143,14 @@
*
* <p>It is recommended to use this on larger screen sizes (screen sizes above 225dp).
*/
- public static final DpProp EDGE_CONTENT_LAYOUT_LARGE_CONTENT_AND_SECONDARY_LABEL_SPACING_DP =
- dp(12);
+ @NonNull public static final DpProp
+ EDGE_CONTENT_LAYOUT_LARGE_CONTENT_AND_SECONDARY_LABEL_SPACING_DP = dp(12);
/**
* The default spacing below primary label in the {@link EdgeContentLayout} to ensure that inner
* content is not too high up and not near the primary label.
*/
- static final DpProp EDGE_CONTENT_LAYOUT_RESPONSIVE_PRIMARY_LABEL_SPACING_DP = dp(8);
+ @NonNull static final DpProp EDGE_CONTENT_LAYOUT_RESPONSIVE_PRIMARY_LABEL_SPACING_DP = dp(8);
/**
* The recommended padding that should be above the main content (text) in the {@link
@@ -164,10 +165,10 @@
public static final float EDGE_CONTENT_LAYOUT_PADDING_BELOW_MAIN_CONTENT_DP = 8;
/** The default spacer width for slots in a {@link MultiSlotLayout}. */
- public static final DpProp MULTI_SLOT_LAYOUT_HORIZONTAL_SPACER_WIDTH = dp(8);
+ @NonNull public static final DpProp MULTI_SLOT_LAYOUT_HORIZONTAL_SPACER_WIDTH = dp(8);
/** The recommended space between the main content and additional labels in layouts. */
- public static final DpProp DEFAULT_VERTICAL_SPACER_HEIGHT = dp(8);
+ @NonNull public static final DpProp DEFAULT_VERTICAL_SPACER_HEIGHT = dp(8);
/**
* The maximum number of button that can be added to the {@link MultiButtonLayout}.
@@ -188,30 +189,32 @@
* The default size of button in case when there are 3 or more buttons in the {@link
* MultiButtonLayout}.
*/
- public static final DpProp BUTTON_SIZE_FOR_3_PLUS_BUTTONS = ButtonDefaults.DEFAULT_SIZE;
+ @NonNull public static final DpProp BUTTON_SIZE_FOR_3_PLUS_BUTTONS =
+ ButtonDefaults.DEFAULT_SIZE;
/**
* The default size of button in case when there are 2 buttons in the {@link
* MultiButtonLayout}.
*/
- public static final DpProp BUTTON_SIZE_FOR_2_BUTTONS = ButtonDefaults.LARGE_SIZE;
+ @NonNull public static final DpProp BUTTON_SIZE_FOR_2_BUTTONS = ButtonDefaults.LARGE_SIZE;
/**
* The default size of button in case when there is 1 button in the {@link
* MultiButtonLayout}.
*/
- public static final DpProp BUTTON_SIZE_FOR_1_BUTTON = ButtonDefaults.EXTRA_LARGE_SIZE;
+ @NonNull public static final DpProp BUTTON_SIZE_FOR_1_BUTTON =
+ ButtonDefaults.EXTRA_LARGE_SIZE;
/**
* The default width for vertical spacer between buttons in the {@link MultiButtonLayout}.
*/
- static final DpProp SPACER_WIDTH = dp(6);
+ @NonNull static final DpProp SPACER_WIDTH = dp(6);
/**
* The default height for horizontal spacer between buttons in the {@link
* MultiButtonLayout}.
*/
- static final DpProp SPACER_HEIGHT = dp(4);
+ @NonNull static final DpProp SPACER_HEIGHT = dp(4);
}
/** Wraps the given element into a {@link Box} and applies given horizontal padding. */
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/MultiButtonLayout.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/MultiButtonLayout.java
index 3f9f9ff..56d7664 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/MultiButtonLayout.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/MultiButtonLayout.java
@@ -87,6 +87,7 @@
/** Button distribution where the last row has more buttons than other rows. */
public static final int FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY = 2;
+ /** Button distribution values. */
@RestrictTo(Scope.LIBRARY)
@Retention(RetentionPolicy.SOURCE)
@IntDef({FIVE_BUTTON_DISTRIBUTION_TOP_HEAVY, FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY})
@@ -101,7 +102,7 @@
/** Builder class for {@link MultiButtonLayout}. */
public static final class Builder implements LayoutElement.Builder {
@NonNull private final List<LayoutElement> mButtonsContent = new ArrayList<>();
- private @ButtonDistribution int mFiveButtonDistribution =
+ @ButtonDistribution private int mFiveButtonDistribution =
FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY;
/**
diff --git a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ButtonColorsTest.java b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ButtonColorsTest.java
index fcbf8b2..9c95828 100644
--- a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ButtonColorsTest.java
+++ b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ButtonColorsTest.java
@@ -40,9 +40,8 @@
public void testCreateButtonColorsFromArgb() {
ButtonColors buttonColors = new ButtonColors(ARGB_BACKGROUND_COLOR, ARGB_CONTENT_COLOR);
- assertThat(buttonColors.getBackgroundColor().getArgb())
- .isEqualTo(BACKGROUND_COLOR.getArgb());
- assertThat(buttonColors.getContentColor().getArgb()).isEqualTo(CONTENT_COLOR.getArgb());
+ assertThat(buttonColors.getBackgroundColor().getArgb()).isEqualTo(ARGB_BACKGROUND_COLOR);
+ assertThat(buttonColors.getContentColor().getArgb()).isEqualTo(ARGB_CONTENT_COLOR);
}
@Test
diff --git a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ChipColorsTest.java b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ChipColorsTest.java
index 5bf4319..6154fc2 100644
--- a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ChipColorsTest.java
+++ b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ChipColorsTest.java
@@ -44,11 +44,10 @@
public void testCreateChipColorsFromArgb() {
ChipColors chipColors = new ChipColors(ARGB_BACKGROUND_COLOR, ARGB_CONTENT_COLOR);
- assertThat(chipColors.getBackgroundColor().getArgb()).isEqualTo(BACKGROUND_COLOR.getArgb());
- assertThat(chipColors.getIconColor().getArgb()).isEqualTo(CONTENT_COLOR.getArgb());
- assertThat(chipColors.getContentColor().getArgb()).isEqualTo(CONTENT_COLOR.getArgb());
- assertThat(chipColors.getSecondaryContentColor().getArgb())
- .isEqualTo(CONTENT_COLOR.getArgb());
+ assertThat(chipColors.getBackgroundColor().getArgb()).isEqualTo(ARGB_BACKGROUND_COLOR);
+ assertThat(chipColors.getIconColor().getArgb()).isEqualTo(ARGB_CONTENT_COLOR);
+ assertThat(chipColors.getContentColor().getArgb()).isEqualTo(ARGB_CONTENT_COLOR);
+ assertThat(chipColors.getSecondaryContentColor().getArgb()).isEqualTo(ARGB_CONTENT_COLOR);
}
@Test
@@ -71,11 +70,11 @@
ARGB_CONTENT_COLOR,
ARGB_SECONDARY_CONTENT_COLOR);
- assertThat(chipColors.getBackgroundColor().getArgb()).isEqualTo(BACKGROUND_COLOR.getArgb());
- assertThat(chipColors.getIconColor().getArgb()).isEqualTo(ICON_COLOR.getArgb());
- assertThat(chipColors.getContentColor().getArgb()).isEqualTo(CONTENT_COLOR.getArgb());
+ assertThat(chipColors.getBackgroundColor().getArgb()).isEqualTo(ARGB_BACKGROUND_COLOR);
+ assertThat(chipColors.getIconColor().getArgb()).isEqualTo(ARGB_ICON_COLOR);
+ assertThat(chipColors.getContentColor().getArgb()).isEqualTo(ARGB_CONTENT_COLOR);
assertThat(chipColors.getSecondaryContentColor().getArgb())
- .isEqualTo(SECONDARY_CONTENT_COLOR.getArgb());
+ .isEqualTo(ARGB_SECONDARY_CONTENT_COLOR);
}
@Test
diff --git a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ProgressIndicatorColorsTest.java b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ProgressIndicatorColorsTest.java
index 485a4f1..70273a8 100644
--- a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ProgressIndicatorColorsTest.java
+++ b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ProgressIndicatorColorsTest.java
@@ -30,21 +30,21 @@
@RunWith(AndroidJUnit4.class)
@DoNotInstrument
public class ProgressIndicatorColorsTest {
- private static final int ARGB_BACKGROUND_COLOR = 0x12345678;
- private static final int ARGB_CONTENT_COLOR = 0x11223344;
- private static final ColorProp TRACK_COLOR = argb(ARGB_BACKGROUND_COLOR);
- private static final ColorProp INDICATOR_COLOR = argb(ARGB_CONTENT_COLOR);
+ private static final int ARGB_TRACK_COLOR = 0x12345678;
+ private static final int ARGB_INDICATOR_COLOR = 0x11223344;
+ private static final ColorProp TRACK_COLOR = argb(ARGB_TRACK_COLOR);
+ private static final ColorProp INDICATOR_COLOR = argb(ARGB_INDICATOR_COLOR);
private static final Colors COLORS = new Colors(0x123, 0x234, 0x345, 0x456);
@Test
public void testCreateProgressIndicatorColorsFromArgb() {
ProgressIndicatorColors progressIndicatorColors =
- new ProgressIndicatorColors(ARGB_CONTENT_COLOR, ARGB_BACKGROUND_COLOR);
+ new ProgressIndicatorColors(ARGB_INDICATOR_COLOR, ARGB_TRACK_COLOR);
assertThat(progressIndicatorColors.getTrackColor().getArgb())
- .isEqualTo(TRACK_COLOR.getArgb());
+ .isEqualTo(ARGB_TRACK_COLOR);
assertThat(progressIndicatorColors.getIndicatorColor().getArgb())
- .isEqualTo(INDICATOR_COLOR.getArgb());
+ .isEqualTo(ARGB_INDICATOR_COLOR);
}
@Test
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 fbf9866..85fb646 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
@@ -21,6 +21,7 @@
import static androidx.wear.protolayout.LayoutElementBuilders.FONT_WEIGHT_MEDIUM;
import static androidx.wear.protolayout.LayoutElementBuilders.FONT_WEIGHT_NORMAL;
import static androidx.wear.protolayout.LayoutElementBuilders.TEXT_ALIGN_END;
+import static androidx.wear.protolayout.LayoutElementBuilders.TEXT_OVERFLOW_ELLIPSIZE_END;
import static androidx.wear.protolayout.material.Typography.TYPOGRAPHY_BODY1;
import static androidx.wear.protolayout.material.Typography.TYPOGRAPHY_CAPTION2;
import static androidx.wear.protolayout.material.Typography.TYPOGRAPHY_TITLE1;
@@ -48,7 +49,6 @@
import androidx.wear.protolayout.TypeBuilders.StringLayoutConstraint;
import androidx.wear.protolayout.TypeBuilders.StringProp;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicString;
-import androidx.wear.protolayout.expression.ProtoLayoutExperimental;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -128,8 +128,7 @@
}
@Test
- @ProtoLayoutExperimental
- @SuppressWarnings("deprecation")
+ @SuppressWarnings("deprecation") // ELLIPSIZE_END
public void testText() {
String textContent = "Testing text.";
Modifiers modifiers =
@@ -145,7 +144,7 @@
.setUnderline(true)
.setMaxLines(2)
.setModifiers(modifiers)
- .setOverflow(LayoutElementBuilders.TEXT_OVERFLOW_ELLIPSIZE_END)
+ .setOverflow(TEXT_OVERFLOW_ELLIPSIZE_END)
.setMultilineAlignment(TEXT_ALIGN_END)
.setWeight(FONT_WEIGHT_BOLD)
.build();
@@ -199,8 +198,7 @@
assertThat(constraint.getAlignment()).isEqualTo(TEXT_ALIGN_END);
}
- @ProtoLayoutExperimental
- @SuppressWarnings("deprecation")
+ @SuppressWarnings("deprecation") // ELLIPSIZE_END
private void assertTextIsEqual(
Text actualText,
String expectedTextContent,
@@ -210,8 +208,9 @@
assertThat(actualText.getFontStyle().toProto()).isEqualTo(expectedFontStyle.toProto());
assertThat(actualText.getText().getValue()).isEqualTo(expectedTextContent);
assertThat(actualText.getColor().getArgb()).isEqualTo(expectedColor);
+ assertThat(actualText.getModifiers().toProto()).isEqualTo(expectedModifiers.toProto());
assertThat(actualText.getOverflow())
- .isEqualTo(LayoutElementBuilders.TEXT_OVERFLOW_ELLIPSIZE_END);
+ .isEqualTo(TEXT_OVERFLOW_ELLIPSIZE_END);
assertThat(actualText.getMultilineAlignment()).isEqualTo(TEXT_ALIGN_END);
assertThat(actualText.getMaxLines()).isEqualTo(2);
assertThat(actualText.getLineHeight())
diff --git a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/TitleChipTest.java b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/TitleChipTest.java
index 4570ab7..2fac6bb 100644
--- a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/TitleChipTest.java
+++ b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/TitleChipTest.java
@@ -88,7 +88,7 @@
}
@Test
- public void testIconChipIconCustomColor() {
+ public void testTitleChipIconCustomColor() {
String iconId = "icon_id";
TitleChip titleChip =
new TitleChip.Builder(CONTEXT, MAIN_TEXT, CLICKABLE, DEVICE_PARAMETERS)