Animate the stash handle for new bubbles

The stash handle now animates out before the new bubble animates in, and animates back in after the new bubble is hidden.
There's still some additional polish needed :)

Demo: http://recall/-/bJtug1HhvXkkeA4MQvIaiP/z30Ob1rcDUkNEphLAQsgV

Flag: ACONFIG com.android.wm.shell.enable_bubble_bar DEVELOPMENT
Bug: 280605846
Test: atest BubbleBarViewAnimatorTest
Change-Id: I03449286b01ec96de9834e24a707652ddbe49fb0
This commit is contained in:
Liran Binyamin
2024-04-02 15:44:26 -04:00
parent 966156e363
commit 597ced3033
5 changed files with 224 additions and 34 deletions
@@ -29,6 +29,7 @@ import android.view.View;
import android.view.ViewOutlineProvider;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.anim.RevealOutlineAnimation;
import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
import com.android.launcher3.taskbar.StashedHandleView;
@@ -47,7 +48,7 @@ public class BubbleStashedHandleViewController {
private final TaskbarActivityContext mActivity;
private final StashedHandleView mStashedHandleView;
private final MultiValueAlpha mTaskbarStashedHandleAlpha;
private final MultiValueAlpha mStashedHandleAlpha;
// Initialized in init.
private BubbleBarViewController mBarViewController;
@@ -58,6 +59,12 @@ public class BubbleStashedHandleViewController {
private int mStashedHandleWidth;
private int mStashedHandleHeight;
private final AnimatedFloat mStashedHandleTranslationY =
new AnimatedFloat(this::updateTranslationY);
// Modified when swipe up is happening on the stashed handle or task bar.
private float mSwipeUpTranslationY;
// The bounds we want to clip to in the settled state when showing the stashed handle.
private final Rect mStashedHandleBounds = new Rect();
@@ -75,7 +82,7 @@ public class BubbleStashedHandleViewController {
StashedHandleView stashedHandleView) {
mActivity = activity;
mStashedHandleView = stashedHandleView;
mTaskbarStashedHandleAlpha = new MultiValueAlpha(mStashedHandleView, 1);
mStashedHandleAlpha = new MultiValueAlpha(mStashedHandleView, 1);
}
public void init(TaskbarControllers controllers, BubbleControllers bubbleControllers) {
@@ -93,7 +100,7 @@ public class BubbleStashedHandleViewController {
R.dimen.transient_taskbar_bottom_margin);
mStashedHandleView.getLayoutParams().height = mBarSize + bottomMargin;
mTaskbarStashedHandleAlpha.get(0).setValue(0);
mStashedHandleAlpha.get(0).setValue(0);
mStashedTaskbarHeight = resources.getDimensionPixelSize(
R.dimen.bubblebar_stashed_size);
@@ -231,18 +238,33 @@ public class BubbleStashedHandleViewController {
}
}
/** Returns an animator for translation Y. */
public AnimatedFloat getStashedHandleTranslationY() {
return mStashedHandleTranslationY;
}
/**
* Sets the translation of the stashed handle during the swipe up gesture.
*/
public void setTranslationYForSwipe(float transY) {
mStashedHandleView.setTranslationY(transY);
mSwipeUpTranslationY = transY;
updateTranslationY();
}
private void updateTranslationY() {
mStashedHandleView.setTranslationY(mStashedHandleTranslationY.value + mSwipeUpTranslationY);
}
/**
* Used by {@link BubbleStashController} to animate the handle when stashing or un stashing.
*/
public MultiPropertyFactory<View> getStashedHandleAlpha() {
return mTaskbarStashedHandleAlpha;
return mStashedHandleAlpha;
}
/** Returns the x position of the center of the stashed handle. */
public float getStashedHandleCenterX() {
return mStashedHandleBounds.exactCenterX();
}
/**