Update new bubble animation

This change is a rewrite of the new bubble animation. Previously we chained the handle animation and the bubble animation so that they run sequentially.
That caused the transition from the handle to the bubble to be jarring.

We now use a single spring animation along the y axis that starts from the position of the handle to the position of where the bubble will end up.
The animation is split into 3 logical parts, where initially the bubble animates out, then the bubble starts animating in, and the last part is the overshoot of the spring animation, which is used to mark the bubble fully visible and ensure that from that point on, the bubble is only moving but doesn't change in scale or transparency as the bounce effect is playing.
Using a single animation path allows for a smooth transition from the handle to the bubble view.

Demo: http://recall/-/bJtug1HhvXkkeA4MQvIaiP/hHNUBdNJPiWi9gMbqy45UJ

Flag: ACONFIG com.android.wm.shell.enable_bubble_bar DEVELOPMENT
Bug: 280605846
Test: atest BubbleBarViewAnimatorTest
Change-Id: Ic1d3244574b8500d4aad2e9c718e61c1c34bd82a
This commit is contained in:
Liran Binyamin
2024-04-11 11:34:47 -04:00
parent adbdfe2ac7
commit e79120af38
4 changed files with 147 additions and 164 deletions
@@ -29,7 +29,6 @@ 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;
@@ -40,6 +39,7 @@ import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.systemui.shared.navigationbar.RegionSamplingHelper;
import com.android.wm.shell.common.bubbles.BubbleBarLocation;
import com.android.wm.shell.shared.animation.PhysicsAnimator;
/**
* Handles properties/data collection, then passes the results to our stashed handle View to render.
@@ -59,12 +59,6 @@ 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();
@@ -129,6 +123,11 @@ public class BubbleStashedHandleViewController {
updateBounds(mBarViewController.getBubbleBarLocation()));
}
/** Returns the [PhysicsAnimator] for the stashed handle view. */
public PhysicsAnimator<View> getPhysicsAnimator() {
return PhysicsAnimator.getInstance(mStashedHandleView);
}
private void updateBounds(BubbleBarLocation bubbleBarLocation) {
// As more bubbles get added, the icon bounds become larger. To ensure a consistent
// handle bar position, we pin it to the edge of the screen.
@@ -238,21 +237,11 @@ 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) {
mSwipeUpTranslationY = transY;
updateTranslationY();
}
private void updateTranslationY() {
mStashedHandleView.setTranslationY(mStashedHandleTranslationY.value + mSwipeUpTranslationY);
mStashedHandleView.setTranslationY(transY);
}
/**