From 47709b1d3a397c295ab6169796f9d0aabc4d39b2 Mon Sep 17 00:00:00 2001 From: Josh Tsuji Date: Wed, 31 Mar 2021 19:21:33 -0400 Subject: [PATCH] Don't reset Z order if the expanded view is temporarily animated out. This resulted in a full opacity SurfaceView hanging out behind the bubble scrim. This was not visible when we had an opaque scrim but now that it's transparent again we can see it. Bug: 184198137 Test: manual Change-Id: If768ccc9f6dab56764227cffdbbda4f8738d56cc --- .../wm/shell/bubbles/BubbleStackView.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index e5c9e2567ec5f..fe2e22c5292fb 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -268,7 +268,7 @@ public class BubbleStackView extends FrameLayout private boolean mIsDraggingStack = false; /** Whether the expanded view has been hidden, because we are dragging out a bubble. */ - private boolean mExpandedViewHidden = false; + private boolean mExpandedViewTemporarilyHidden = false; /** Animator for animating the expanded view's alpha (including the TaskView inside it). */ private final ValueAnimator mExpandedViewAlphaAnimator = ValueAnimator.ofFloat(0f, 1f); @@ -970,7 +970,13 @@ public class BubbleStackView extends FrameLayout @Override public void onAnimationEnd(Animator animation) { - if (mExpandedBubble != null && mExpandedBubble.getExpandedView() != null) { + if (mExpandedBubble != null + && mExpandedBubble.getExpandedView() != null + // The surface needs to be Z ordered on top for alpha values to work on the + // TaskView, and if we're temporarily hidden, we are still on the screen + // with alpha = 0f until we animate back. Stay Z ordered on top so the alpha + // = 0f remains in effect. + && !mExpandedViewTemporarilyHidden) { mExpandedBubble.getExpandedView().setSurfaceZOrderedOnTop(false); mExpandedBubble.getExpandedView().setAlphaAnimating(false); } @@ -985,7 +991,7 @@ public class BubbleStackView extends FrameLayout mAnimatingOutSurfaceAlphaAnimator.setDuration(EXPANDED_VIEW_ALPHA_ANIMATION_DURATION); mAnimatingOutSurfaceAlphaAnimator.setInterpolator(Interpolators.PANEL_CLOSE_ACCELERATED); mAnimatingOutSurfaceAlphaAnimator.addUpdateListener(valueAnimator -> { - if (!mExpandedViewHidden) { + if (!mExpandedViewTemporarilyHidden) { mAnimatingOutSurfaceView.setAlpha((float) valueAnimator.getAnimatedValue()); } }); @@ -1598,7 +1604,7 @@ public class BubbleStackView extends FrameLayout // If we're expanded, screenshot the currently expanded bubble (before expanding the newly // selected bubble) so we can animate it out. if (mIsExpanded && mExpandedBubble != null && mExpandedBubble.getExpandedView() != null - && !mExpandedViewHidden) { + && !mExpandedViewTemporarilyHidden) { if (mExpandedBubble != null && mExpandedBubble.getExpandedView() != null) { // Before screenshotting, have the real ActivityView show on top of other surfaces // so that the screenshot doesn't flicker on top of it. @@ -1724,13 +1730,13 @@ public class BubbleStackView extends FrameLayout /** Animate the expanded view hidden. This is done while we're dragging out a bubble. */ private void hideExpandedViewIfNeeded() { - if (mExpandedViewHidden + if (mExpandedViewTemporarilyHidden || mExpandedBubble == null || mExpandedBubble.getExpandedView() == null) { return; } - mExpandedViewHidden = true; + mExpandedViewTemporarilyHidden = true; // Scale down. PhysicsAnimator.getInstance(mExpandedViewContainerMatrix) @@ -1754,11 +1760,11 @@ public class BubbleStackView extends FrameLayout * Animate the expanded view visible again. This is done when we're done dragging out a bubble. */ private void showExpandedViewIfNeeded() { - if (!mExpandedViewHidden) { + if (!mExpandedViewTemporarilyHidden) { return; } - mExpandedViewHidden = false; + mExpandedViewTemporarilyHidden = false; PhysicsAnimator.getInstance(mExpandedViewContainerMatrix) .spring(AnimatableScaleMatrix.SCALE_X, @@ -2087,7 +2093,7 @@ public class BubbleStackView extends FrameLayout mExpandedViewContainer.setAnimationMatrix(mExpandedViewContainerMatrix); }) .withEndActions(() -> { - mExpandedViewHidden = false; + mExpandedViewTemporarilyHidden = false; mIsBubbleSwitchAnimating = false; }) .start();