Skip to content

Commit b8da637

Browse files
cketchamdsn5ft
authored andcommitted
Update corner size for builder to use floats
PiperOrigin-RevId: 271428842
1 parent 310068c commit b8da637

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

lib/java/com/google/android/material/shape/MaterialShapeUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.android.material.shape;
1818

1919
import android.graphics.drawable.Drawable;
20+
import androidx.annotation.Dimension;
2021
import androidx.annotation.NonNull;
2122
import android.view.View;
2223
import com.google.android.material.internal.ViewUtils;
@@ -27,7 +28,8 @@ public class MaterialShapeUtils {
2728
private MaterialShapeUtils() {}
2829

2930
@NonNull
30-
static CornerTreatment createCornerTreatment(@CornerFamily int cornerFamily, int cornerSize) {
31+
static CornerTreatment createCornerTreatment(
32+
@CornerFamily int cornerFamily, @Dimension float cornerSize) {
3133
switch (cornerFamily) {
3234
case CornerFamily.ROUNDED:
3335
return new RoundedCornerTreatment(cornerSize);

lib/java/com/google/android/material/shape/ShapeAppearanceModel.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public Builder(@NonNull ShapeAppearanceModel other) {
8383
* corners.
8484
*/
8585
@NonNull
86-
public Builder setAllCorners(@CornerFamily int cornerFamily, @Dimension int cornerSize) {
86+
public Builder setAllCorners(@CornerFamily int cornerFamily, @Dimension float cornerSize) {
8787
return setAllCorners(MaterialShapeUtils.createCornerTreatment(cornerFamily, cornerSize));
8888
}
8989

@@ -108,7 +108,7 @@ public Builder setAllCorners(@NonNull CornerTreatment cornerTreatment) {
108108
* something like {@link #setAllCorners(CornerTreatment)} is called after it.
109109
*/
110110
@NonNull
111-
public Builder setCornerRadius(float cornerRadius) {
111+
public Builder setCornerRadius(@Dimension float cornerRadius) {
112112
return setTopLeftCornerSize(cornerRadius)
113113
.setTopRightCornerSize(cornerRadius)
114114
.setBottomRightCornerSize(cornerRadius)
@@ -123,7 +123,7 @@ public Builder setCornerRadius(float cornerRadius) {
123123
* something like {@link #setTopLeftCorner(CornerTreatment)} is called after it.
124124
*/
125125
@NonNull
126-
public Builder setTopLeftCornerSize(float topLeftCornerSize) {
126+
public Builder setTopLeftCornerSize(@Dimension float topLeftCornerSize) {
127127
topLeftCorner = withSizeAndCornerClassCheck(topLeftCorner, topLeftCornerSize);
128128
return this;
129129
}
@@ -136,7 +136,7 @@ public Builder setTopLeftCornerSize(float topLeftCornerSize) {
136136
* something like {@link #setTopRightCorner(CornerTreatment)} is called after it.
137137
*/
138138
@NonNull
139-
public Builder setTopRightCornerSize(float topRightCornerSize) {
139+
public Builder setTopRightCornerSize(@Dimension float topRightCornerSize) {
140140
topRightCorner = withSizeAndCornerClassCheck(topRightCorner, topRightCornerSize);
141141
return this;
142142
}
@@ -149,7 +149,7 @@ public Builder setTopRightCornerSize(float topRightCornerSize) {
149149
* something like {@link #setBottomRightCorner(CornerTreatment)} is called after it.
150150
*/
151151
@NonNull
152-
public Builder setBottomRightCornerSize(float bottomRightCornerSize) {
152+
public Builder setBottomRightCornerSize(@Dimension float bottomRightCornerSize) {
153153
bottomRightCorner =
154154
withSizeAndCornerClassCheck(bottomRightCorner, bottomRightCornerSize);
155155
return this;
@@ -163,7 +163,7 @@ public Builder setBottomRightCornerSize(float bottomRightCornerSize) {
163163
* something like {@link #setBottomLeftCorner(CornerTreatment)} is called after it.
164164
*/
165165
@NonNull
166-
public Builder setBottomLeftCornerSize(float bottomLeftCornerSize) {
166+
public Builder setBottomLeftCornerSize(@Dimension float bottomLeftCornerSize) {
167167
bottomLeftCorner = withSizeAndCornerClassCheck(bottomLeftCorner, bottomLeftCornerSize);
168168
return this;
169169
}
@@ -175,7 +175,7 @@ public Builder setBottomLeftCornerSize(float bottomLeftCornerSize) {
175175
* @param cornerSize the size to use to create the corner treatment
176176
*/
177177
@NonNull
178-
public Builder setTopLeftCorner(@CornerFamily int cornerFamily, @Dimension int cornerSize) {
178+
public Builder setTopLeftCorner(@CornerFamily int cornerFamily, @Dimension float cornerSize) {
179179
return setTopLeftCorner(MaterialShapeUtils.createCornerTreatment(cornerFamily, cornerSize));
180180
}
181181

@@ -197,7 +197,7 @@ public Builder setTopLeftCorner(@NonNull CornerTreatment topLeftCorner) {
197197
* @param cornerSize the size to use to create the corner treatment
198198
*/
199199
@NonNull
200-
public Builder setTopRightCorner(@CornerFamily int cornerFamily, @Dimension int cornerSize) {
200+
public Builder setTopRightCorner(@CornerFamily int cornerFamily, @Dimension float cornerSize) {
201201
return setTopRightCorner(MaterialShapeUtils.createCornerTreatment(cornerFamily, cornerSize));
202202
}
203203

@@ -219,7 +219,8 @@ public Builder setTopRightCorner(@NonNull CornerTreatment topRightCorner) {
219219
* @param cornerSize the size to use to create the corner treatment
220220
*/
221221
@NonNull
222-
public Builder setBottomRightCorner(@CornerFamily int cornerFamily, @Dimension int cornerSize) {
222+
public Builder setBottomRightCorner(
223+
@CornerFamily int cornerFamily, @Dimension float cornerSize) {
223224
return setBottomRightCorner(
224225
MaterialShapeUtils.createCornerTreatment(cornerFamily, cornerSize));
225226
}
@@ -242,7 +243,8 @@ public Builder setBottomRightCorner(@NonNull CornerTreatment bottomRightCorner)
242243
* @param cornerSize the size to use to create the corner treatment
243244
*/
244245
@NonNull
245-
public Builder setBottomLeftCorner(@CornerFamily int cornerFamily, @Dimension int cornerSize) {
246+
public Builder setBottomLeftCorner(
247+
@CornerFamily int cornerFamily, @Dimension float cornerSize) {
246248
return setBottomLeftCorner(
247249
MaterialShapeUtils.createCornerTreatment(cornerFamily, cornerSize));
248250
}
@@ -317,7 +319,7 @@ public Builder setBottomEdge(@NonNull EdgeTreatment bottomEdge) {
317319

318320
/** Adjusts all the corners by the offset. */
319321
@NonNull
320-
public Builder adjustCorners(float offset) {
322+
public Builder adjustCorners(@Dimension float offset) {
321323
return setTopLeftCornerSize(getOffsetCornerSize(topLeftCorner, offset))
322324
.setTopRightCornerSize(getOffsetCornerSize(topRightCorner, offset))
323325
.setBottomRightCornerSize(getOffsetCornerSize(bottomRightCorner, offset))

0 commit comments

Comments
 (0)