Skip to content

Commit a0547c6

Browse files
cketchamymarian
authored andcommitted
Rename setCornerRadius to setAllCornerSizes
PiperOrigin-RevId: 272959729 (cherry picked from commit 294f124)
1 parent 6f653a5 commit a0547c6

File tree

10 files changed

+33
-27
lines changed

10 files changed

+33
-27
lines changed

lib/java/com/google/android/material/badge/BadgeDrawable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ private void updateCenterAndBounds() {
676676

677677
updateBadgeBounds(badgeBounds, badgeCenterX, badgeCenterY, halfBadgeWidth, halfBadgeHeight);
678678

679-
shapeDrawable.setCornerRadius(cornerRadius);
679+
shapeDrawable.setCornerSize(cornerRadius);
680680
if (!tmpRect.equals(badgeBounds)) {
681681
shapeDrawable.setBounds(badgeBounds);
682682
}

lib/java/com/google/android/material/button/MaterialButtonHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void loadFromAttributes(@NonNull TypedArray attributes) {
8888
// cornerRadius should override whatever corner radius is set in shapeAppearanceModel
8989
if (attributes.hasValue(R.styleable.MaterialButton_cornerRadius)) {
9090
cornerRadius = attributes.getDimensionPixelSize(R.styleable.MaterialButton_cornerRadius, -1);
91-
setShapeAppearanceModel(shapeAppearanceModel.withCornerRadius(cornerRadius));
91+
setShapeAppearanceModel(shapeAppearanceModel.withCornerSize(cornerRadius));
9292
cornerRadiusSet = true;
9393
}
9494

@@ -307,7 +307,7 @@ void setCornerRadius(int cornerRadius) {
307307
this.cornerRadius = cornerRadius;
308308
cornerRadiusSet = true;
309309

310-
setShapeAppearanceModel(shapeAppearanceModel.withCornerRadius(cornerRadius));
310+
setShapeAppearanceModel(shapeAppearanceModel.withCornerSize(cornerRadius));
311311
}
312312
}
313313

lib/java/com/google/android/material/button/MaterialButtonToggleGroup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ private void updateChildShapes() {
499499
.setBottomLeftCornerSize(cornerData.bottomLeft);
500500
} else if (i != 0 && i < numChildren - 1) {
501501
// Sets corner radii of all middle children to 0
502-
shapeAppearanceModelBuilder.setCornerRadius(0);
502+
shapeAppearanceModelBuilder.setAllCornerSizes(0);
503503
} else if (i == (ViewUtils.isLayoutRtl(this) ? 0 : (numChildren - 1))) {
504504
// Keeps the right corners of the last child in LTR, or the first child in RTL
505505
shapeAppearanceModelBuilder

lib/java/com/google/android/material/card/MaterialCardViewHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public MaterialCardViewHelper(
133133
.obtainStyledAttributes(attrs, R.styleable.CardView, defStyleAttr, R.style.CardView);
134134
if (cardViewAttributes.hasValue(R.styleable.CardView_cardCornerRadius)) {
135135
// If cardCornerRadius is set, let it override the shape appearance.
136-
shapeAppearanceModelBuilder.setCornerRadius(
136+
shapeAppearanceModelBuilder.setAllCornerSizes(
137137
cardViewAttributes.getDimension(R.styleable.CardView_cardCornerRadius, 0));
138138
}
139139

@@ -267,7 +267,7 @@ void updateClickable() {
267267
}
268268

269269
void setCornerRadius(float cornerRadius) {
270-
setShapeAppearanceModel(shapeAppearanceModel.withCornerRadius(cornerRadius));
270+
setShapeAppearanceModel(shapeAppearanceModel.withCornerSize(cornerRadius));
271271
fgDrawable.invalidateSelf();
272272
if (shouldAddCornerPaddingOutsideCardBackground()
273273
|| shouldAddCornerPaddingInsideCardBackground()) {

lib/java/com/google/android/material/chip/Chip.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ public float getChipCornerRadius() {
11431143
}
11441144

11451145
/**
1146-
* @deprecated call {@link ShapeAppearanceModel#withCornerRadius()} or call {@link
1146+
* @deprecated call {@link ShapeAppearanceModel#withCornerSize()} or call {@link
11471147
* ShapeAppearanceModel#toBuilder()} on the {@link #getShapeAppearanceModel()}, modify the
11481148
* shape using the builder and then call {@link
11491149
* #setShapeAppearanceModel(ShapeAppearanceModel)}.
@@ -1167,7 +1167,7 @@ public ShapeAppearanceModel getShapeAppearanceModel() {
11671167
}
11681168

11691169
/**
1170-
* @deprecated call {@link ShapeAppearanceModel#withCornerRadius()} or call {@link
1170+
* @deprecated call {@link ShapeAppearanceModel#withCornerSize()} or call {@link
11711171
* ShapeAppearanceModel#toBuilder()} on the {@link #getShapeAppearanceModel()}, modify the
11721172
* shape using the builder and then call {@link
11731173
* #setShapeAppearanceModel(ShapeAppearanceModel)}.

lib/java/com/google/android/material/chip/ChipDrawable.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ public float getChipCornerRadius() {
14101410
}
14111411

14121412
/**
1413-
* @deprecated call {@link ShapeAppearanceModel#withCornerRadius()} or call {@link
1413+
* @deprecated call {@link ShapeAppearanceModel#withCornerSize()} or call {@link
14141414
* ShapeAppearanceModel#toBuilder()} on the {@link #getShapeAppearanceModel()}, modify the
14151415
* shape using the builder and then call {@link
14161416
* #setShapeAppearanceModel(ShapeAppearanceModel)}.
@@ -1421,7 +1421,7 @@ public void setChipCornerRadiusResource(@DimenRes int id) {
14211421
}
14221422

14231423
/**
1424-
* @deprecated call {@link ShapeAppearanceModel#withCornerRadius()} or call {@link
1424+
* @deprecated call {@link ShapeAppearanceModel#withCornerSize()} or call {@link
14251425
* ShapeAppearanceModel#toBuilder()} on the {@link #getShapeAppearanceModel()}, modify the
14261426
* shape using the builder and then call {@link
14271427
* #setShapeAppearanceModel(ShapeAppearanceModel)}.
@@ -1431,7 +1431,7 @@ public void setChipCornerRadius(float chipCornerRadius) {
14311431
if (this.chipCornerRadius != chipCornerRadius) {
14321432
this.chipCornerRadius = chipCornerRadius;
14331433

1434-
setShapeAppearanceModel(getShapeAppearanceModel().withCornerRadius(chipCornerRadius));
1434+
setShapeAppearanceModel(getShapeAppearanceModel().withCornerSize(chipCornerRadius));
14351435
}
14361436
}
14371437

lib/java/com/google/android/material/dialog/MaterialAlertDialogBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public MaterialAlertDialogBuilder(Context context, int overrideThemeResId) {
130130
float dialogCornerRadius =
131131
dialogCornerRadiusValue.getDimension(getContext().getResources().getDisplayMetrics());
132132
if (dialogCornerRadiusValue.type == TypedValue.TYPE_DIMENSION && dialogCornerRadius >= 0) {
133-
materialShapeDrawable.setCornerRadius(dialogCornerRadius);
133+
materialShapeDrawable.setCornerSize(dialogCornerRadius);
134134
}
135135
}
136136
background = materialShapeDrawable;

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,14 @@ protected RectF getBoundsAsRectF() {
459459
return rectF;
460460
}
461461

462-
public void setCornerRadius(float cornerRadius) {
463-
setShapeAppearanceModel(drawableState.shapeAppearanceModel.withCornerRadius(cornerRadius));
462+
/** Updates the corners for the given {@link cornerSize}. */
463+
public void setCornerSize(float cornerSize) {
464+
setShapeAppearanceModel(drawableState.shapeAppearanceModel.withCornerSize(cornerSize));
465+
}
466+
467+
/** Updates the corners for the given {@link cornerSize}. */
468+
public void setCornerSize(@NonNull CornerSize cornerSize) {
469+
setShapeAppearanceModel(drawableState.shapeAppearanceModel.withCornerSize(cornerSize));
464470
}
465471

466472
/**

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public Builder(@NonNull ShapeAppearanceModel other) {
9696
@NonNull
9797
public Builder setAllCorners(@CornerFamily int cornerFamily, @Dimension float cornerSize) {
9898
return setAllCorners(MaterialShapeUtils.createCornerTreatment(cornerFamily))
99-
.setCornerRadius(cornerSize);
99+
.setAllCornerSizes(cornerSize);
100100
}
101101

102102
/**
@@ -125,13 +125,13 @@ public Builder setAllCornerSizes(@NonNull CornerSize cornerSize) {
125125
.setBottomLeftCornerSize(cornerSize);
126126
}
127127

128-
/** Sets the corner size of all four corner treatments to {@code cornerRadius}. */
128+
/** Sets the corner size of all four corner treatments to {@code cornerSize}. */
129129
@NonNull
130-
public Builder setCornerRadius(@Dimension float cornerRadius) {
131-
return setTopLeftCornerSize(cornerRadius)
132-
.setTopRightCornerSize(cornerRadius)
133-
.setBottomRightCornerSize(cornerRadius)
134-
.setBottomLeftCornerSize(cornerRadius);
130+
public Builder setAllCornerSizes(@Dimension float cornerSize) {
131+
return setTopLeftCornerSize(cornerSize)
132+
.setTopRightCornerSize(cornerSize)
133+
.setBottomRightCornerSize(cornerSize)
134+
.setBottomLeftCornerSize(cornerSize);
135135
}
136136

137137
/** Sets the top left corner size for the current corner. */
@@ -561,7 +561,7 @@ private static CornerSize getCornerSize(
561561
}
562562
}
563563

564-
// Constant corner radius value to indicate that shape should use 50% height corner radii
564+
// Constant corner size value to indicate that shape should use 50% height corner radii
565565
public static final CornerSize PILL = new RelativeCornerSize(0.5f);
566566

567567
CornerTreatment topLeftCorner;
@@ -740,11 +740,11 @@ public Builder toBuilder() {
740740

741741
/**
742742
* Returns a copy of this {@link ShapeAppearanceModel} with the same edges and corners, but with
743-
* the corner radius for all corners updated.
743+
* the corner size for all corners updated.
744744
*/
745745
@NonNull
746-
public ShapeAppearanceModel withCornerRadius(float cornerRadius) {
747-
return toBuilder().setCornerRadius(cornerRadius).build();
746+
public ShapeAppearanceModel withCornerSize(float cornerSize) {
747+
return toBuilder().setAllCornerSizes(cornerSize).build();
748748
}
749749

750750
@NonNull
@@ -765,7 +765,7 @@ public interface CornerSizeUnaryOperator {
765765

766766
/**
767767
* Returns a copy of this {@link ShapeAppearanceModel} with the same edges and corners, but with
768-
* the corner radius for all corners converted by a {@link CornerSizeUnaryOperator}.
768+
* the corner size for all corners converted by a {@link CornerSizeUnaryOperator}.
769769
*
770770
* @hide
771771
*/

lib/javatests/com/google/android/material/button/MaterialButtonTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void themeApplicationContext() {
5858
public void testSetShapeAppearanceModel_setCornerRadius() {
5959
MaterialButton materialButton = new MaterialButton(context);
6060
ShapeAppearanceModel shapeAppearanceModel =
61-
ShapeAppearanceModel.builder().setCornerRadius(LARGE_CORNER_SIZE).build();
61+
ShapeAppearanceModel.builder().setAllCornerSizes(LARGE_CORNER_SIZE).build();
6262

6363
materialButton.setShapeAppearanceModel(shapeAppearanceModel);
6464

0 commit comments

Comments
 (0)