From 6b18e3811de1cfe7bb4a1bedc000352c8799099c Mon Sep 17 00:00:00 2001 From: Liran Binyamin Date: Wed, 5 Mar 2025 10:04:58 -0800 Subject: [PATCH] Handle bubble bar drag and bubble drag to fullscreen This change wires bubble bar dragging as well as bubble dragging to full screen behind a flag. Note that when the bubble is dragged to full screen we remove the bubble from the bubble bar and notify sysui but on the sysui side the bubble doesn't yet get converted. Flag: com.android.wm.shell.enable_bubble_to_fullscreen Bug: 388858013 Test: manual - with flag off - verify existing dragging works - with flag on - verify bubble bar can be dragged across - verify bubble is removed when bubble dragged to full screen zone Change-Id: I9e4d8ee3d2ba9dffff3dd4ba91dfce1a5c723d68 --- .../bubbles/BubbleBarViewController.java | 13 +++ .../taskbar/bubbles/BubbleDragController.java | 93 ++++++++++++++++--- .../com/android/quickstep/SystemUiProxy.kt | 7 ++ 3 files changed, 98 insertions(+), 15 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index 2aa5925c4f..277dbbf677 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -1360,6 +1360,19 @@ public class BubbleBarViewController { mTaskbarDragController.removeDropTarget(mBubbleBarRightDropTarget); } + /** + * Removes the bubble from the bubble bar and notifies sysui that the bubble should move to + * full screen. + */ + public void moveBubbleToFullscreen(@NonNull BubbleView bubbleView) { + if (bubbleView.getBubble() == null) { + return; + } + String key = bubbleView.getBubble().getKey(); + mSystemUiProxy.moveBubbleToFullscreen(key); + onBubbleDismissed(bubbleView); + } + /** * Create an animator for showing or hiding bubbles when stashed state changes * diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java index a76b572c4d..f77b934373 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java @@ -204,10 +204,19 @@ public class BubbleDragController { protected void onDragRelease() { if (BubbleAnythingFlagHelper.enableBubbleToFullscreen()) { mDropTargetManager.onDragEnded(); + if (!mBubbleDragZoneChangedListener.isDraggedToFullscreen()) { + // TODO b/393173014: check for desktop window and split once they're + // implemented. this notifies wm shell that the dragged bubble was + // released so that we can show the expanded view. we only want to show it + // after releasing in a Bubble zone. But Split and Desktop Window aren't + // implemented yet, so we only check for full screen for now. + mBubbleBarViewController.onBubbleDragRelease( + getBubbleBarLocationDuringDrag()); + } } else { mBubblePinController.onDragEnd(); + mBubbleBarViewController.onBubbleDragRelease(getBubbleBarLocationDuringDrag()); } - mBubbleBarViewController.onBubbleDragRelease(getBubbleBarLocationDuringDrag()); } @Override @@ -225,12 +234,15 @@ public class BubbleDragController { void onDragEnd() { mBubbleBarController.updateBubbleBarLocation(getBubbleBarLocationDuringDrag(), BubbleBarLocation.UpdateSource.DRAG_BUBBLE); - mBubbleBarViewController.onBubbleDragEnd(); if (BubbleAnythingFlagHelper.enableBubbleToFullscreen()) { mDropTargetManager.onDragEnded(); + if (mBubbleDragZoneChangedListener.isDraggedToFullscreen()) { + mBubbleBarViewController.moveBubbleToFullscreen(bubbleView); + } } else { mBubblePinController.setListener(null); } + mBubbleBarViewController.onBubbleDragEnd(); } @Override @@ -254,6 +266,12 @@ public class BubbleDragController { private final LocationChangeListener mLocationChangeListener = location -> mReleasedLocation = location; + private BubbleBarLocation getBubbleBarLocationDuringDrag() { + return BubbleAnythingFlagHelper.enableBubbleToFullscreen() + ? mBubbleDragZoneChangedListener.mBubbleBarLocation + : mReleasedLocation; + } + @Override protected boolean onTouchDown(@NonNull View view, @NonNull MotionEvent event) { if (bubbleBarView.isExpanded()) return false; @@ -262,50 +280,74 @@ public class BubbleDragController { @Override void onDragStart() { - mBubbleBarPinController.setListener(mLocationChangeListener); initialRelativePivot.set(bubbleBarView.getRelativePivotX(), bubbleBarView.getRelativePivotY()); // By default the bubble bar view pivot is in bottom right corner, while dragging // it should be centered in order to align it with the dismiss target view bubbleBarView.setRelativePivot(/* x = */ 0.5f, /* y = */ 0.5f); bubbleBarView.setIsDragging(true); - mBubbleBarPinController.onDragStart( - bubbleBarView.getBubbleBarLocation().isOnLeft(bubbleBarView.isLayoutRtl())); + if (BubbleAnythingFlagHelper.enableBubbleToFullscreen()) { + DraggedObject.BubbleBar draggedBubbleBar = new DraggedObject.BubbleBar( + mBubbleBarViewController.getBubbleBarLocation()); + mDropTargetManager.onDragStarted(draggedBubbleBar, + mDragZoneFactory.createSortedDragZones(draggedBubbleBar)); + } else { + mBubbleBarPinController.setListener(mLocationChangeListener); + mBubbleBarPinController.onDragStart( + bubbleBarView.getBubbleBarLocation().isOnLeft( + bubbleBarView.isLayoutRtl())); + } } @Override protected void onDragUpdate(float x, float y, float newTx, float newTy) { bubbleBarView.setTranslationX(newTx); bubbleBarView.setTranslationY(newTy); - mBubbleBarPinController.onDragUpdate(x, y); + if (BubbleAnythingFlagHelper.enableBubbleToFullscreen()) { + mDropTargetManager.onDragUpdated((int) x, (int) y); + } else { + mBubbleBarPinController.onDragUpdate(x, y); + } } @Override protected void onDragRelease() { - mBubbleBarPinController.onDragEnd(); + if (BubbleAnythingFlagHelper.enableBubbleToFullscreen()) { + mDropTargetManager.onDragEnded(); + } else { + mBubbleBarPinController.onDragEnd(); + } } @Override protected void onDragDismiss() { - mBubbleBarPinController.onDragEnd(); + if (BubbleAnythingFlagHelper.enableBubbleToFullscreen()) { + mDropTargetManager.onDragEnded(); + } else { + mBubbleBarPinController.onDragEnd(); + } } @Override void onDragEnd() { // Make sure to update location as the first thing. Pivot update causes a relayout - mBubbleBarController.updateBubbleBarLocation(mReleasedLocation, + mBubbleBarController.updateBubbleBarLocation(getBubbleBarLocationDuringDrag(), BubbleBarLocation.UpdateSource.DRAG_BAR); bubbleBarView.setIsDragging(false); // Restoring the initial pivot for the bubble bar view bubbleBarView.setRelativePivot(initialRelativePivot.x, initialRelativePivot.y); mBubbleBarViewController.onBubbleBarDragEnd(); - mBubbleBarPinController.setListener(null); + if (BubbleAnythingFlagHelper.enableBubbleToFullscreen()) { + mDropTargetManager.onDragEnded(); + } else { + mBubbleBarPinController.setListener(null); + } } @Override protected PointF getRestingPosition() { return mBubbleBarViewController.getBubbleBarDragReleaseTranslation( - getInitialPosition(), mReleasedLocation); + getInitialPosition(), getBubbleBarLocationDuringDrag()); } }); } @@ -545,8 +587,17 @@ public class BubbleDragController { mAnimator.animateDismiss(mViewInitialPosition, onComplete); } else { onDragRelease(); - mAnimator.animateToRestingState(getRestingPosition(), getCurrentVelocity(), + if (BubbleAnythingFlagHelper.enableBubbleToFullscreen()) { + if (mBubbleDragZoneChangedListener.isDraggedToFullscreen()) { + onComplete.run(); + } else { + mAnimator.animateToRestingState(getRestingPosition(), getCurrentVelocity(), + onComplete); + } + } else { + mAnimator.animateToRestingState(getRestingPosition(), getCurrentVelocity(), onComplete); + } } mBubbleDismissController.hideDismissView(); } @@ -590,9 +641,15 @@ public class BubbleDragController { private class BubbleDragZoneChangedListener implements DragZoneChangedListener { private BubbleBarLocation mBubbleBarLocation = BubbleBarLocation.DEFAULT; + private DragZone mDragZone; + + boolean isDraggedToFullscreen() { + return mDragZone instanceof DragZone.FullScreen; + } @Override public void onInitialDragZoneSet(@NonNull DragZone dragZone) { + mDragZone = dragZone; if (dragZone instanceof DragZone.Bubble.Left) { mBubbleBarLocation = BubbleBarLocation.LEFT; } else if (dragZone instanceof DragZone.Bubble.Right) { @@ -601,14 +658,20 @@ public class BubbleDragController { } @Override - public void onDragZoneChanged(@NonNull DragZone from, @NonNull DragZone to) { + public void onDragZoneChanged(@NonNull DraggedObject draggedObject, @NonNull DragZone from, + @NonNull DragZone to) { + mDragZone = to; if (to instanceof DragZone.Bubble.Left && mBubbleBarLocation != BubbleBarLocation.LEFT) { - mBubbleBarController.animateBubbleBarLocation(BubbleBarLocation.LEFT); + if (draggedObject instanceof DraggedObject.Bubble) { + mBubbleBarController.animateBubbleBarLocation(BubbleBarLocation.LEFT); + } mBubbleBarLocation = BubbleBarLocation.LEFT; } else if (to instanceof DragZone.Bubble.Right && mBubbleBarLocation != BubbleBarLocation.RIGHT) { - mBubbleBarController.animateBubbleBarLocation(BubbleBarLocation.RIGHT); + if (draggedObject instanceof DraggedObject.Bubble) { + mBubbleBarController.animateBubbleBarLocation(BubbleBarLocation.RIGHT); + } mBubbleBarLocation = BubbleBarLocation.RIGHT; } } diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.kt b/quickstep/src/com/android/quickstep/SystemUiProxy.kt index 1de696660c..d6f654004b 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.kt +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.kt @@ -690,6 +690,13 @@ class SystemUiProxy @Inject constructor(@ApplicationContext private val context: bubbles?.showDropTarget(show, bubbleBarLocation) } + /** Tells SysUI to move the bubble to full screen. */ + fun moveBubbleToFullscreen(key: String) { + executeWithErrorLog({ "Failed to call moveBubbleToFullscreen"}) { + bubbles?.moveBubbleToFullscreen(key) + } + } + // // Splitscreen //