From 04ab640572127e5d7da280f88ec91eeb01c62914 Mon Sep 17 00:00:00 2001 From: Joshua Tsuji Date: Wed, 20 May 2020 14:54:34 -0400 Subject: [PATCH] Prevent conflicting animations from starting. This will prevent the stack from becoming separated and confused in some situations. The root cause was that the BubbleStackView returned false by default in its touch handler, which allowed the bubble views to grab touch events they shouldn't have and start animations. However, those bubbles trying to start the animations should have been prevented by the active controller logic, but it wasn't due to a missing check. Might as well fix both causes! Also, cancel the path animator before starting a new one just in case. Fixes: 155499044 Test: manual Change-Id: Idbdb68dfe3cccc69ae3709faad8d3b7078b354a9 --- .../src/com/android/systemui/bubbles/BubbleStackView.java | 2 +- .../systemui/bubbles/animation/PhysicsAnimationLayout.java | 4 ++++ .../bubbles/animation/StackAnimationController.java | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java index c97ca2b9d8f81..e69fe31fa9e1b 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java @@ -879,7 +879,7 @@ public class BubbleStackView extends FrameLayout } } - return false; + return true; }); } 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 a7d1be1a766ae..942b9a74bb861 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/PhysicsAnimationLayout.java @@ -767,6 +767,10 @@ public class PhysicsAnimationLayout extends FrameLayout { int targetAnimDuration, TimeInterpolator targetAnimInterpolator, Runnable... pathAnimEndActions) { + if (mPathAnimator != null) { + mPathAnimator.cancel(); + } + mPathAnimator = ObjectAnimator.ofFloat( this, mCurrentPointOnPathXProperty, mCurrentPointOnPathYProperty, path); 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 8318c21ad4cf9..69db5c35a1701 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java @@ -459,6 +459,10 @@ public class StackAnimationController extends float friction, SpringForce spring, Float finalPosition) { + if (!isActiveController()) { + return; + } + Log.d(TAG, String.format("Flinging %s.", PhysicsAnimationLayout.getReadablePropertyName(property))); @@ -679,7 +683,7 @@ public class StackAnimationController extends DynamicAnimation.ViewProperty property, SpringForce spring, float vel, float finalPosition, @Nullable Runnable... after) { - if (mLayout.getChildCount() == 0) { + if (mLayout.getChildCount() == 0 || !isActiveController()) { return; }