|
16 | 16 |
|
17 | 17 | package com.google.android.material.button; |
18 | 18 |
|
19 | | -import com.google.android.material.R; |
20 | | - |
21 | | -import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP; |
22 | | - |
23 | 19 | import android.content.Context; |
24 | 20 | import android.content.res.ColorStateList; |
25 | 21 | import android.content.res.TypedArray; |
|
31 | 27 | import android.graphics.drawable.RippleDrawable; |
32 | 28 | import android.os.Build.VERSION; |
33 | 29 | import android.os.Build.VERSION_CODES; |
34 | | -import androidx.core.graphics.drawable.DrawableCompat; |
35 | | -import androidx.core.view.ViewCompat; |
| 30 | + |
36 | 31 | import androidx.annotation.Dimension; |
37 | 32 | import androidx.annotation.NonNull; |
38 | 33 | import androidx.annotation.Nullable; |
39 | 34 | import androidx.annotation.RestrictTo; |
| 35 | +import androidx.core.graphics.drawable.DrawableCompat; |
| 36 | +import androidx.core.view.ViewCompat; |
| 37 | + |
| 38 | +import com.google.android.material.R; |
40 | 39 | import com.google.android.material.color.MaterialColors; |
41 | 40 | import com.google.android.material.internal.ViewUtils; |
42 | 41 | import com.google.android.material.resources.MaterialResources; |
|
46 | 45 | import com.google.android.material.shape.ShapeAppearanceModel; |
47 | 46 | import com.google.android.material.shape.Shapeable; |
48 | 47 |
|
| 48 | +import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP; |
| 49 | + |
49 | 50 | /** @hide */ |
50 | 51 | @RestrictTo(LIBRARY_GROUP) |
51 | 52 | class MaterialButtonHelper { |
@@ -359,14 +360,20 @@ private MaterialShapeDrawable getSurfaceColorStrokeDrawable() { |
359 | 360 | } |
360 | 361 |
|
361 | 362 | private void updateButtonShape(@NonNull ShapeAppearanceModel shapeAppearanceModel) { |
362 | | - if (getMaterialShapeDrawable() != null) { |
363 | | - getMaterialShapeDrawable().setShapeAppearanceModel(shapeAppearanceModel); |
364 | | - } |
365 | | - if (getSurfaceColorStrokeDrawable() != null) { |
366 | | - getSurfaceColorStrokeDrawable().setShapeAppearanceModel(shapeAppearanceModel); |
367 | | - } |
368 | | - if (getMaskDrawable() != null) { |
369 | | - getMaskDrawable().setShapeAppearanceModel(shapeAppearanceModel); |
| 363 | + if (IS_LOLLIPOP) { |
| 364 | + // There seems to be a bug to drawables that is affecting Lollipop, since invalidation is not |
| 365 | + // changing an existing drawable shape. This is a fallback |
| 366 | + updateBackground(); |
| 367 | + } else { |
| 368 | + if (getMaterialShapeDrawable() != null) { |
| 369 | + getMaterialShapeDrawable().setShapeAppearanceModel(shapeAppearanceModel); |
| 370 | + } |
| 371 | + if (getSurfaceColorStrokeDrawable() != null) { |
| 372 | + getSurfaceColorStrokeDrawable().setShapeAppearanceModel(shapeAppearanceModel); |
| 373 | + } |
| 374 | + if (getMaskDrawable() != null) { |
| 375 | + getMaskDrawable().setShapeAppearanceModel(shapeAppearanceModel); |
| 376 | + } |
370 | 377 | } |
371 | 378 | } |
372 | 379 |
|
|
0 commit comments