Skip to content

Conversation

@vicmns
Copy link
Contributor

@vicmns vicmns commented Aug 14, 2021

[Android Lollipop][Buttons] Fallback when updating drawable shapes. (closes #1797)

Changing a button shape in Lollipop doesn't affect the view ripple drawable, which overflows the background drawable:

This change introduces a fallback only for Lollipop, in which we recreate the background drawable when the shape changes (As it is currently done when changing the drawable insets):

@google-cla
Copy link

google-cla bot commented Aug 14, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Aug 14, 2021
@vicmns
Copy link
Contributor Author

vicmns commented Aug 14, 2021

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Aug 14, 2021
Fallback logic for button shape update logic for lollipop
@vicmns vicmns force-pushed the material_button_lollipop_shape_fix branch from be723b2 to cd17642 Compare August 14, 2021 06:08
class MaterialButtonHelper {

private static final boolean IS_LOLLIPOP = VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP;
private static final boolean IS_MIN_LOLLIPOP = VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS_LOLLIPOP_OR_ABOVE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, wasn't "IS_MIN" and old used convention in Android when gating min API logic? I'm pretty sure that I saw some time ago code using this prefix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess Android uses atLeastXXXX in many places, which also works. : )

slavonnet pushed a commit to slavonnet/material-components-android that referenced this pull request Sep 2, 2021
Resolves material-components#2331
Resolves material-components#1797

GIT_ORIGIN_REV_ID=cd176426395bf93f701c623c00947384aabf0706
PiperOrigin-RevId: 393405994
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MaterialButton] Ripple doesn't respect shape if app:rippleColor was set on API 21

2 participants