Merge "Don't animate reorder/add when we're about to collapse." into rvc-dev am: f083c15656 am: 3cb62293a9 am: 6dcf1c051e am: 4fa7ebc099

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11852403

Change-Id: I14ca4e11c3486c1909342a9cff118956d7f48635
This commit is contained in:
TreeHugger Robot
2020-06-12 18:43:24 +00:00
committed by Automerger Merge Worker
2 changed files with 47 additions and 9 deletions

View File

@@ -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(

View File

@@ -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();
}
}