From 1c03ed001dba141727a52b8949f5152bd4cd9d51 Mon Sep 17 00:00:00 2001 From: Liran Binyamin Date: Mon, 10 Jul 2023 17:19:12 -0400 Subject: [PATCH] Pass bubble bar offsets instead of position to WMShell This allows WMShell to calculate the position of the expanded view correctly when the bubble bar is being expanded from stashed. Test: See ag/24012908 Change-Id: I7b917e761c827135942d918917c920b06650f496 --- .../taskbar/bubbles/BubbleBarController.java | 18 ++++++++++++++---- .../taskbar/bubbles/BubbleBarView.java | 6 ++++++ .../taskbar/bubbles/BubbleStashController.java | 5 +++++ .../com/android/quickstep/SystemUiProxy.java | 10 ++++++---- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java index 056fc74c30..e5dd903861 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java @@ -31,6 +31,8 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_Q import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED; +import static java.lang.Math.abs; + import android.annotation.BinderThread; import android.annotation.Nullable; import android.content.Context; @@ -334,8 +336,8 @@ public class BubbleBarController extends IBubblesListener.Stub { // TODO: (b/273316505) handle suppression } if (update.selectedBubbleKey != null) { - if (mSelectedBubble != null - && !update.selectedBubbleKey.equals(mSelectedBubble.getKey())) { + if (mSelectedBubble == null + || !update.selectedBubbleKey.equals(mSelectedBubble.getKey())) { BubbleBarBubble newlySelected = mBubbles.get(update.selectedBubbleKey); if (newlySelected != null) { bubbleToSelect = newlySelected; @@ -360,12 +362,11 @@ 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]); + getBubbleBarOffsetX(), getBubbleBarOffsetY()); } else { Log.w(TAG, "Trying to show the selected bubble but it's null"); } @@ -520,4 +521,13 @@ public class BubbleBarController extends IBubblesListener.Stub { return mIconFactory.createBadgedIconBitmap(drawable).icon; } + + private int getBubbleBarOffsetY() { + final int translation = (int) abs(mBubbleStashController.getBubbleBarTranslationY()); + return translation + mBarView.getHeight(); + } + + private int getBubbleBarOffsetX() { + return mBarView.getWidth() + mBarView.getHorizontalMargin(); + } } diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index 563ba02a42..6643b48058 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -223,6 +223,12 @@ public class BubbleBarView extends FrameLayout { setLayoutParams(lp); } + /** @return the horizontal margin between the bubble bar and the edge of the screen. */ + int getHorizontalMargin() { + LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams(); + return lp.getMarginEnd(); + } + /** * Updates the z order, positions, and badge visibility of the bubble views in the bar based * on the expanded state. diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleStashController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleStashController.java index 5177d932f1..c995b4c26e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleStashController.java @@ -309,4 +309,9 @@ public class BubbleStashController { return -hotseatBottomSpace - hotseatCellHeight + mUnstashedHeight - abs( hotseatCellHeight - mUnstashedHeight) / 2; } + + float getBubbleBarTranslationY() { + return mBubblesShowingOnHome ? getBubbleBarTranslationYForHotseat() + : getBubbleBarTranslationYForTaskbar(); + } } diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index d2e7fb54f3..60784f5854 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -646,13 +646,15 @@ public class SystemUiProxy implements ISystemUiProxy { /** * Tells SysUI to show the bubble with the provided key. * @param key the key of the bubble to show. - * @param bubbleBarXCoordinate the X coordinate of the bubble bar on the screen. - * @param bubbleBarYCoordinate the Y coordinate of the bubble bar on the screen. + * @param bubbleBarOffsetX the offset of the bubble bar from the edge of the screen on the X + * axis. + * @param bubbleBarOffsetY the offset of the bubble bar from the edge of the screen on the Y + * axis. */ - public void showBubble(String key, int bubbleBarXCoordinate, int bubbleBarYCoordinate) { + public void showBubble(String key, int bubbleBarOffsetX, int bubbleBarOffsetY) { if (mBubbles != null) { try { - mBubbles.showBubble(key, bubbleBarXCoordinate, bubbleBarYCoordinate); + mBubbles.showBubble(key, bubbleBarOffsetX, bubbleBarOffsetY); } catch (RemoteException e) { Log.w(TAG, "Failed call showBubble"); }