summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Josh Tsuji <tsuji@google.com> 2020-06-12 12:51:19 -0400
committer Josh Tsuji <tsuji@google.com> 2020-06-12 12:57:10 -0400
commitd12d46a51e5f02c62dd0e6d06add07d269ebc7f5 (patch)
tree9df702fce55de45608ae593defc94189e574ea62
parent8140ae8d22d4165bc9a4c22e1b6e57d359c6fde8 (diff)
Don't animate reorder/add when we're about to collapse.
Fixes: 158658744 Test: expand the stack, select a different bubble, collapse the stack, observe no weird bubble swapping behavior Test: add a bubble while expanded, observe the bubbles still animate around as expected Change-Id: I585c0ed139d38e57e19014971259bc32787b9f35
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java52
2 files changed, 47 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index 015079ff900a..d5fe9b2953de 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -1822,6 +1822,10 @@ public class BubbleStackView extends FrameLayout
mExpandedBubble.getExpandedView().hideImeIfVisible();
}
+ // Let the expanded animation controller know that it shouldn't animate child adds/reorders
+ // since we're about to animate collapsed.
+ mExpandedAnimationController.notifyPreparingToCollapse();
+
final long startDelay =
(long) (ExpandedAnimationController.EXPAND_COLLAPSE_TARGET_ANIM_DURATION * 0.6f);
postDelayed(() -> mExpandedAnimationController.collapseBackToStack(
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 86fe10dddc2c..cb8995a72dc3 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
@@ -92,6 +92,14 @@ public class ExpandedAnimationController
private int mScreenOrientation;
private boolean mAnimatingExpand = false;
+
+ /**
+ * Whether we are animating other Bubbles UI elements out in preparation for a call to
+ * {@link #collapseBackToStack}. If true, we won't animate bubbles in response to adds or
+ * reorders.
+ */
+ private boolean mPreparingToCollapse = false;
+
private boolean mAnimatingCollapse = false;
private @Nullable Runnable mAfterExpand;
private Runnable mAfterCollapse;
@@ -150,6 +158,7 @@ public class ExpandedAnimationController
*/
public void expandFromStack(
@Nullable Runnable after, @Nullable Runnable leadBubbleEndAction) {
+ mPreparingToCollapse = false;
mAnimatingCollapse = false;
mAnimatingExpand = true;
mAfterExpand = after;
@@ -165,9 +174,20 @@ public class ExpandedAnimationController
expandFromStack(after, null /* leadBubbleEndAction */);
}
+ /**
+ * Sets that we're animating the stack collapsed, but haven't yet called
+ * {@link #collapseBackToStack}. This will temporarily suspend animations for bubbles that are
+ * added or re-ordered, since the upcoming collapse animation will handle positioning those
+ * bubbles in the collapsed stack.
+ */
+ public void notifyPreparingToCollapse() {
+ mPreparingToCollapse = true;
+ }
+
/** Animate collapsing the bubbles back to their stacked position. */
public void collapseBackToStack(PointF collapsePoint, Runnable after) {
mAnimatingExpand = false;
+ mPreparingToCollapse = false;
mAnimatingCollapse = true;
mAfterCollapse = after;
mCollapsePoint = collapsePoint;
@@ -501,12 +521,18 @@ public class ExpandedAnimationController
startOrUpdatePathAnimation(false /* expanding */);
} else {
child.setTranslationX(getBubbleLeft(index));
- animationForChild(child)
- .translationY(
- getExpandedY() - mBubbleSizePx * ANIMATE_TRANSLATION_FACTOR, /* from */
- getExpandedY() /* to */)
- .start();
- updateBubblePositions();
+
+ // If we're preparing to collapse, don't start animations since the collapse animation
+ // will take over and animate the new bubble into the correct (stacked) position.
+ if (!mPreparingToCollapse) {
+ animationForChild(child)
+ .translationY(
+ getExpandedY()
+ - mBubbleSizePx * ANIMATE_TRANSLATION_FACTOR, /* from */
+ getExpandedY() /* to */)
+ .start();
+ updateBubblePositions();
+ }
}
}
@@ -532,12 +558,20 @@ public class ExpandedAnimationController
@Override
void onChildReordered(View child, int oldIndex, int newIndex) {
- updateBubblePositions();
+ if (mPreparingToCollapse) {
+ // If a re-order is received while we're preparing to collapse, ignore it. Once started,
+ // the collapse animation will animate all of the bubbles to their correct (stacked)
+ // position.
+ return;
+ }
- // We expect reordering during collapse, since we'll put the last selected bubble on top.
- // Update the collapse animation so they end up in the right stacked positions.
if (mAnimatingCollapse) {
+ // If a re-order is received during collapse, update the animation so that the bubbles
+ // end up in the correct (stacked) position.
startOrUpdatePathAnimation(false /* expanding */);
+ } else {
+ // Otherwise, animate the bubbles around to reflect their new order.
+ updateBubblePositions();
}
}