From f3224cf8472e4a4e24c780bfc038bc15ffc06384 Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Wed, 8 May 2024 14:05:03 -0700 Subject: [PATCH] Update expanded view drop target size based on value from shell When a bubble drag starts, shell sends the current expanded view size over as part of BubbleBarData. Update the size stored in BubblePinController based on latest value. Update drop target visual to match the spec. It should have 24dp insets compared to expanded view and 28dp corner radius. Bug: 330585402 Test: drag bubble in landscape, check that drop target for expanded view matches with what is shown when expanded view is dragged Test: drag bubble in portrait, check that the drop target for expanded view, matches with what is shown when expanded view is dragged Flag: ACONFIG com.android.wm.shell.enable_bubble_bar DEVELOPMENT Change-Id: Ic11c4c5c675107543ba08f24a4138cda422d24c1 --- .../bg_bubble_expanded_view_drop_target.xml | 19 +++++++++++-------- .../bubble_expanded_view_drop_target.xml | 4 ++-- quickstep/res/values/dimens.xml | 6 ++++-- .../taskbar/bubbles/BubbleBarController.java | 7 +++++++ .../taskbar/bubbles/BubblePinController.kt | 16 +++++++++++++++- 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/quickstep/res/drawable/bg_bubble_expanded_view_drop_target.xml b/quickstep/res/drawable/bg_bubble_expanded_view_drop_target.xml index 98aab67987..d722dd7f94 100644 --- a/quickstep/res/drawable/bg_bubble_expanded_view_drop_target.xml +++ b/quickstep/res/drawable/bg_bubble_expanded_view_drop_target.xml @@ -13,12 +13,15 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - - - - + android:inset="@dimen/bubble_expanded_view_drop_target_padding"> + + + + + + diff --git a/quickstep/res/layout/bubble_expanded_view_drop_target.xml b/quickstep/res/layout/bubble_expanded_view_drop_target.xml index 15ec49a6b0..3bd5d31dd5 100644 --- a/quickstep/res/layout/bubble_expanded_view_drop_target.xml +++ b/quickstep/res/layout/bubble_expanded_view_drop_target.xml @@ -16,8 +16,8 @@ \ No newline at end of file diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index c5f25ad87e..aea460247e 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -456,8 +456,10 @@ 36dp - 16dp - 412dp + 412dp + 600dp + 28dp + 24dp 16dp diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java index 8c83508ad9..90e0108b40 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java @@ -150,6 +150,7 @@ public class BubbleBarController extends IBubblesListener.Stub { private BubbleBarViewController mBubbleBarViewController; private BubbleStashController mBubbleStashController; private BubbleStashedHandleViewController mBubbleStashedHandleViewController; + private BubblePinController mBubblePinController; // Keep track of bubble bar bounds sent to shell to avoid sending duplicate updates private final Rect mLastSentBubbleBarBounds = new Rect(); @@ -169,6 +170,7 @@ public class BubbleBarController extends IBubblesListener.Stub { BubbleBarLocation bubbleBarLocation; List removedBubbles; List bubbleKeysInOrder; + Point expandedViewDropTargetSize; // These need to be loaded in the background BubbleBarBubble addedBubble; @@ -186,6 +188,7 @@ public class BubbleBarController extends IBubblesListener.Stub { bubbleBarLocation = update.bubbleBarLocation; removedBubbles = update.removedBubbles; bubbleKeysInOrder = update.bubbleKeysInOrder; + expandedViewDropTargetSize = update.expandedViewDropTargetSize; } } @@ -216,6 +219,7 @@ public class BubbleBarController extends IBubblesListener.Stub { mBubbleBarViewController = bubbleControllers.bubbleBarViewController; mBubbleStashController = bubbleControllers.bubbleStashController; mBubbleStashedHandleViewController = bubbleControllers.bubbleStashedHandleViewController; + mBubblePinController = bubbleControllers.bubblePinController; bubbleControllers.runAfterInit(() -> { mBubbleBarViewController.setHiddenForBubbles( @@ -419,6 +423,9 @@ public class BubbleBarController extends IBubblesListener.Stub { updateBubbleBarLocationInternal(update.bubbleBarLocation); } } + if (update.expandedViewDropTargetSize != null) { + mBubblePinController.setDropTargetSize(update.expandedViewDropTargetSize); + } } /** Tells WMShell to show the currently selected bubble. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubblePinController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubblePinController.kt index fef7fa1dd5..a77e685d00 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubblePinController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubblePinController.kt @@ -37,12 +37,17 @@ class BubblePinController( screenSizeProvider: () -> Point ) : BaseBubblePinController(screenSizeProvider) { + var dropTargetSize: Point? = null + private lateinit var bubbleBarViewController: BubbleBarViewController private lateinit var bubbleStashController: BubbleStashController private var exclRectWidth: Float = 0f private var exclRectHeight: Float = 0f private var dropTargetView: View? = null + // Fallback width and height in case shell has not sent the size over + private var dropTargetDefaultWidth: Int = 0 + private var dropTargetDefaultHeight: Int = 0 private var dropTargetMargin: Int = 0 fun init(bubbleControllers: BubbleControllers) { @@ -50,6 +55,14 @@ class BubblePinController( bubbleStashController = bubbleControllers.bubbleStashController exclRectWidth = context.resources.getDimension(R.dimen.bubblebar_dismiss_zone_width) exclRectHeight = context.resources.getDimension(R.dimen.bubblebar_dismiss_zone_height) + dropTargetDefaultWidth = + context.resources.getDimensionPixelSize( + R.dimen.bubble_expanded_view_drop_target_default_width + ) + dropTargetDefaultHeight = + context.resources.getDimensionPixelSize( + R.dimen.bubble_expanded_view_drop_target_default_height + ) dropTargetMargin = context.resources.getDimensionPixelSize(R.dimen.bubble_expanded_view_drop_target_margin) } @@ -75,7 +88,6 @@ class BubblePinController( return LayoutInflater.from(context) .inflate(R.layout.bubble_expanded_view_drop_target, container, false) .also { view -> - // TODO(b/330585402): dynamic height for the drop target based on actual height dropTargetView = view container.addView(view) } @@ -88,6 +100,8 @@ class BubblePinController( val bubbleBarBounds = bubbleBarViewController.bubbleBarBounds dropTargetView?.updateLayoutParams { gravity = BOTTOM or (if (onLeft) LEFT else RIGHT) + width = dropTargetSize?.x ?: dropTargetDefaultWidth + height = dropTargetSize?.y ?: dropTargetDefaultHeight bottomMargin = -bubbleStashController.bubbleBarTranslationY.toInt() + bubbleBarBounds.height() +