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

PC-I25: Prevent Mini Player From Animating When Changing Theme #513

Merged
merged 2 commits into from
Nov 1, 2022
Merged

PC-I25: Prevent Mini Player From Animating When Changing Theme #513

merged 2 commits into from
Nov 1, 2022

Conversation

owenlejeune
Copy link
Contributor

Description

Store the state of the mini player when recreating the MainActivity so that the mini player animation can be disabled when changing the theme.

Fixes #25

Testing Instructions

  1. Navigate to Appearance settings
  2. Select a theme different from the currently applied theme
  3. Mini player should not animate

Screenshots or Screencast

22-10-29-09-55-51.mp4

@owenlejeune owenlejeune requested a review from a team as a code owner October 29, 2022 13:59
binding.miniPlayer.setUpNext(upNext, theme)

// only show the mini player when an episode is loaded
if (upNext is UpNextQueue.State.Loaded) {
if ((isHidden() || !hasLoadedFirstTime)) {
show()
if (!shouldPlayerOpenOnAttach) {
if (!shouldPlayerOpenOnAttach && shouldAnimateOnAttach) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is preventing listener?.onMiniPlayerVisible() from getting called on line 148 after changing themes. As a result, the padding isn't being updated to handle the mini player being visible, and we're losing content under the miniplayer. I was able to see this by following these steps:

  1. Open the app and go to Profile tab -> Gear Icon
  2. Scroll to the bottom of the screen and observe that the last two settings are "Privacy" followed by "About"
  3. Tap on Appearance and change the theme
  4. Tap back and scroll to the bottom
  5. Observe that Privacy is now the last visible setting (because "About" is now hidden behind the miniplayer).
device-2022-10-31-134952.mp4

Similarly, it seems like we should also be updating the hasLoadedFirstTime field here, although I'm not sure that not updating it is actually causing any problems currently.

@@ -219,7 +220,10 @@ class MainActivity :
activity = this
)

setupPlayerViews()
val showMiniPlayerImmediately = savedInstanceState?.getBoolean(SAVEDSTATE_MINIPLAYER_SHOWN, false) ?: false
binding.playerBottomSheet.isVisible = showMiniPlayerImmediately
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I understanding correctly that we're updating the visibility here even though it will get updated later in order to avoid (or at least reduce) the miniplayer "flickering" when changing themes? If so, it might be worth adding a comment here briefly explaining that.

Copy link
Contributor

@mchowning mchowning left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @owenlejeune ! 🙇 This is looking nice and it fixes the animation issue. 🎉

I left a comment below about an issue with the padding not being updated that I noticed. It would be good to address that before we merge this.

One other thing I noticed is that now, if a podcast is playing, the miniplayer's play button quickly switch back and forth between play and pause a few times when we switch themes. I suspect this was probably happening before, but the animation just hid it.

Before After
device-2022-10-31-140719.mp4
device-2022-10-31-140137.mp4

We can log an issue for this (I wonder if it might have a similar cause as #52), and not address it in this PR if you'd like though because it's not directly related to the animation issue you're addressing here. Just let me know what you'd like to do.

@owenlejeune
Copy link
Contributor Author

@mchowning good catch! The padding issue should be addressed now. I don't seem to be able to reproduce the play button animation on my end though, may be best to open a new issue to address that separately.

Copy link
Contributor

@mchowning mchowning left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks so much for taking care of this @owenlejeune!

I don't seem to be able to reproduce the play button animation on my end though, may be best to open a new issue to address that separately.

👍 Opened here: #523

@mchowning mchowning merged commit da9d3b4 into Automattic:main Nov 1, 2022
@owenlejeune owenlejeune deleted the i-25 branch November 1, 2022 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When toggling themes the miniplayer animates back into place
2 participants