From c81cc482ddb72cdda0e8e7d47c1be6bd9f767f70 Mon Sep 17 00:00:00 2001 From: Joshua Tsuji Date: Thu, 21 May 2020 00:17:08 -0400 Subject: [PATCH] Don't save touch location as a resting position. When you drag bubbles out of the magnetic target, it springs towards your touch position to 'catch up', since it was stuck in the target away from the touch. However, unlike all other springs, this one should not save its end position as the stack resting position, since it's not a valid resting position. This one was hard to repro - you have to drag bubbles into the target, then quickly pull them out, back in, and release them before they catch up to your finger. If you do though, you'll end up with bubbles that come back in the middle of the screen. Test: mash on the dismiss target a bunch Bug: 155495386 Change-Id: I8ded5337a72fb52a851e7640d2b0fddb8453648a --- .../bubbles/animation/StackAnimationController.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java index 2cfe1dde0b51e..5eb5c6a6e6ac7 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java @@ -676,12 +676,22 @@ public class StackAnimationController extends PhysicsAnimationLayout.getReadablePropertyName(property), finalPosition)); + // Whether we're springing towards the touch location, rather than to a position on the + // sides of the screen. + final boolean isSpringingTowardsTouch = mSpringToTouchOnNextMotionEvent; + StackPositionProperty firstBubbleProperty = new StackPositionProperty(property); SpringAnimation springAnimation = new SpringAnimation(this, firstBubbleProperty) .setSpring(spring) .addEndListener((dynamicAnimation, b, v, v1) -> { - mRestingStackPosition.set(mStackPosition); + if (!isSpringingTowardsTouch) { + // If we're springing towards the touch position, don't save the + // resting position - the touch location is not a valid resting + // position. We'll set this when the stack springs to the left or + // right side of the screen after the touch gesture ends. + mRestingStackPosition.set(mStackPosition); + } if (after != null) { for (Runnable callback : after) {