From 4e0ec1e458be262e40a12218536227cf6b12ff77 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Fri, 7 Jul 2023 16:19:27 -0700 Subject: [PATCH] Unify calls to sysuiProxy#showBubble into one method This will make it easier to note that a bubble has been "visited" so that we can hide the update dot (coming in future CL). Test: manual Bug: 269670235 Change-Id: Ie2dbbc478198ece65c05927295d3c3031a7be82e --- .../taskbar/bubbles/BubbleBarController.java | 34 ++++++++++++++++--- .../bubbles/BubbleBarViewController.java | 12 ++----- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java index b2d5940895..056fc74c30 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java @@ -118,6 +118,7 @@ public class BubbleBarController extends IBubblesListener.Stub { private final Executor mMainExecutor; private final LauncherApps mLauncherApps; private final BubbleIconFactory mIconFactory; + private final SystemUiProxy mSystemUiProxy; private BubbleBarItem mSelectedBubble; private BubbleBarOverflow mOverflowBubble; @@ -159,8 +160,10 @@ public class BubbleBarController extends IBubblesListener.Stub { mContext = context; mBarView = bubbleView; // Need the view for inflating bubble views. + mSystemUiProxy = SystemUiProxy.INSTANCE.get(context); + if (BUBBLE_BAR_ENABLED) { - SystemUiProxy.INSTANCE.get(context).setBubblesListener(this); + mSystemUiProxy.setBubblesListener(this); } mMainExecutor = MAIN_EXECUTOR; mLauncherApps = context.getSystemService(LauncherApps.class); @@ -173,7 +176,7 @@ public class BubbleBarController extends IBubblesListener.Stub { } public void onDestroy() { - SystemUiProxy.INSTANCE.get(mContext).setBubblesListener(null); + mSystemUiProxy.setBubblesListener(null); } public void init(TaskbarControllers controllers, BubbleControllers bubbleControllers) { @@ -354,12 +357,33 @@ public class BubbleBarController extends IBubblesListener.Stub { } } + /** Tells WMShell to show the currently selected bubble. */ + public void showSelectedBubble() { + if (getSelectedBubbleKey() != null) { + int[] bubbleBarCoords = mBarView.getLocationOnScreen(); + if (mSelectedBubble instanceof BubbleBarBubble) { + // TODO (b/269670235): hide the update dot on the view if needed. + } + mSystemUiProxy.showBubble(getSelectedBubbleKey(), + bubbleBarCoords[0], bubbleBarCoords[1]); + } else { + Log.w(TAG, "Trying to show the selected bubble but it's null"); + } + } + + /** Updates the currently selected bubble for launcher views and tells WMShell to show it. */ + public void showAndSelectBubble(BubbleBarItem b) { + if (DEBUG) Log.w(TAG, "showingSelectedBubble: " + b.getKey()); + setSelectedBubble(b); + showSelectedBubble(); + } + /** * Sets the bubble that should be selected. This notifies the views, it does not notify - * WMShell that the selection has changed, that should go through - * {@link SystemUiProxy#showBubble}. + * WMShell that the selection has changed, that should go through either + * {@link #showSelectedBubble()} or {@link #showAndSelectBubble(BubbleBarItem)}. */ - public void setSelectedBubble(BubbleBarItem b) { + private void setSelectedBubble(BubbleBarItem b) { if (!Objects.equals(b, mSelectedBubble)) { if (DEBUG) Log.w(TAG, "selectingBubble: " + b.getKey()); mSelectedBubble = b; diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index 725f94820f..ca0c4cc206 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -112,9 +112,7 @@ public class BubbleBarViewController { setExpanded(false); mBubbleStashController.stashBubbleBar(); } else { - mBubbleBarController.setSelectedBubble(bubble); - int[] bubbleBarCoords = mBarView.getLocationOnScreen(); - mSystemUiProxy.showBubble(bubble.getKey(), bubbleBarCoords[0], bubbleBarCoords[1]); + mBubbleBarController.showAndSelectBubble(bubble); } } @@ -291,13 +289,7 @@ public class BubbleBarViewController { if (!isExpanded) { mSystemUiProxy.collapseBubbles(); } else { - final String selectedKey = mBubbleBarController.getSelectedBubbleKey(); - if (selectedKey != null) { - int[] bubbleBarCoords = mBarView.getLocationOnScreen(); - mSystemUiProxy.showBubble(selectedKey, bubbleBarCoords[0], bubbleBarCoords[1]); - } else { - Log.w(TAG, "trying to expand bubbles when there isn't one selected"); - } + mBubbleBarController.showSelectedBubble(); mTaskbarStashController.updateAndAnimateTransientTaskbar(true /* stash */, false /* shouldBubblesFollow */); }