From 4b39591456062eae459144cc3cb410ddf9a6a844 Mon Sep 17 00:00:00 2001 From: Joshua Tsuji Date: Fri, 19 Apr 2019 17:18:40 -0400 Subject: [PATCH] Update the stack bounds for IME changes even if we're expanded. Even though the stack shouldn't animate due to IME changes when expanded, it needs to know that the IME has been shown/hidden so it can recalculate bounds. Test: atest SystemUITests Fixes: 130344714 Change-Id: I99a6741799eb1a0f19896d0001afa072fb29de47 --- .../systemui/bubbles/BubbleStackView.java | 8 ++- .../animation/StackAnimationController.java | 49 +++++++++---------- 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java index a4a0fe18f5cb2..00ed4f1dd505c 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java @@ -717,12 +717,10 @@ public class BubbleStackView extends FrameLayout { /** Moves the bubbles out of the way if they're going to be over the keyboard. */ public void onImeVisibilityChanged(boolean visible, int height) { + mStackAnimationController.setImeHeight(height + mImeOffset); + if (!mIsExpanded) { - if (visible) { - mStackAnimationController.updateBoundsForVisibleImeAndAnimate(height + mImeOffset); - } else { - mStackAnimationController.updateBoundsForInvisibleImeAndAnimate(); - } + mStackAnimationController.animateForImeVisibility(visible); } } 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 74a6b60054500..e0912bf31ec9a 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java @@ -334,41 +334,38 @@ public class StackAnimationController extends mLayout.removeEndActionForProperty(DynamicAnimation.TRANSLATION_Y); } - /** - * Save the IME height so that the allowable stack bounds reflect the now-visible IME, and - * animate the stack out of the way if necessary. - */ - public void updateBoundsForVisibleImeAndAnimate(int imeHeight) { + /** Save the current IME height so that we know where the stack bounds should be. */ + public void setImeHeight(int imeHeight) { mImeHeight = imeHeight; + } + /** + * Animates the stack either away from the newly visible IME, or back to its original position + * due to the IME going away. + */ + public void animateForImeVisibility(boolean imeVisible) { final float maxBubbleY = getAllowableStackPositionRegion().bottom; - if (mStackPosition.y > maxBubbleY && mPreImeY == Float.MIN_VALUE) { - mPreImeY = mStackPosition.y; + float destinationY = Float.MIN_VALUE; + if (imeVisible) { + if (mStackPosition.y > maxBubbleY && mPreImeY == Float.MIN_VALUE) { + mPreImeY = mStackPosition.y; + destinationY = maxBubbleY; + } + } else { + if (mPreImeY > Float.MIN_VALUE) { + destinationY = mPreImeY; + mPreImeY = Float.MIN_VALUE; + } + } + + if (destinationY > Float.MIN_VALUE) { springFirstBubbleWithStackFollowing( DynamicAnimation.TRANSLATION_Y, getSpringForce(DynamicAnimation.TRANSLATION_Y, /* view */ null) .setStiffness(SpringForce.STIFFNESS_LOW), /* startVel */ 0f, - maxBubbleY); - } - } - - /** - * Clear the IME height from the bounds and animate the stack back to its original position, - * assuming it wasn't moved in the meantime. - */ - public void updateBoundsForInvisibleImeAndAnimate() { - mImeHeight = 0; - - if (mPreImeY > Float.MIN_VALUE) { - springFirstBubbleWithStackFollowing( - DynamicAnimation.TRANSLATION_Y, - getSpringForce(DynamicAnimation.TRANSLATION_Y, /* view */ null) - .setStiffness(SpringForce.STIFFNESS_LOW), - /* startVel */ 0f, - mPreImeY); - mPreImeY = Float.MIN_VALUE; + destinationY); } }