From f1186f9d14e2fd905c1f5030b5bf99e17b0565f9 Mon Sep 17 00:00:00 2001 From: mpodolian Date: Wed, 8 Jan 2025 14:23:39 -0800 Subject: [PATCH] Hide bubble bar stash handle when the notification shade is open. Introduced logic to control the bubble bar stash handle alpha based on the notification shade state. Test: TransientBubbleStashControllerTest Test: Manual. Have bubbles and the bubble bar stashed. Open the notification shade, observe that the stash handle fades away. Close the notification shade, observe that the stash handle fades back in. Have few bubbles, open bubbles test app, click on bubble icon. Observe the bubble bar expands without blinking. Test: Manual. http://recall/-/gx8ASgewUeUS3QYohfrd1J/e1iUtwaFdezKOb0gBRff7Z Flag: com.android.wm.shell.enable_bubble_bar Fixes: 376140839 Fixes: 376141264 Change-Id: Id9c473f9aead0e4c5830793d9f3b0b1ae86453e7 --- .../taskbar/TaskbarActivityContext.java | 21 +++++++--- .../bubbles/stashing/BubbleStashController.kt | 4 ++ .../TransientBubbleStashController.kt | 8 ++++ .../TransientBubbleStashControllerTest.kt | 39 +++++++++++++++++++ 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 060173a2d7..deda802464 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -140,6 +140,7 @@ import com.android.launcher3.util.ApplicationInfoWrapper; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.Executors; +import com.android.launcher3.util.MultiPropertyFactory; import com.android.launcher3.util.NavigationMode; import com.android.launcher3.util.RunnableList; import com.android.launcher3.util.SettingsCache; @@ -194,6 +195,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { private WindowManager.LayoutParams mWindowLayoutParams; private WindowManager.LayoutParams mLastUpdatedLayoutParams; private boolean mIsFullscreen; + private boolean mIsNotificationShadeExpanded = false; // The size we should return to when we call setTaskbarWindowFullscreen(false) private int mLastRequestedNonFullscreenSize; /** @@ -1006,6 +1008,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext { * Hides the taskbar icons and background when the notification shade is expanded. */ private void onNotificationShadeExpandChanged(boolean isExpanded, boolean skipAnim) { + boolean isExpandedUpdated = isExpanded != mIsNotificationShadeExpanded; + mIsNotificationShadeExpanded = isExpanded; // Close all floating views within the Taskbar window to make sure nothing is shown over // the notification shade. if (isExpanded) { @@ -1019,11 +1023,18 @@ public class TaskbarActivityContext extends BaseTaskbarContext { anim.play(mControllers.taskbarDragLayerController.getNotificationShadeBgTaskbar() .animateToValue(alpha)); - mControllers.bubbleControllers.ifPresent(controllers -> { - BubbleBarViewController bubbleBarViewController = controllers.bubbleBarViewController; - anim.play(bubbleBarViewController.getBubbleBarAlpha().get(0).animateToValue(alpha)); - }); - + if (isExpandedUpdated) { + mControllers.bubbleControllers.ifPresent(controllers -> { + BubbleBarViewController bubbleBarViewController = + controllers.bubbleBarViewController; + anim.play(bubbleBarViewController.getBubbleBarAlpha().get(0).animateToValue(alpha)); + MultiPropertyFactory.MultiProperty handleAlpha = + controllers.bubbleStashController.getHandleViewAlpha(); + if (handleAlpha != null) { + anim.play(handleAlpha.animateToValue(alpha)); + } + }); + } anim.start(); if (skipAnim) { anim.end(); diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt index 595dac3f32..fec1eaf55c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt @@ -24,6 +24,7 @@ import com.android.launcher3.taskbar.TaskbarInsetsController import com.android.launcher3.taskbar.bubbles.BubbleBarView import com.android.launcher3.taskbar.bubbles.BubbleBarViewController import com.android.launcher3.taskbar.bubbles.BubbleStashedHandleViewController +import com.android.launcher3.util.MultiPropertyFactory import com.android.wm.shell.shared.animation.PhysicsAnimator import com.android.wm.shell.shared.bubbles.BubbleBarLocation import java.io.PrintWriter @@ -172,6 +173,9 @@ interface BubbleStashController { /** Returns bounds of the handle */ fun getHandleBounds(bounds: Rect) + /** Returns MultiValueAlpha of the handle view when the handle view is shown. */ + fun getHandleViewAlpha(): MultiPropertyFactory.MultiProperty? = null + /** * Returns bubble bar Y position according to [isBubblesShowingOnHome] and * [isBubblesShowingOnOverview] values. Default implementation only analyse 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 3e3f5692c9..9c148e2191 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt @@ -512,6 +512,14 @@ class TransientBubbleStashController( } } + override fun getHandleViewAlpha(): MultiPropertyFactory.MultiProperty? = + // only return handle alpha if the bubble bar is stashed and has bubbles + if (isStashed && bubbleBarViewController.hasBubbles()) { + stashHandleViewAlpha + } else { + null + } + private fun Animator.updateTouchRegionOnAnimationEnd(): Animator { doOnEnd { onIsStashedChanged() } return this 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 f642345b15..b24926beca 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 @@ -507,6 +507,45 @@ class TransientBubbleStashControllerTest { assertThat(height).isEqualTo(BUBBLE_BAR_HEIGHT) } + @Test + fun getHandleViewAlpha_stashedHasBubbles_alphaPropertyReturned() { + // Given BubbleBar is stashed and has bubbles + whenever(bubbleBarViewController.hasBubbles()).thenReturn(true) + mTransientBubbleStashController.isStashed = true + + // When handle view alpha property + val alphaProperty = mTransientBubbleStashController.getHandleViewAlpha() + + // Then the stash handle alpha property should not be null + assertThat(alphaProperty).isNotNull() + } + + @Test + fun getHandleViewAlpha_stashedHasNoBubblesBar_alphaPropertyIsNull() { + // Given BubbleBar is stashed and has no bubbles + whenever(bubbleBarViewController.hasBubbles()).thenReturn(false) + mTransientBubbleStashController.isStashed = true + + // When handle view alpha property + val alphaProperty = mTransientBubbleStashController.getHandleViewAlpha() + + // Then the stash handle alpha property should be null + assertThat(alphaProperty).isNull() + } + + @Test + fun getHandleViewAlpha_unstashedHasBubbles_alphaPropertyIsNull() { + // Given BubbleBar is not stashed and has bubbles + whenever(bubbleBarViewController.hasBubbles()).thenReturn(true) + mTransientBubbleStashController.isStashed = false + + // When handle view alpha property + val alphaProperty = mTransientBubbleStashController.getHandleViewAlpha() + + // Then the stash handle alpha property should be null + assertThat(alphaProperty).isNull() + } + private fun advanceTimeBy(advanceMs: Long) { // Advance animator for on-device tests getInstrumentation().runOnMainSync { animatorTestRule.advanceTimeBy(advanceMs) }