Skip to content

Commit a48a9af

Browse files
gsajithdsn5ft
authored andcommitted
Shape system changes for MaterialButton
PiperOrigin-RevId: 225050954
1 parent 734670d commit a48a9af

File tree

5 files changed

+136
-274
lines changed

5 files changed

+136
-274
lines changed

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import android.content.Context;
2525
import android.content.res.ColorStateList;
2626
import android.content.res.TypedArray;
27-
import android.graphics.Canvas;
2827
import android.graphics.Paint;
2928
import android.graphics.PorterDuff;
3029
import android.graphics.PorterDuff.Mode;
@@ -42,6 +41,7 @@
4241
import com.google.android.material.internal.ThemeEnforcement;
4342
import com.google.android.material.internal.ViewUtils;
4443
import com.google.android.material.resources.MaterialResources;
44+
import com.google.android.material.shape.ShapeAppearanceModel;
4545
import android.support.v4.graphics.drawable.DrawableCompat;
4646
import android.support.v4.view.ViewCompat;
4747
import android.support.v4.widget.TextViewCompat;
@@ -156,9 +156,11 @@ public MaterialButton(Context context, AttributeSet attrs, int defStyleAttr) {
156156
iconGravity = attributes.getInteger(R.styleable.MaterialButton_iconGravity, ICON_GRAVITY_START);
157157

158158
iconSize = attributes.getDimensionPixelSize(R.styleable.MaterialButton_iconSize, 0);
159+
ShapeAppearanceModel shapeAppearanceModel =
160+
new ShapeAppearanceModel(context, attrs, defStyleAttr, DEF_STYLE_RES);
159161

160162
// Loads and sets background drawable attributes
161-
materialButtonHelper = new MaterialButtonHelper(this);
163+
materialButtonHelper = new MaterialButtonHelper(this, shapeAppearanceModel);
162164
materialButtonHelper.loadFromAttributes(attributes);
163165

164166
attributes.recycle();
@@ -167,15 +169,6 @@ public MaterialButton(Context context, AttributeSet attrs, int defStyleAttr) {
167169
updateIcon();
168170
}
169171

170-
@Override
171-
protected void onDraw(Canvas canvas) {
172-
super.onDraw(canvas);
173-
// Manually draw stroke on top of background for Kit Kat (API 19) and earlier versions
174-
if (VERSION.SDK_INT < VERSION_CODES.LOLLIPOP && isUsingOriginalBackground()) {
175-
materialButtonHelper.drawStroke(canvas);
176-
}
177-
}
178-
179172
/**
180173
* This should be accessed via {@link
181174
* android.support.v4.view.ViewCompat#setBackgroundTintList(android.view.View, ColorStateList)}
@@ -187,7 +180,7 @@ protected void onDraw(Canvas canvas) {
187180
public void setSupportBackgroundTintList(@Nullable ColorStateList tint) {
188181
if (isUsingOriginalBackground()) {
189182
materialButtonHelper.setSupportBackgroundTintList(tint);
190-
} else if (materialButtonHelper != null) {
183+
} else {
191184
// If default MaterialButton background has been overwritten, we will let AppCompatButton
192185
// handle the tinting
193186
super.setSupportBackgroundTintList(tint);
@@ -225,7 +218,7 @@ public ColorStateList getSupportBackgroundTintList() {
225218
public void setSupportBackgroundTintMode(@Nullable PorterDuff.Mode tintMode) {
226219
if (isUsingOriginalBackground()) {
227220
materialButtonHelper.setSupportBackgroundTintMode(tintMode);
228-
} else if (materialButtonHelper != null) {
221+
} else {
229222
// If default MaterialButton background has been overwritten, we will let AppCompatButton
230223
// handle the tint Mode
231224
super.setSupportBackgroundTintMode(tintMode);

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

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)