From 2166749190f9ae1aeefaf59824d0c42c6858d598 Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Thu, 3 Oct 2024 11:29:17 -0700 Subject: [PATCH 1/2] Set bubble bar invisible while stashed Update bubble bar visibility when it is stashed. Ensures that if alpha is updated, it won't show up. Bug: 345687278 Test: TransientBubbleStashController Flag: com.android.wm.shell.enable_bubble_bar Change-Id: I603a67a824a5cee0fb35de7c3f2dc98d9d2323ed --- .../bubbles/BubbleBarViewController.java | 12 +++++- .../TransientBubbleStashController.kt | 18 +++++++- .../TransientBubbleStashControllerTest.kt | 43 +++++++++++++++++++ 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index ba180a691e..c164eec450 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -106,6 +106,8 @@ public class BubbleBarViewController { private boolean mHiddenForSysui; // Whether the bar is hidden because there are no bubbles. private boolean mHiddenForNoBubbles = true; + // Whether the bar is hidden when stashed + private boolean mHiddenForStashed; private boolean mShouldShowEducation; public boolean mOverflowAdded; @@ -467,9 +469,17 @@ public class BubbleBarViewController { } } + /** Sets whether the bubble bar should be hidden due to stashed state */ + public void setHiddenForStashed(boolean hidden) { + if (mHiddenForStashed != hidden) { + mHiddenForStashed = hidden; + updateVisibilityForStateChange(); + } + } + // TODO: (b/273592694) animate it private void updateVisibilityForStateChange() { - if (!mHiddenForSysui && !mHiddenForNoBubbles) { + if (!mHiddenForSysui && !mHiddenForNoBubbles && !mHiddenForStashed) { mBarView.setVisibility(VISIBLE); } else { mBarView.setVisibility(INVISIBLE); diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt index fe3db302a3..9e7d1c4602 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt @@ -169,7 +169,11 @@ class TransientBubbleStashController( isStashed = true stashHandleViewAlpha?.let { animatorSet.playTogether(it.animateToValue(1f)) } } - animatorSet.updateTouchRegionOnAnimationEnd().setDuration(BAR_STASH_DURATION).start() + animatorSet + .updateBarVisibility(isStashed) + .updateTouchRegionOnAnimationEnd() + .setDuration(BAR_STASH_DURATION) + .start() } override fun showBubbleBarImmediate() { @@ -186,6 +190,7 @@ class TransientBubbleStashController( bubbleBarBackgroundScaleX.updateValue(1f) bubbleBarBackgroundScaleY.updateValue(1f) isStashed = false + bubbleBarViewController.setHiddenForStashed(false) onIsStashedChanged() } @@ -200,6 +205,7 @@ class TransientBubbleStashController( bubbleBarBackgroundScaleX.updateValue(getStashScaleX()) bubbleBarBackgroundScaleY.updateValue(getStashScaleY()) isStashed = true + bubbleBarViewController.setHiddenForStashed(true) onIsStashedChanged() } @@ -481,6 +487,7 @@ class TransientBubbleStashController( animator?.cancel() animator = createStashAnimator(isStashed, BAR_STASH_DURATION).apply { + updateBarVisibility(isStashed) updateTouchRegionOnAnimationEnd() start() } @@ -495,6 +502,15 @@ class TransientBubbleStashController( return this } + private fun T.updateBarVisibility(stashed: Boolean): T { + if (stashed) { + doOnEnd { bubbleBarViewController.setHiddenForStashed(true) } + } else { + doOnStart { bubbleBarViewController.setHiddenForStashed(false) } + } + return this + } + private fun Animator.setBubbleBarPivotDuringAnim(pivotX: Float, pivotY: Float): Animator { var initialPivotX = Float.NaN var initialPivotY = Float.NaN diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt index 7973e2dfd9..8b277e792d 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt @@ -49,6 +49,7 @@ import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule import org.mockito.kotlin.any import org.mockito.kotlin.atLeastOnce +import org.mockito.kotlin.never import org.mockito.kotlin.verify import org.mockito.kotlin.whenever @@ -306,6 +307,44 @@ class TransientBubbleStashControllerTest { assertThat(bubbleBarView.background.alpha).isNotEqualTo((bubbleView.alpha * 255f).toInt()) } + @Test + fun updateStashedAndExpandedState_stash_updateBarVisibilityAfterAnimation() { + // Given bubble bar has bubbles and is unstashed + mTransientBubbleStashController.isStashed = false + whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false) + + // When stash + getInstrumentation().runOnMainSync { + mTransientBubbleStashController.updateStashedAndExpandedState( + stash = true, + expand = false, + ) + } + + // Hides bubble bar only after animation completes + verify(bubbleBarViewController, never()).setHiddenForStashed(true) + advanceTimeBy(BubbleStashController.BAR_STASH_DURATION) + verify(bubbleBarViewController).setHiddenForStashed(true) + } + + @Test + fun updateStashedAndExpandedState_unstash_updateBarVisibilityBeforeAnimation() { + // Given bubble bar has bubbles and is stashed + mTransientBubbleStashController.isStashed = true + whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false) + + // When unstash + getInstrumentation().runOnMainSync { + mTransientBubbleStashController.updateStashedAndExpandedState( + stash = false, + expand = false, + ) + } + + // Shows bubble bar immediately + verify(bubbleBarViewController).setHiddenForStashed(false) + } + @Test fun isSysuiLockedSwitchedToFalseForOverview_unlockAnimationIsShown() { // Given screen is locked and bubble bar has bubbles @@ -358,6 +397,8 @@ class TransientBubbleStashControllerTest { assertThat(stashedHandleView.alpha).isEqualTo(0) // Insets controller is notified verify(taskbarInsetsController).onTaskbarOrBubblebarWindowHeightOrInsetsChanged() + // Bubble bar visibility updated + verify(bubbleBarViewController).setHiddenForStashed(false) } @Test @@ -375,6 +416,8 @@ class TransientBubbleStashControllerTest { assertThat(stashedHandleView.translationY).isEqualTo(0) // Insets controller is notified verify(taskbarInsetsController).onTaskbarOrBubblebarWindowHeightOrInsetsChanged() + // Bubble bar visibility updated + verify(bubbleBarViewController).setHiddenForStashed(true) } @Test From d819f32e463ba1f076577e1b8275f2ef6bcca0c0 Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Wed, 2 Oct 2024 10:23:34 -0700 Subject: [PATCH 2/2] Animate bubble bar alpha when notif shade opens Similar to taskbar, animate the alpha for bubble bar when notification shade is expanded. Bug: 345687278 Test: have bubbles on home screen, swipe down notification shade, bubbles are hidden with an animation Test: have bubbles in app, stashed, swipe down notification shade, no change Test: have bubbles in app, unstashed, swipe down notification shade, bubbles hidden with an animation Test: receive bubble notification while shade is open, check that bubble bar is not shown Test: compare bubble bar shadow and stroke before and after change Flag: com.android.wm.shell.enable_bubble_bar Change-Id: I74af6a7230f81628540f9b935cbe7dc801bd7a01 --- .../android/launcher3/taskbar/TaskbarActivityContext.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index a59445b9f6..73d7fd0787 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -943,7 +943,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { } /** - * Hides the taskbar icons and background when the notication shade is expanded. + * Hides the taskbar icons and background when the notification shade is expanded. */ private void onNotificationShadeExpandChanged(boolean isExpanded, boolean skipAnim) { float alpha = isExpanded ? 0 : 1; @@ -952,6 +952,12 @@ public class TaskbarActivityContext extends BaseTaskbarContext { TaskbarViewController.ALPHA_INDEX_NOTIFICATION_EXPANDED).animateToValue(alpha)); anim.play(mControllers.taskbarDragLayerController.getNotificationShadeBgTaskbar() .animateToValue(alpha)); + + mControllers.bubbleControllers.ifPresent(controllers -> { + BubbleBarViewController bubbleBarViewController = controllers.bubbleBarViewController; + anim.play(bubbleBarViewController.getBubbleBarAlpha().get(0).animateToValue(alpha)); + }); + anim.start(); if (skipAnim) { anim.end();