Skip to content

[Android] Fix: Modal Animation Repeats When Returning from Background 2 #29557

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

Merged
merged 7 commits into from
May 21, 2025

Conversation

bhavanesh2001
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

This is an alternative (and improved) approach to #28538 and #28522.
As suggested by @PureWeen, a new animation style has been added, and the previous animation logic has been cleaned up.

Befor fix After fix
before_fix.mov
new_fix.mov

Issues Fixed

Fixes #28492

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label May 16, 2025
@PureWeen
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).


#pragma warning disable CS0618 // TODO: Remove when we internalize/replace MessagingCenter
if (value)
MessagingCenter.Send(this, CloseContextActionsSignalName);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this was originally intended for

//TODO: MAUI
//MessagingCenter.Subscribe<ListViewAdapter>(this, Platform.CloseContextActionsSignalName, lva => CloseContextActions());

which clearly isn’t subscribing anymore.
And since ListView is about to be kicked out of the house, I’m removing it.

@bhavanesh2001
Copy link
Contributor Author

bhavanesh2001 commented May 17, 2025

Everything looks good now, but there’s a limitation with this approach:
Once SetWindowAnimations() is applied during PushModalAsync(true), it appears that it cannot be dynamically altered or disabled afterward. As a result, calling PopModalAsync(false) does not suppress the exit animation — the dialog still animates during dismissal.

Call Status
PushModalAsync(true), PopModalAsync(true) ✅ Works fine — animations play as expected.
PushModalAsync(true), PopModalAsync(false) ⚠️ Exit still animates — pop animation not skipped.
PushModalAsync(false), PopModalAsync(true) ⚠️ No animation plays — pop(true) has no effect.
PushModalAsync(false), PopModalAsync(false) ✅ Works fine — no animations, as expected.
Screenshot 2025-05-17 at 9 34 43 PM Screenshot 2025-05-17 at 9 25 53 PM Screenshot 2025-05-17 at 9 26 38 PM

@pictos
Copy link
Contributor

pictos commented May 17, 2025

On the after, the first time that you reopen the app I could see an animation very fast, and after that no more. Not sure if it's something that shiuld be fixed or we can ignore. It's definitely better than before

@bhavanesh2001
Copy link
Contributor Author

Thanks to @PureWeen 's suggestion, I think now animation works perfectly in all cases.

anim.mov

@bhavanesh2001 bhavanesh2001 marked this pull request as ready for review May 19, 2025 17:57
@bhavanesh2001 bhavanesh2001 requested a review from a team as a code owner May 19, 2025 17:57
@bhavanesh2001
Copy link
Contributor Author

On the after, the first time that you reopen the app I could see an animation very fast, and after that no more. Not sure if it's something that shiuld be fixed or we can ignore. It's definitely better than before

Yeah I noticed that too.. But i don't think it's related to animation we set.. because same thing can be seen if we do PushModalAsync(false)

@rmarinho
Copy link
Member

/azp run

@dotnet dotnet deleted a comment from azure-pipelines bot May 19, 2025
@bhavanesh2001
Copy link
Contributor Author

bhavanesh2001 commented May 20, 2025

PushingNavigationPageModallyWithShellShowsToolbarCorrectly fails with API 23 😔

@PureWeen PureWeen added this to the .NET 9 SR8 milestone May 21, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing May 21, 2025
@bhavanesh2001 bhavanesh2001 requested a review from PureWeen May 21, 2025 06:02
@bhavanesh2001
Copy link
Contributor Author

It seems , using Dialog?.Window?.DecorView.Animation?.SetAnimationListener() only works for explicitly started view animations. It does not get triggered for window-enter/exit animations defined via styles (i.e., SetWindowAnimations).

@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing May 21, 2025
@PureWeen PureWeen changed the base branch from main to inflight/current May 21, 2025 17:50
@PureWeen PureWeen merged commit 1e89758 into dotnet:inflight/current May 21, 2025
1 of 2 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing May 21, 2025
github-actions bot pushed a commit that referenced this pull request May 22, 2025
… 2 (#29557)

* [Android] clean up modalnavigationmanager

* fix failing tests

* Handle animation while poping

* subscribe to event before showing dailog

* change style's names

* apply new styles

* set result to tcs once dailog dismiss
bhavanesh2001 added a commit to bhavanesh2001/maui that referenced this pull request May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Android] Modal Animation Repeats When Returning from Background
5 participants