From 04bd5b49ea9d514605e3ccf2e2976a82b9fae46c Mon Sep 17 00:00:00 2001 From: mpodolian Date: Thu, 17 Apr 2025 16:53:01 -0700 Subject: [PATCH] Stash the taskbar on every bubble bar expansion Added logic to enable BubbleBarView to notify BubbleBarViewController of expanded state change. Also updated all the test that uses BubbleBarView to pass empty Controller. Fixes: 411304392 Flag: com.android.wm.shell.enable_bubble_bar Test: Manual. Go to any app. Swipe up to show the taskbar. Trigger any bubble. Observe taskbar is stashed on bubble bar expanded. Change-Id: I88ad167eb0ed444629716df3672bbb06ca8adcc4 --- .../taskbar/bubbles/BubbleBarView.java | 8 +++++-- .../bubbles/BubbleBarViewController.java | 10 ++++++-- .../bubbles/BubbleBarViewScreenshotTest.kt | 20 ++++++++++++++++ .../PersistentBubbleStashControllerTest.kt | 23 +++++++++++++++++++ .../TransientBubbleStashControllerTest.kt | 23 +++++++++++++++++++ .../animation/BubbleBarViewAnimatorTest.kt | 19 +++++++++++++++ 6 files changed, 99 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index 32860a136a..5dbd4c1ce2 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -1191,7 +1191,7 @@ public class BubbleBarView extends FrameLayout { mUpdateSelectedBubbleAfterCollapse = updateSelectedBubbleAfterCollapse; } - void setController(Controller controller) { + public void setController(Controller controller) { mController = controller; } @@ -1320,6 +1320,7 @@ public class BubbleBarView extends FrameLayout { mWidthAnimator.start(); updateBubbleAccessibilityStates(); announceExpandedStateChange(); + mController.onBubbleBarExpandedStateChanged(mIsBarExpanded); } } @@ -1643,7 +1644,7 @@ public class BubbleBarView extends FrameLayout { } /** Interface for BubbleBarView to communicate with its controller. */ - interface Controller { + public interface Controller { /** Returns the screen height. */ int getScreenHeight(); @@ -1666,5 +1667,8 @@ public class BubbleBarView extends FrameLayout { /** Notifies the controller that bubble bar is being dragged */ void setIsDragging(boolean dragging); + + /** Notifies the controller that bubble bar expanded state changed */ + void onBubbleBarExpandedStateChanged(boolean expanded); } } diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index d5436c5ee3..03586c80c6 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -318,6 +318,14 @@ public class BubbleBarViewController { public void setIsDragging(boolean dragging) { mBubbleBarContainer.setElevation(dragging ? mDragElevation : 0); } + + @Override + public void onBubbleBarExpandedStateChanged(boolean expanded) { + if (expanded && !mTaskbarStashController.isStashed()) { + mTaskbarStashController.updateAndAnimateTransientTaskbar(true /* stash */, + false /* shouldBubblesFollow */); + } + } }); mBubbleViewController = new BubbleView.Controller() { @@ -1252,8 +1260,6 @@ public class BubbleBarViewController { mSystemUiProxy.collapseBubbles(); } else { mBubbleBarController.showSelectedBubble(); - mTaskbarStashController.updateAndAnimateTransientTaskbar(true /* stash */, - false /* shouldBubblesFollow */); } } } diff --git a/quickstep/tests/multivalentScreenshotTests/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewScreenshotTest.kt b/quickstep/tests/multivalentScreenshotTests/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewScreenshotTest.kt index b5a418b04d..b6ceb5f6b2 100644 --- a/quickstep/tests/multivalentScreenshotTests/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewScreenshotTest.kt +++ b/quickstep/tests/multivalentScreenshotTests/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewScreenshotTest.kt @@ -27,6 +27,7 @@ import androidx.activity.ComponentActivity import androidx.test.core.app.ApplicationProvider import com.android.launcher3.R import com.android.launcher3.taskbar.bubbles.testing.FakeBubbleViewFactory +import com.android.wm.shell.shared.bubbles.BubbleBarLocation import com.google.android.apps.nexuslauncher.imagecomparison.goldenpathmanager.ViewScreenshotGoldenPathManager import org.junit.Rule import org.junit.Test @@ -124,6 +125,25 @@ class BubbleBarViewScreenshotTest(emulationSpec: DeviceEmulationSpec) { val paddingTop = context.resources.getDimensionPixelSize(R.dimen.bubblebar_pointer_visible_size) bubbleBarView.setPadding(0, paddingTop, 0, 0) + bubbleBarView.setController( + object : BubbleBarView.Controller { + override fun getScreenHeight(): Int = 0 + + override fun getBubbleBarTranslationY(): Float = 0f + + override fun onBubbleBarTouched() {} + + override fun expandBubbleBar() {} + + override fun dismissBubbleBar() {} + + override fun updateBubbleBarLocation(location: BubbleBarLocation?, source: Int) {} + + override fun setIsDragging(dragging: Boolean) {} + + override fun onBubbleBarExpandedStateChanged(expanded: Boolean) {} + } + ) bubbleBarView.visibility = View.VISIBLE bubbleBarView.alpha = 1f } diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt index 88b39d3653..bfc9b9f5f4 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt @@ -29,6 +29,7 @@ import com.android.launcher3.taskbar.bubbles.BubbleBarView import com.android.launcher3.taskbar.bubbles.BubbleBarViewController import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.BubbleLauncherState import com.android.launcher3.util.MultiValueAlpha +import com.android.wm.shell.shared.bubbles.BubbleBarLocation import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Rule @@ -391,6 +392,28 @@ class PersistentBubbleStashControllerTest { getInstrumentation().runOnMainSync { bubbleBarView = BubbleBarView(context) bubbleBarView.layoutParams = FrameLayout.LayoutParams(0, 0) + bubbleBarView.setController( + object : BubbleBarView.Controller { + override fun getScreenHeight(): Int = 0 + + override fun getBubbleBarTranslationY(): Float = 0f + + override fun onBubbleBarTouched() {} + + override fun expandBubbleBar() {} + + override fun dismissBubbleBar() {} + + override fun updateBubbleBarLocation( + location: BubbleBarLocation?, + source: Int, + ) {} + + override fun setIsDragging(dragging: Boolean) {} + + override fun onBubbleBarExpandedStateChanged(expanded: Boolean) {} + } + ) } } 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 b24926beca..42a667b35b 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 @@ -38,6 +38,7 @@ import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.Bubb import com.android.launcher3.util.MultiValueAlpha import com.android.wm.shell.shared.animation.PhysicsAnimator import com.android.wm.shell.shared.animation.PhysicsAnimatorTestUtils +import com.android.wm.shell.shared.bubbles.BubbleBarLocation import com.google.common.collect.Range import com.google.common.truth.Truth.assertThat import org.junit.Before @@ -556,6 +557,28 @@ class TransientBubbleStashControllerTest { bubbleBarView = BubbleBarView(context) bubbleBarView.layoutParams = FrameLayout.LayoutParams(BUBBLE_BAR_WIDTH, BUBBLE_BAR_HEIGHT) + bubbleBarView.setController( + object : BubbleBarView.Controller { + override fun getScreenHeight(): Int = 0 + + override fun getBubbleBarTranslationY(): Float = 0f + + override fun onBubbleBarTouched() {} + + override fun expandBubbleBar() {} + + override fun dismissBubbleBar() {} + + override fun updateBubbleBarLocation( + location: BubbleBarLocation?, + source: Int, + ) {} + + override fun setIsDragging(dragging: Boolean) {} + + override fun onBubbleBarExpandedStateChanged(expanded: Boolean) {} + } + ) bubbleView = BubbleView(context) bubbleBarView.addBubble(bubbleView) bubbleBarView.layout(0, 0, BUBBLE_BAR_WIDTH, BUBBLE_BAR_HEIGHT) diff --git a/quickstep/tests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt b/quickstep/tests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt index 8f26795045..3e6d53f545 100644 --- a/quickstep/tests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt +++ b/quickstep/tests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt @@ -1396,6 +1396,25 @@ class BubbleBarViewAnimatorTest { private fun setUpBubbleBar() { bubbleBarView = BubbleBarView(context) + bubbleBarView.setController( + object : BubbleBarView.Controller { + override fun getScreenHeight(): Int = 0 + + override fun getBubbleBarTranslationY(): Float = 0f + + override fun onBubbleBarTouched() {} + + override fun expandBubbleBar() {} + + override fun dismissBubbleBar() {} + + override fun updateBubbleBarLocation(location: BubbleBarLocation?, source: Int) {} + + override fun setIsDragging(dragging: Boolean) {} + + override fun onBubbleBarExpandedStateChanged(expanded: Boolean) {} + } + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { bubbleBarView.layoutParams = FrameLayout.LayoutParams(0, 0) val inflater = LayoutInflater.from(context)