Drag and drop from the search view on the overview screen.

When the bubble bar is stashed and an icon is dragged from the search
grid towards it, the bubble bar should be un-stashed. Conversely, if the
icon is dragged to the opposite location of the stashed bubble bar, the
handle should teleport out, and the collapsed bubble bar should
teleport in.
This change implements logic that addresses this behavior.

Bug: 399678274
Test: Manual. Drag and drop application icons from the search grid to
the bubble bar drop areas.
Flag: com.android.wm.shell.enable_create_any_bubble

Change-Id: Ief9ef3e5c24f8199b2812fd0adf63ae3f6cf8f32
This commit is contained in:
Mykola Podolian
2025-03-20 09:39:35 -07:00
parent 3a4595c207
commit 6ddfa5dfd5
7 changed files with 255 additions and 78 deletions
@@ -194,9 +194,11 @@ public class BubbleBarViewController {
private boolean mHiddenForStashed;
private boolean mShouldShowEducation;
public boolean mOverflowAdded;
private boolean mIsLocationUpdatedForDropTarget = false;
private boolean mWasStashedBeforeEnteringBubbleDragZone = false;
/** This field is used solely to track the bubble bar location prior to the start of the drag */
private @Nullable BubbleBarLocation mBubbleBarDragLocation;
private BubbleBarViewAnimator mBubbleBarViewAnimator;
private final FrameLayout mBubbleBarContainer;
private BubbleBarFlyoutController mBubbleBarFlyoutController;
@@ -364,7 +366,7 @@ public class BubbleBarViewController {
@Override
public boolean isOnLeft() {
boolean shouldRevertLocation =
mBarView.isShowingDropTarget() && mIsLocationUpdatedForDropTarget;
mBarView.isShowingDropTarget() && isLocationUpdatedForDropTarget();
boolean isOnLeft = mBarView.getBubbleBarLocation().isOnLeft(mBarView.isLayoutRtl());
return shouldRevertLocation != isOnLeft;
}
@@ -616,6 +618,17 @@ public class BubbleBarViewController {
mBarView.animateToBubbleBarLocation(bubbleBarLocation);
}
/** Return animator for animating bubble bar in. */
public Animator animateBubbleBarLocationIn(BubbleBarLocation fromLocation,
BubbleBarLocation toLocation) {
return mBarView.animateToBubbleBarLocationIn(fromLocation, toLocation);
}
/** Return animator for animating bubble bar out. */
public Animator animateBubbleBarLocationOut(BubbleBarLocation toLocation) {
return mBarView.animateToBubbleBarLocationOut(toLocation);
}
/** Returns whether the Bubble Bar is currently displaying a drop target. */
public boolean isShowingDropTarget() {
return mBarView.isShowingDropTarget();
@@ -628,25 +641,18 @@ public class BubbleBarViewController {
* updated.
*/
public void onDragItemOverBubbleBarDragZone(@NonNull BubbleBarLocation bubbleBarLocation) {
Log.w("BBAnimation", "onDragItemOverBubbleBarDragZone()");
mBubbleBarDragLocation = bubbleBarLocation;
mBarView.showDropTarget(/* isDropTarget = */ true);
boolean isRtl = mBarView.isLayoutRtl();
mIsLocationUpdatedForDropTarget = getBubbleBarLocation().isOnLeft(isRtl)
!= bubbleBarLocation.isOnLeft(isRtl);
mWasStashedBeforeEnteringBubbleDragZone = hasBubbles()
&& mBubbleStashController.isStashed();
if (mWasStashedBeforeEnteringBubbleDragZone) {
if (mIsLocationUpdatedForDropTarget) {
// bubble bar is stashed an location updated
//TODO(b/399678274) add animation
mBubbleStashController.showBubbleBarImmediate();
animateBubbleBarLocation(bubbleBarLocation);
} else {
// bubble bar is stashed and location the same - just un-stash
mBubbleStashController.showBubbleBar(/* expandBubbles = */ false);
}
// bubble bar is stashed - un-stash at drag location
mBubbleStashController.showBubbleBarAtLocation(
/* fromLocation = */ getBubbleBarLocation(),
/* toLocation = */ mBubbleBarDragLocation
);
} else if (hasBubbles()) {
if (mIsLocationUpdatedForDropTarget) {
if (isLocationUpdatedForDropTarget()) {
// bubble bar has bubbles and location is changed - animate bar to the opposite side
animateBubbleBarLocation(bubbleBarLocation);
}
@@ -661,7 +667,12 @@ public class BubbleBarViewController {
* {@link #onDragItemOverBubbleBarDragZone}}.
*/
public boolean isLocationUpdatedForDropTarget() {
return mIsLocationUpdatedForDropTarget;
if (mBubbleBarDragLocation == null) {
return false;
}
boolean isRtl = mBarView.isLayoutRtl();
return getBubbleBarLocation().isOnLeft(isRtl)
!= mBubbleBarDragLocation.isOnLeft(isRtl);
}
/**
@@ -671,39 +682,34 @@ public class BubbleBarViewController {
* mode and reset the value returned from {@link #isLocationUpdatedForDropTarget()} to false.
*/
public void onItemDraggedOutsideBubbleBarDropZone() {
Log.w("BBAnimation", "onItemDraggedOutsideBubbleBarDropZone()");
mBarView.showDropTarget(/* isDropTarget = */ false);
if (mWasStashedBeforeEnteringBubbleDragZone) {
if (mIsLocationUpdatedForDropTarget) {
// bubble bar was stashed and location updated
//TODO(b/399678274) add animation
animateBubbleBarLocation(getBubbleBarLocation());
mBubbleStashController.stashBubbleBarImmediate();
} else {
// bubble bar was stashed and location the same - just stash it back
mBubbleStashController.stashBubbleBar();
}
if (!isShowingDropTarget()) {
return;
}
if (mWasStashedBeforeEnteringBubbleDragZone && mBubbleBarDragLocation != null) {
// bubble bar was stashed - stash at original location
mBubbleStashController.stashBubbleBarToLocation(
/* fromLocation = */ mBubbleBarDragLocation,
/* toLocation = */ getBubbleBarLocation()
);
} else if (hasBubbles()) {
if (mIsLocationUpdatedForDropTarget) {
// bubble bar has bubbles and location was changed - return to the original location
if (isLocationUpdatedForDropTarget()) {
// bubble bar has bubbles and location was changed - return to the original
// location
animateBubbleBarLocation(getBubbleBarLocation());
}
}
mBubbleBarPinController.hideDropTarget();
mIsLocationUpdatedForDropTarget = false;
mWasStashedBeforeEnteringBubbleDragZone = false;
onItemDragCompleted();
}
/**
* Notifies the controller that the drag has completed over the Bubble Bar drop zone.
* The controller will hide the drop target if there are no bubbles and exit drop target mode.
*/
public void onItemDroppedInBubbleBarDragZone() {
Log.w("BBAnimation", "onItemDroppedInBubbleBarDragZone()");
public void onItemDragCompleted() {
mBarView.showDropTarget(/* isDropTarget = */ false);
mBubbleBarPinController.hideDropTarget();
mIsLocationUpdatedForDropTarget = false;
mWasStashedBeforeEnteringBubbleDragZone = false;
mBubbleBarDragLocation = null;
}
/**
@@ -842,6 +848,7 @@ public class BubbleBarViewController {
boolean hiddenForStashedAndNotAnimating =
mHiddenForStashed && !mBubbleBarViewAnimator.isAnimating();
if (mHiddenForSysui || mHiddenForNoBubbles || hiddenForStashedAndNotAnimating) {
//TODO(b/404870188) this visibility change cause search view drag misbehavior
mBarView.setVisibility(INVISIBLE);
} else {
mBarView.setVisibility(VISIBLE);