From 16b05e251bea332433b651b58248c56060e64b74 Mon Sep 17 00:00:00 2001 From: Liran Binyamin Date: Wed, 5 Jul 2023 12:12:46 -0400 Subject: [PATCH] Ensure overflow isn't selected when bar is collapsed After the bubble bar collapsing animation completes, and reordering is finished, if the bubble overflow is selected, update the selected bubble to be the first bubble. This ensures that the overflow is not selected the next time the bubble bar is expanded. This is done through a callback from the BubbleBarView to the BubbleBarController with the key of the first bubble. Ideally the view would just notify that the selected bubble needs to be updated, but the controller doesn't hold ordering info. Fixes: 289280431 Test: manual - Add 2 bubbles to the bubble bar - Expand the bubble bar. The first bubble A should be selected - Select the second bubble B - Select the overflow - Tap on the overflow again to collapse the bubble bar - Tap on the bubble bar to expand it - Observe that bubble B is first and selected Change-Id: I0f9c2d628cfaf3a80da55ff634284687425e949a --- .../taskbar/bubbles/BubbleBarController.java | 2 ++ .../launcher3/taskbar/bubbles/BubbleBarView.java | 16 ++++++++++++++++ .../taskbar/bubbles/BubbleBarViewController.java | 7 +++++++ 3 files changed, 25 insertions(+) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java index 6b5c962df1..b2d5940895 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java @@ -184,6 +184,8 @@ public class BubbleBarController extends IBubblesListener.Stub { bubbleControllers.runAfterInit(() -> { mBubbleBarViewController.setHiddenForBubbles(!BUBBLE_BAR_ENABLED); mBubbleStashedHandleViewController.setHiddenForBubbles(!BUBBLE_BAR_ENABLED); + mBubbleBarViewController.setUpdateSelectedBubbleAfterCollapse( + key -> setSelectedBubble(mBubbles.get(key))); }); } diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index 58c67e366e..0b336450c4 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -32,6 +32,7 @@ import com.android.launcher3.taskbar.TaskbarActivityContext; import com.android.launcher3.views.ActivityContext; import java.util.List; +import java.util.function.Consumer; /** * The view that holds all the bubble views. Modifying this view should happen through @@ -101,6 +102,9 @@ public class BubbleBarView extends FrameLayout { @Nullable private Runnable mReorderRunnable; + @Nullable + private Consumer mUpdateSelectedBubbleAfterCollapse; + public BubbleBarView(Context context) { this(context, null); } @@ -144,6 +148,13 @@ public class BubbleBarView extends FrameLayout { mReorderRunnable.run(); mReorderRunnable = null; } + // If the bar was just collapsed and the overflow was the last bubble that was + // selected, set the first bubble as selected. + if (!mIsBarExpanded && mUpdateSelectedBubbleAfterCollapse != null + && mSelectedBubbleView.getBubble() instanceof BubbleBarOverflow) { + BubbleView firstBubble = (BubbleView) getChildAt(0); + mUpdateSelectedBubbleAfterCollapse.accept(firstBubble.getBubble().getKey()); + } updateWidth(); } @@ -293,6 +304,11 @@ public class BubbleBarView extends FrameLayout { } } + public void setUpdateSelectedBubbleAfterCollapse( + Consumer updateSelectedBubbleAfterCollapse) { + mUpdateSelectedBubbleAfterCollapse = updateSelectedBubbleAfterCollapse; + } + /** * Sets which bubble view should be shown as selected. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index 52c144ed4d..4e9f88a14e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -36,6 +36,7 @@ import com.android.quickstep.SystemUiProxy; import java.util.List; import java.util.Objects; +import java.util.function.Consumer; /** * Controller for {@link BubbleBarView}. Manages the visibility of the bubble bar as well as @@ -184,6 +185,12 @@ public class BubbleBarViewController { } } + /** Sets a callback that updates the selected bubble after the bubble bar collapses. */ + public void setUpdateSelectedBubbleAfterCollapse( + Consumer updateSelectedBubbleAfterCollapse) { + mBarView.setUpdateSelectedBubbleAfterCollapse(updateSelectedBubbleAfterCollapse); + } + /** * Sets whether the bubble bar should be hidden due to SysUI state (e.g. on lockscreen). */