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
@@ -18,6 +18,7 @@ package com.android.launcher3.taskbar.bubbles;
import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.NonNull;
@@ -560,30 +561,52 @@ public class BubbleBarView extends FrameLayout {
// First animator hides the bar.
// After it completes, bubble positions in the bar and arrow position is updated.
// Second animator is started to show the bar.
ObjectAnimator alphaOutAnim = ObjectAnimator.ofFloat(
this, getLocationAnimAlphaProperty(), 0f);
mBubbleBarLocationAnimator = BarsLocationAnimatorHelper.getBubbleBarLocationOutAnimator(
this,
bubbleBarLocation,
alphaOutAnim);
mBubbleBarLocationAnimator = animateToBubbleBarLocationOut(bubbleBarLocation);
mBubbleBarLocationAnimator.addListener(AnimatorListeners.forEndCallback(() -> {
updateBubblesLayoutProperties(bubbleBarLocation);
mBubbleBarBackground.setAnchorLeft(bubbleBarLocation.isOnLeft(isLayoutRtl()));
ObjectAnimator alphaInAnim = ObjectAnimator.ofFloat(BubbleBarView.this,
getLocationAnimAlphaProperty(), 1f);
// Animate it in
mBubbleBarLocationAnimator = BarsLocationAnimatorHelper.getBubbleBarLocationInAnimator(
bubbleBarLocation,
mBubbleBarLocation,
getDistanceFromOtherSide(),
alphaInAnim,
BubbleBarView.this);
mBubbleBarLocationAnimator = animateToBubbleBarLocationIn(mBubbleBarLocation,
bubbleBarLocation);
mBubbleBarLocationAnimator.start();
}));
mBubbleBarLocationAnimator.start();
}
/** Creates animator for animating bubble bar in. */
public Animator animateToBubbleBarLocationIn(BubbleBarLocation fromLocation,
BubbleBarLocation toLocation) {
updateBubblesLayoutProperties(toLocation);
mBubbleBarBackground.setAnchorLeft(toLocation.isOnLeft(isLayoutRtl()));
ObjectAnimator alphaInAnim = ObjectAnimator.ofFloat(BubbleBarView.this,
getLocationAnimAlphaProperty(), 1f);
return BarsLocationAnimatorHelper.getBubbleBarLocationInAnimator(toLocation, fromLocation,
getDistanceFromOtherSide(), alphaInAnim, this);
}
/**
* Creates animator for animating bubble bar out.
*
* @param targetLocation the location bubble br should animate to.
*/
public Animator animateToBubbleBarLocationOut(BubbleBarLocation targetLocation) {
ObjectAnimator alphaOutAnim = ObjectAnimator.ofFloat(
this, getLocationAnimAlphaProperty(), 0f);
Animator outAnimation = BarsLocationAnimatorHelper.getBubbleBarLocationOutAnimator(
this,
targetLocation,
alphaOutAnim);
outAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(@NonNull Animator animation, boolean isReverse) {
// need to restore the original bar view state in case icon is dropped to the bubble
// bar original location
updateBubblesLayoutProperties(targetLocation);
mBubbleBarBackground.setAnchorLeft(targetLocation.isOnLeft(isLayoutRtl()));
setTranslationX(0f);
}
});
return outAnimation;
}
/**
* Get property that can be used to animate the alpha value for the bar.
* When a bubble is being dragged, uses {@link #BUBBLE_DRAG_ALPHA}.