Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Fix Button Ripple Effect not working #17821

Closed
wants to merge 14 commits into from
Closed

Conversation

jsuarezruiz
Copy link
Contributor

@jsuarezruiz jsuarezruiz commented Oct 4, 2023

Description of Change

Fix Button Ripple Effect not working using a custom background.

We use the MaterialButton instead a Button on Android, and this type use MaterialShapeDrawable. MaterialShapeDrawable does not support gradients. Settings a gradient or creating a composition drawable with two layers: gradient drawable and ripple drawable create a black background. [MaterialShapeDrawable] Unable to add gradient to MaterialShapeDrawable · Issue #1167 · material-components/material-components-android (github.com)
To set the gradient we set to null the backgroundTintList property and set a custom drawable in the background. The PR apply changes in the custom drawable adding the ripple effect animation to maintain the same drawable and the MaterialButton.
surprised 1

fix-17642

Issues Fixed

Fixes #17642
Fixes #18815

@jsuarezruiz jsuarezruiz added t/bug Something isn't working platform/android 🤖 legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor area-controls-button Button, ImageButton labels Oct 4, 2023
bool HasBorder()
{
InitializeBorderIfNeeded();

return _stroke != null || _borderColor != null;
}

bool HasRipple()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only render and run the ripple animation if set the RippleColor.

@samhouts samhouts added this to the .NET 8 GA milestone Oct 5, 2023
@jsuarezruiz jsuarezruiz marked this pull request as ready for review October 9, 2023 11:26
@jsuarezruiz jsuarezruiz requested a review from a team as a code owner October 9, 2023 11:26
@PureWeen PureWeen modified the milestones: .NET 8 GA, .NET 8 SR1 Oct 9, 2023
@jsuarezruiz jsuarezruiz marked this pull request as draft November 8, 2023 16:27
@@ -14,8 +18,10 @@

namespace Microsoft.Maui.Platform
{
public class BorderDrawable : PaintDrawable
public class BorderDrawable : PaintDrawable, IAnimatorUpdateListener
Copy link
Member

Choose a reason for hiding this comment

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

We can't add a new interface

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With IAnimatorUpdateListener, should go to .NET 9?. In this case, we need an alternative for .NET 8.

@Redth Redth removed this from the .NET 8 SR1 milestone Nov 30, 2023
@samhouts samhouts added the stale Indicates a stale issue/pr and will be closed soon label Dec 14, 2023
@zippo227
Copy link

@jsuarezruiz Is this the planned fix for #18815 as well?

@samhouts samhouts added the s/pr-needs-author-input PR needs an update from the author label Jan 9, 2024
@ghost
Copy link

ghost commented Jan 9, 2024

Hi @jsuarezruiz. We have added the "s/pr-needs-author-input" label to this issue, which indicates that we have an open question/action for you before we can take further action. This PRwill be closed automatically in 14 days if we do not hear back from you by then - please feel free to re-open it if you come back to this PR after that time.

@ghost ghost closed this Jan 13, 2024
@cytoph
Copy link

cytoph commented Jan 16, 2024

So this will just be closed? How can it be, that throughout a whole major version of .NET, button animations (so almost everything that's being tapped) just don't work for one of the biggest platforms of .NET MAUI (Android), and Microsoft doesn't seem to care about it. I was really looking forward to migrate from Xamarin to .NET MAUI, but with this issue the app just looks plain unprofessional and cannot be delivered to any customers as it is.

@jsuarezruiz jsuarezruiz reopened this Jan 18, 2024
@ghost ghost removed stale Indicates a stale issue/pr and will be closed soon s/pr-needs-author-input PR needs an update from the author labels Jan 18, 2024
@jsuarezruiz
Copy link
Contributor Author

So this will just be closed? How can it be, that throughout a whole major version of .NET, button animations (so almost everything that's being tapped) just don't work for one of the biggest platforms of .NET MAUI (Android), and Microsoft doesn't seem to care about it. I was really looking forward to migrate from Xamarin to .NET MAUI, but with this issue the app just looks plain unprofessional and cannot be delivered to any customers as it is.

Reopened and is a priority for the next release.

@cytoph
Copy link

cytoph commented Jan 22, 2024

Reopened and is a priority for the next release.

That is really, really good to hear. Just to clarify: "Next release" as in ".NET 9" or as in ".NET 8 SR1/2"? 🤔

@PureWeen PureWeen closed this Mar 23, 2024
PureWeen added a commit that referenced this pull request Apr 2, 2024
…7821)  (#20412)

* Other approach to fix the issue

* More changes

* Fixed Stroke

* Added device test

* Updated sample

* More changes

* Updated test

* Fix build errors

* Fix format

* working

* So much done here!

* - fix Tizen

---------

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 23, 2024
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-button Button, ImageButton platform/android 🤖 t/bug Something isn't working
Projects
None yet
7 participants