Interrupt bubble animation on stash change
This change handles cancelling the currently running bubble animation when the stash state is changing. Demo - http://recall/-/bJtug1HhvXkkeA4MQvIaiP/4jnBgnFaIPez6m7fVLSlf Flag: ACONFIG com.android.wm.shell.enable_bubble_bar DEVELOPMENT Bug: 280605846 Test: atest BubbleBarViewAnimatorTest Change-Id: I34628f8ad741228dd21285ad66e45ef2909fbdab
This commit is contained in:
1 parent
85c50adb91
commit
209c764175
4 files changed
+225
-71
No files matched your search
@@ -172,6 +172,13 @@ public class BubbleBarViewController {
|
||||
}
|
||||
}
|
||||
|
||||
/** Notifies that the stash state is changing. */
|
||||
public void onStashStateChanging() {
|
||||
if (isAnimatingNewBubble()) {
|
||||
mBubbleBarViewAnimator.onStashStateChangingWhileAnimating();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// The below animators are exposed to BubbleStashController so it can manage the stashing
|
||||
// animation.
|
||||
|
||||
@@ -250,6 +250,11 @@ public class BubbleStashController {
|
||||
&& !mBubblesShowingOnHome
|
||||
&& !mBubblesShowingOnOverview;
|
||||
if (mIsStashed != isStashed) {
|
||||
// notify the view controller that the stash state is about to change so that it can
|
||||
// cancel an ongoing animation if there is one.
|
||||
// note that this has to be called before updating mIsStashed with the new value,
|
||||
// otherwise interrupting an ongoing animation may update it again with the wrong state
|
||||
mBarViewController.onStashStateChanging();
|
||||
mIsStashed = isStashed;
|
||||
if (mAnimator != null) {
|
||||
mAnimator.cancel();
|
||||
@@ -423,4 +428,29 @@ public class BubbleStashController {
|
||||
mIsStashed = true;
|
||||
onIsStashedChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the values of the internal animators after the new bubble animation was interrupted
|
||||
*
|
||||
* @param isStashed whether the current state should be stashed
|
||||
* @param bubbleBarTranslationY the current bubble bar translation. this is only used if the
|
||||
* bubble bar is showing to ensure that the stash animator runs
|
||||
* smoothly.
|
||||
*/
|
||||
public void onNewBubbleAnimationInterrupted(boolean isStashed, float bubbleBarTranslationY) {
|
||||
if (isStashed) {
|
||||
mBubbleStashedHandleAlpha.setValue(1);
|
||||
mIconAlphaForStash.setValue(0);
|
||||
mIconScaleForStash.updateValue(STASHED_BAR_SCALE);
|
||||
mIconTranslationYForStash.updateValue(getStashTranslation());
|
||||
} else {
|
||||
mBubbleStashedHandleAlpha.setValue(0);
|
||||
mHandleViewController.setTranslationYForSwipe(0);
|
||||
mIconAlphaForStash.setValue(1);
|
||||
mIconScaleForStash.updateValue(1);
|
||||
mIconTranslationYForStash.updateValue(bubbleBarTranslationY);
|
||||
}
|
||||
mIsStashed = isStashed;
|
||||
onIsStashedChanged();
|
||||
}
|
||||
}
|
||||
+28
-3
@@ -179,7 +179,17 @@ constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
animator.addEndListener { _, _, _, _, _, _, _ ->
|
||||
animator.addEndListener { _, _, _, canceled, _, _, _ ->
|
||||
// if the show animation was canceled, also cancel the hide animation. this is typically
|
||||
// canceled in this class, but could potentially be canceled elsewhere.
|
||||
if (canceled) {
|
||||
val hideAnimation = animatingBubble?.hideAnimation ?: return@addEndListener
|
||||
scheduler.cancel(hideAnimation)
|
||||
animatingBubble = null
|
||||
bubbleBarView.onAnimatingBubbleCompleted()
|
||||
bubbleBarView.relativePivotY = 1f
|
||||
return@addEndListener
|
||||
}
|
||||
// the bubble bar is now fully settled in. update taskbar touch region so it's touchable
|
||||
bubbleStashController.updateTaskbarTouchRegion()
|
||||
}
|
||||
@@ -200,6 +210,7 @@ constructor(
|
||||
* 3. The third part is the overshoot. The handle is made fully visible.
|
||||
*/
|
||||
private fun buildHideAnimation() = Runnable {
|
||||
if (animatingBubble == null) return@Runnable
|
||||
val offset = bubbleStashController.diffBetweenHandleAndBarCenters
|
||||
val stashedHandleTranslationY =
|
||||
bubbleStashController.stashedHandleTranslationForNewBubbleAnimation
|
||||
@@ -238,9 +249,9 @@ constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
animator.addEndListener { _, _, _, _, _, _, _ ->
|
||||
animator.addEndListener { _, _, _, canceled, _, _, _ ->
|
||||
animatingBubble = null
|
||||
bubbleStashController.stashBubbleBarImmediate()
|
||||
if (!canceled) bubbleStashController.stashBubbleBarImmediate()
|
||||
bubbleBarView.onAnimatingBubbleCompleted()
|
||||
bubbleBarView.relativePivotY = 1f
|
||||
bubbleStashController.updateTaskbarTouchRegion()
|
||||
@@ -256,4 +267,18 @@ constructor(
|
||||
bubbleBarView.relativePivotY = 1f
|
||||
animatingBubble = null
|
||||
}
|
||||
|
||||
/** Notifies the animator that the taskbar area was touched during an animation. */
|
||||
fun onStashStateChangingWhileAnimating() {
|
||||
val hideAnimation = animatingBubble?.hideAnimation ?: return
|
||||
scheduler.cancel(hideAnimation)
|
||||
animatingBubble = null
|
||||
bubbleStashController.stashedHandlePhysicsAnimator.cancel()
|
||||
bubbleBarView.onAnimatingBubbleCompleted()
|
||||
bubbleBarView.relativePivotY = 1f
|
||||
bubbleStashController.onNewBubbleAnimationInterrupted(
|
||||
/* isStashed= */ bubbleBarView.alpha == 0f,
|
||||
bubbleBarView.translationY
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user