diff options
2 files changed, 41 insertions, 8 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java index 0002e862bb41..35406c71a080 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java @@ -128,17 +128,31 @@ public class ExpandedAnimationController */ private boolean mBubbleDraggedOutEnough = false; + /** End action to run when the lead bubble's expansion animation completes. */ + @Nullable private Runnable mLeadBubbleEndAction; + /** - * Animates expanding the bubbles into a row along the top of the screen. + * Animates expanding the bubbles into a row along the top of the screen, optionally running an + * end action when the entire animation completes, and an end action when the lead bubble's + * animation ends. */ - public void expandFromStack(@Nullable Runnable after) { + public void expandFromStack( + @Nullable Runnable after, @Nullable Runnable leadBubbleEndAction) { mAnimatingCollapse = false; mAnimatingExpand = true; mAfterExpand = after; + mLeadBubbleEndAction = leadBubbleEndAction; startOrUpdatePathAnimation(true /* expanding */); } + /** + * Animates expanding the bubbles into a row along the top of the screen. + */ + public void expandFromStack(@Nullable Runnable after) { + expandFromStack(after, null /* leadBubbleEndAction */); + } + /** Animate collapsing the bubbles back to their stacked position. */ public void collapseBackToStack(PointF collapsePoint, Runnable after) { mAnimatingExpand = false; @@ -237,11 +251,17 @@ public class ExpandedAnimationController ? (index * 10) : ((mLayout.getChildCount() - index) * 10); + final boolean isLeadBubble = + (firstBubbleLeads && index == 0) + || (!firstBubbleLeads && index == mLayout.getChildCount() - 1); + animation .followAnimatedTargetAlongPath( path, EXPAND_COLLAPSE_TARGET_ANIM_DURATION /* targetAnimDuration */, - Interpolators.LINEAR /* targetAnimInterpolator */) + Interpolators.LINEAR /* targetAnimInterpolator */, + isLeadBubble ? mLeadBubbleEndAction : null /* endAction */, + () -> mLeadBubbleEndAction = null /* endAction */) .withStartDelay(startDelay) .withStiffness(EXPAND_COLLAPSE_ANIM_STIFFNESS); }).startAll(after); diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java index b1bbafc1ed8f..a7d1be1a766a 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java @@ -758,21 +758,34 @@ public class PhysicsAnimationLayout extends FrameLayout { * or {@link #position}, ultimately animating the view's position to the final point on the * given path. * - * Any provided end listeners will be called when the physics-based animations kicked off by - * the moving target have completed - not when the target animation completes. + * @param pathAnimEndActions End actions to run after the animator that moves the target + * along the path ends. The views following the target may still + * be moving. */ public PhysicsPropertyAnimator followAnimatedTargetAlongPath( Path path, int targetAnimDuration, TimeInterpolator targetAnimInterpolator, - Runnable... endActions) { + Runnable... pathAnimEndActions) { mPathAnimator = ObjectAnimator.ofFloat( this, mCurrentPointOnPathXProperty, mCurrentPointOnPathYProperty, path); + + if (pathAnimEndActions != null) { + mPathAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + for (Runnable action : pathAnimEndActions) { + if (action != null) { + action.run(); + } + } + } + }); + } + mPathAnimator.setDuration(targetAnimDuration); mPathAnimator.setInterpolator(targetAnimInterpolator); - mPositionEndActions = endActions; - // Remove translation related values since we're going to ignore them and follow the // path instead. clearTranslationValues(); |