Fix bubbles taskbar scrim showing when notification panel is shown

TaskbarScrimViewController was previously unaware of visibility
changes that happened to taskbar outside of when the sysui state
flags changed. Additionally, isTaskbarVisibileAndNotStashing is not
a reliable signal as the visibility might be GONE even though taskbar
is about to animate to be visible (i.e. shade is showing and then
you swipe it back up -- taskbar scrim wouldn't appear because when
the sysuiStateFlags changed, taskbar visibility would still be 'gone'
at that point so the taskbar scrim wouldn't animate back when
the shade is swiped up).

To resolve this, I've added a callback to notify the scrim
controller of visibility changes and it'll update if needed.

Bug: 270634233
Test: manual - enable 3 button nav
             - have a bubble
             - go to overview
             - expand bubbles
             => observe that scrim appears over taskbar
             - swipe down shade
             => observe that scrim fades out
             - swipe shade up
             => observe that scrim fades in

Change-Id: Ibaae8efb90b4558d30795298570208a52b31efb4
This commit is contained in:
Mady Mellor
2023-09-08 15:31:03 -07:00
parent 9ea209b893
commit b898a3c8d3
4 changed files with 62 additions and 12 deletions

View File

@@ -15,10 +15,13 @@
*/
package com.android.launcher3.taskbar;
import static android.view.View.VISIBLE;
import static com.android.launcher3.taskbar.bubbles.BubbleBarController.BUBBLE_BAR_ENABLED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED;
import static com.android.wm.shell.common.bubbles.BubbleConstants.BUBBLE_EXPANDED_SCRIM_ALPHA;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE;
import android.animation.ObjectAnimator;
import android.view.animation.Interpolator;
@@ -41,6 +44,8 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa
private final TaskbarActivityContext mActivity;
private final TaskbarScrimView mScrimView;
private boolean mTaskbarVisible;
private int mSysUiStateFlags;
// Alpha property for the scrim.
private final AnimatedFloat mScrimAlpha = new AnimatedFloat(this::updateScrimAlpha);
@@ -60,6 +65,20 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa
mControllers = controllers;
}
/**
* Called when the taskbar visibility changes.
*
* @param visibility the current visibility of {@link TaskbarView}.
*/
public void onTaskbarVisibilityChanged(int visibility) {
mTaskbarVisible = visibility == VISIBLE;
if (shouldShowScrim()) {
showScrim(true, getScrimAlpha(), false /* skipAnim */);
} else if (mScrimView.getScrimAlpha() > 0f) {
showScrim(false, 0, false /* skipAnim */);
}
}
/**
* Updates the scrim state based on the flags.
*/
@@ -68,29 +87,39 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa
// These scrims aren't used if bubble bar & transient taskbar are active.
return;
}
final boolean bubblesExpanded = (stateFlags & SYSUI_STATE_BUBBLES_EXPANDED) != 0;
mSysUiStateFlags = stateFlags;
showScrim(shouldShowScrim(), getScrimAlpha(), skipAnim);
}
private boolean shouldShowScrim() {
final boolean bubblesExpanded = (mSysUiStateFlags & SYSUI_STATE_BUBBLES_EXPANDED) != 0;
boolean isShadeVisible = (mSysUiStateFlags & SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE) != 0;
return bubblesExpanded && !mControllers.navbarButtonsViewController.isImeVisible()
&& !isShadeVisible
&& !mControllers.taskbarStashController.isStashed()
&& mTaskbarVisible;
}
private float getScrimAlpha() {
final boolean manageMenuExpanded =
(stateFlags & SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED) != 0;
final boolean showScrim = !mControllers.navbarButtonsViewController.isImeVisible()
&& bubblesExpanded
&& mControllers.taskbarStashController.isTaskbarVisibleAndNotStashing();
final float scrimAlpha = manageMenuExpanded
(mSysUiStateFlags & SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED) != 0;
return manageMenuExpanded
// When manage menu shows there's the first scrim and second scrim so figure out
// what the total transparency would be.
? (BUBBLE_EXPANDED_SCRIM_ALPHA + (BUBBLE_EXPANDED_SCRIM_ALPHA
* (1 - BUBBLE_EXPANDED_SCRIM_ALPHA)))
: showScrim ? BUBBLE_EXPANDED_SCRIM_ALPHA : 0;
showScrim(showScrim, scrimAlpha, skipAnim);
: shouldShowScrim() ? BUBBLE_EXPANDED_SCRIM_ALPHA : 0;
}
private void showScrim(boolean showScrim, float alpha, boolean skipAnim) {
mScrimView.setOnClickListener(showScrim ? (view) -> onClick() : null);
mScrimView.setClickable(showScrim);
ObjectAnimator anim = mScrimAlpha.animateToValue(showScrim ? alpha : 0);
anim.setInterpolator(showScrim ? SCRIM_ALPHA_IN : SCRIM_ALPHA_OUT);
anim.start();
if (skipAnim) {
anim.end();
mScrimView.setScrimAlpha(alpha);
} else {
ObjectAnimator anim = mScrimAlpha.animateToValue(showScrim ? alpha : 0);
anim.setInterpolator(showScrim ? SCRIM_ALPHA_IN : SCRIM_ALPHA_OUT);
anim.start();
}
}