Small updates to Button & Chip
Update/Remove SuppressWarning for missing getter.
Bug: N/A
Test: N/A
Relnote: "Small updates."
Change-Id: Ibf3d13c1223da534072bd0d7bea7eaa9d9c4a7ea
diff --git a/wear/tiles/tiles-material/api/current.txt b/wear/tiles/tiles-material/api/current.txt
index ea063a6..92156c6 100644
--- a/wear/tiles/tiles-material/api/current.txt
+++ b/wear/tiles/tiles-material/api/current.txt
@@ -62,7 +62,7 @@
method public androidx.wear.tiles.material.Chip.Builder setPrimaryTextLabelContent(String, String);
method public androidx.wear.tiles.material.Chip.Builder setPrimaryTextLabelIconContent(String, String, String);
method public androidx.wear.tiles.material.Chip.Builder setWidth(androidx.wear.tiles.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.material.Chip.Builder setWidth(@Dimension(unit=androidx.annotation.Dimension.DP) int);
+ method public androidx.wear.tiles.material.Chip.Builder setWidth(@Dimension(unit=androidx.annotation.Dimension.DP) float);
}
public class ChipColors {
diff --git a/wear/tiles/tiles-material/api/public_plus_experimental_current.txt b/wear/tiles/tiles-material/api/public_plus_experimental_current.txt
index ea063a6..92156c6 100644
--- a/wear/tiles/tiles-material/api/public_plus_experimental_current.txt
+++ b/wear/tiles/tiles-material/api/public_plus_experimental_current.txt
@@ -62,7 +62,7 @@
method public androidx.wear.tiles.material.Chip.Builder setPrimaryTextLabelContent(String, String);
method public androidx.wear.tiles.material.Chip.Builder setPrimaryTextLabelIconContent(String, String, String);
method public androidx.wear.tiles.material.Chip.Builder setWidth(androidx.wear.tiles.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.material.Chip.Builder setWidth(@Dimension(unit=androidx.annotation.Dimension.DP) int);
+ method public androidx.wear.tiles.material.Chip.Builder setWidth(@Dimension(unit=androidx.annotation.Dimension.DP) float);
}
public class ChipColors {
diff --git a/wear/tiles/tiles-material/api/restricted_current.txt b/wear/tiles/tiles-material/api/restricted_current.txt
index ea063a6..92156c6 100644
--- a/wear/tiles/tiles-material/api/restricted_current.txt
+++ b/wear/tiles/tiles-material/api/restricted_current.txt
@@ -62,7 +62,7 @@
method public androidx.wear.tiles.material.Chip.Builder setPrimaryTextLabelContent(String, String);
method public androidx.wear.tiles.material.Chip.Builder setPrimaryTextLabelIconContent(String, String, String);
method public androidx.wear.tiles.material.Chip.Builder setWidth(androidx.wear.tiles.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.material.Chip.Builder setWidth(@Dimension(unit=androidx.annotation.Dimension.DP) int);
+ method public androidx.wear.tiles.material.Chip.Builder setWidth(@Dimension(unit=androidx.annotation.Dimension.DP) float);
}
public class ChipColors {
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Button.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Button.java
index 1e8f862..e2ff6c7 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Button.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Button.java
@@ -159,7 +159,6 @@
* ButtonDefaults#PRIMARY_BUTTON_COLORS} will be used.
*/
@NonNull
- @SuppressWarnings("MissingGetterMatchingBuilder")
public Builder setButtonColors(@NonNull ButtonColors buttonColors) {
mButtonColors = buttonColors;
return this;
@@ -183,7 +182,7 @@
* channel and not an actual image.
*/
@NonNull
- @SuppressWarnings("MissingGetterMatchingBuilder")
+ @SuppressWarnings("MissingGetterMatchingBuilder") // There's getContent() method.
public Builder setIconContent(@NonNull String resourceId, @NonNull DpProp size) {
resetContent();
this.mIcon = resourceId;
@@ -200,7 +199,7 @@
* should be image with chosen alpha channel and not an actual image.
*/
@NonNull
- @SuppressWarnings("MissingGetterMatchingBuilder")
+ @SuppressWarnings("MissingGetterMatchingBuilder") // There's getContent() method.
public Builder setIconContent(@NonNull String resourceId) {
resetContent();
this.mIcon = resourceId;
@@ -218,7 +217,7 @@
* more than 3 characters, otherwise it will overflow from the edges.
*/
@NonNull
- @SuppressWarnings("MissingGetterMatchingBuilder")
+ @SuppressWarnings("MissingGetterMatchingBuilder") // There's getContent() method.
public Builder setTextContent(
@NonNull String text, @NonNull DeviceParameters deviceParameters) {
resetContent();
@@ -230,12 +229,14 @@
}
/**
- * Sets the content of this Button to be the given text with the given font. You should add
- * chosen color to your font. Any previously added content will be overridden. Text should
- * contain no more than 3 characters, otherwise it will overflow from the edges.
+ * Sets the content of this Button to be the given text with the given font. You shouldn't
+ * add color to your font as it will be overridden by the {@link
+ * ButtonColors#getContentColor}. Only {@link #setButtonColors} should be used for
+ * customizing the colors of the button. Any previously added content will be overridden.
+ * Text should contain no more than 3 characters, otherwise it will overflow from the edges.
*/
@NonNull
- @SuppressWarnings("MissingGetterMatchingBuilder")
+ @SuppressWarnings("MissingGetterMatchingBuilder") // There's getContent() method.
public Builder setTextContent(@NonNull String text, @NonNull FontStyle font) {
resetContent();
this.mText = text;
@@ -252,7 +253,7 @@
* image with chosen alpha channel and not an actual image.
*/
@NonNull
- @SuppressWarnings("MissingGetterMatchingBuilder")
+ @SuppressWarnings("MissingGetterMatchingBuilder") // There's getContent() method.
public Builder setImageContent(@NonNull String resourceId) {
resetContent();
this.mImage = resourceId;
@@ -316,7 +317,8 @@
case ICON:
{
DpProp iconSize =
- mDefaultSize ? ButtonDefaults.recommendedIconSize(mSize)
+ mDefaultSize
+ ? ButtonDefaults.recommendedIconSize(mSize)
: checkNotNull(mIconSize);
mContent =
new Image.Builder()
@@ -338,7 +340,10 @@
fontStyle =
FontStyle.fromProto(
mFontStyle.toProto().toBuilder()
- .setColor(mButtonColors.getContentColor().toProto())
+ .setColor(
+ mButtonColors
+ .getContentColor()
+ .toProto())
.build());
} else {
fontStyle =
@@ -347,10 +352,11 @@
.build();
}
- mContent = new Text.Builder()
- .setText(checkNotNull(mText))
- .setMaxLines(1)
- .setFontStyle(fontStyle);
+ mContent =
+ new Text.Builder()
+ .setText(checkNotNull(mText))
+ .setMaxLines(1)
+ .setFontStyle(fontStyle);
return mContent.build();
}
@@ -457,8 +463,7 @@
case Builder.ICON:
contentColor =
checkNotNull(
- checkNotNull(((Image) mainElement).getColorFilter()).getTint()
- );
+ checkNotNull(((Image) mainElement).getColorFilter()).getTint());
break;
case Builder.TEXT:
contentColor =
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Chip.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Chip.java
index 4c76b5f..9b7102e 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Chip.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Chip.java
@@ -157,7 +157,7 @@
* by {@link ChipDefaults#DEFAULT_MARGIN_PERCENT}.
*/
@NonNull
- public Builder setWidth(@Dimension(unit = DP) int width) {
+ public Builder setWidth(@Dimension(unit = DP) float width) {
mWidth = dp(width);
return this;
}
@@ -188,7 +188,7 @@
* content will be overridden. Primary text can be on 1 or 2 lines, depending on the length.
*/
@NonNull
- @SuppressWarnings("MissingGetterMatchingBuilder")
+ @SuppressWarnings("MissingGetterMatchingBuilder") // There's getContent() method.
public Builder setPrimaryTextContent(@NonNull String primaryText) {
this.mPrimaryText = primaryText;
this.mLabelText = null;
@@ -204,7 +204,6 @@
* length.
*/
@NonNull
- @SuppressWarnings("MissingGetterMatchingBuilder")
Builder setPrimaryTextFontStyle(@NonNull FontStyle fontStyle) {
this.mPrimaryTextFont = fontStyle;
return this;
@@ -216,7 +215,7 @@
* only. This content will be left aligned inside the chip.
*/
@NonNull
- @SuppressWarnings("MissingGetterMatchingBuilder")
+ @SuppressWarnings("MissingGetterMatchingBuilder") // There's getContent() method.
public Builder setPrimaryTextLabelContent(
@NonNull String primaryText, @NonNull String label) {
this.mPrimaryText = primaryText;
@@ -251,7 +250,7 @@
* will be left-aligned inside the chip.
*/
@NonNull
- @SuppressWarnings("MissingGetterMatchingBuilder")
+ @SuppressWarnings("MissingGetterMatchingBuilder") // There's getContent() method.
public Builder setPrimaryTextLabelIconContent(
@NonNull String primaryText, @NonNull String label, @NonNull String resourceId) {
this.mPrimaryText = primaryText;
@@ -261,7 +260,6 @@
return this;
}
- // TODO(b/210846270): Add getChipColors.
/**
* Sets the colors for the {@link Chip}. If set, {@link ChipColors#getBackgroundColor()}
* will be used for the background of the button, {@link ChipColors#getContentColor()} for
@@ -270,7 +268,6 @@
* set, {@link ChipDefaults#PRIMARY} will be used.
*/
@NonNull
- @SuppressWarnings("MissingGetterMatchingBuilder")
public Builder setChipColors(@NonNull ChipColors chipColors) {
mChipColors = chipColors;
return this;
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ChipColors.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ChipColors.java
index ea7d70c..dc20ec5 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ChipColors.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ChipColors.java
@@ -112,7 +112,7 @@
return mBackgroundColor;
}
- /** The tint color to be used on a chip Tiles components. */
+ /** The icon tint color to be used on a chip Tiles components. */
@NonNull
public ColorProp getIconTintColor() {
return mIconTintColor;
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/CompactChip.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/CompactChip.java
index 3462c3c..04d5487 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/CompactChip.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/CompactChip.java
@@ -86,7 +86,6 @@
* ChipDefaults#COMPACT_PRIMARY} will be used.
*/
@NonNull
- @SuppressWarnings("MissingGetterMatchingBuilder")
public Builder setChipColors(@NonNull ChipColors chipColors) {
mChipColors = chipColors;
return this;
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/TitleChip.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/TitleChip.java
index 367356a..e13e83f 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/TitleChip.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/TitleChip.java
@@ -96,7 +96,6 @@
* ChipDefaults#LARGE_PRIMARY} will be used.
*/
@NonNull
- @SuppressWarnings("MissingGetterMatchingBuilder")
public Builder setChipColors(@NonNull ChipColors chipColors) {
mChipColors = chipColors;
return this;