Merge "Don't animate reorder/add when we're about to collapse." into rvc-dev am: f083c15656 am: 3cb62293a9 am: 6dcf1c051e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11852403 Change-Id: If5afcf51b811fe7d0b2d60f6ba6e8071ec04727f
This commit is contained in:
@@ -1822,6 +1822,10 @@ public class BubbleStackView extends FrameLayout
|
|||||||
mExpandedBubble.getExpandedView().hideImeIfVisible();
|
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 =
|
final long startDelay =
|
||||||
(long) (ExpandedAnimationController.EXPAND_COLLAPSE_TARGET_ANIM_DURATION * 0.6f);
|
(long) (ExpandedAnimationController.EXPAND_COLLAPSE_TARGET_ANIM_DURATION * 0.6f);
|
||||||
postDelayed(() -> mExpandedAnimationController.collapseBackToStack(
|
postDelayed(() -> mExpandedAnimationController.collapseBackToStack(
|
||||||
|
|||||||
@@ -92,6 +92,14 @@ public class ExpandedAnimationController
|
|||||||
private int mScreenOrientation;
|
private int mScreenOrientation;
|
||||||
|
|
||||||
private boolean mAnimatingExpand = false;
|
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 boolean mAnimatingCollapse = false;
|
||||||
private @Nullable Runnable mAfterExpand;
|
private @Nullable Runnable mAfterExpand;
|
||||||
private Runnable mAfterCollapse;
|
private Runnable mAfterCollapse;
|
||||||
@@ -150,6 +158,7 @@ public class ExpandedAnimationController
|
|||||||
*/
|
*/
|
||||||
public void expandFromStack(
|
public void expandFromStack(
|
||||||
@Nullable Runnable after, @Nullable Runnable leadBubbleEndAction) {
|
@Nullable Runnable after, @Nullable Runnable leadBubbleEndAction) {
|
||||||
|
mPreparingToCollapse = false;
|
||||||
mAnimatingCollapse = false;
|
mAnimatingCollapse = false;
|
||||||
mAnimatingExpand = true;
|
mAnimatingExpand = true;
|
||||||
mAfterExpand = after;
|
mAfterExpand = after;
|
||||||
@@ -165,9 +174,20 @@ public class ExpandedAnimationController
|
|||||||
expandFromStack(after, null /* leadBubbleEndAction */);
|
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. */
|
/** Animate collapsing the bubbles back to their stacked position. */
|
||||||
public void collapseBackToStack(PointF collapsePoint, Runnable after) {
|
public void collapseBackToStack(PointF collapsePoint, Runnable after) {
|
||||||
mAnimatingExpand = false;
|
mAnimatingExpand = false;
|
||||||
|
mPreparingToCollapse = false;
|
||||||
mAnimatingCollapse = true;
|
mAnimatingCollapse = true;
|
||||||
mAfterCollapse = after;
|
mAfterCollapse = after;
|
||||||
mCollapsePoint = collapsePoint;
|
mCollapsePoint = collapsePoint;
|
||||||
@@ -501,14 +521,20 @@ public class ExpandedAnimationController
|
|||||||
startOrUpdatePathAnimation(false /* expanding */);
|
startOrUpdatePathAnimation(false /* expanding */);
|
||||||
} else {
|
} else {
|
||||||
child.setTranslationX(getBubbleLeft(index));
|
child.setTranslationX(getBubbleLeft(index));
|
||||||
|
|
||||||
|
// 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)
|
animationForChild(child)
|
||||||
.translationY(
|
.translationY(
|
||||||
getExpandedY() - mBubbleSizePx * ANIMATE_TRANSLATION_FACTOR, /* from */
|
getExpandedY()
|
||||||
|
- mBubbleSizePx * ANIMATE_TRANSLATION_FACTOR, /* from */
|
||||||
getExpandedY() /* to */)
|
getExpandedY() /* to */)
|
||||||
.start();
|
.start();
|
||||||
updateBubblePositions();
|
updateBubblePositions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onChildRemoved(View child, int index, Runnable finishRemoval) {
|
void onChildRemoved(View child, int index, Runnable finishRemoval) {
|
||||||
@@ -532,12 +558,20 @@ public class ExpandedAnimationController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onChildReordered(View child, int oldIndex, int newIndex) {
|
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 (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 */);
|
startOrUpdatePathAnimation(false /* expanding */);
|
||||||
|
} else {
|
||||||
|
// Otherwise, animate the bubbles around to reflect their new order.
|
||||||
|
updateBubblePositions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user