Merge "Fix issues with Bubbles+IME." into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-09 21:04:01 +00:00
committed by Android (Google) Code Review
3 changed files with 33 additions and 8 deletions

View File

@@ -1311,7 +1311,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
private class BubblesImeListener extends PinnedStackListenerForwarder.PinnedStackListener { private class BubblesImeListener extends PinnedStackListenerForwarder.PinnedStackListener {
@Override @Override
public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) { public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {
if (mStackView != null && mStackView.getBubbleCount() > 0) { if (mStackView != null) {
mStackView.post(() -> mStackView.onImeVisibilityChanged(imeVisible, imeHeight)); mStackView.post(() -> mStackView.onImeVisibilityChanged(imeVisible, imeHeight));
} }
} }

View File

@@ -126,6 +126,11 @@ public class BubbleStackView extends FrameLayout {
@VisibleForTesting @VisibleForTesting
static final int FLYOUT_HIDE_AFTER = 5000; static final int FLYOUT_HIDE_AFTER = 5000;
private static final PhysicsAnimator.SpringConfig FLYOUT_IME_ANIMATION_SPRING_CONFIG =
new PhysicsAnimator.SpringConfig(
StackAnimationController.IME_ANIMATION_STIFFNESS,
StackAnimationController.DEFAULT_BOUNCINESS);
/** /**
* Interface to synchronize {@link View} state and the screen. * Interface to synchronize {@link View} state and the screen.
* *
@@ -1354,8 +1359,23 @@ public class BubbleStackView extends FrameLayout {
public void onImeVisibilityChanged(boolean visible, int height) { public void onImeVisibilityChanged(boolean visible, int height) {
mStackAnimationController.setImeHeight(visible ? height + mImeOffset : 0); mStackAnimationController.setImeHeight(visible ? height + mImeOffset : 0);
if (!mIsExpanded) { if (!mIsExpanded && getBubbleCount() > 0) {
mStackAnimationController.animateForImeVisibility(visible); final float stackDestinationY =
mStackAnimationController.animateForImeVisibility(visible);
// How far the stack is animating due to IME, we'll just animate the flyout by that
// much too.
final float stackDy =
stackDestinationY - mStackAnimationController.getStackPosition().y;
// If the flyout is visible, translate it along with the bubble stack.
if (mFlyout.getVisibility() == VISIBLE) {
PhysicsAnimator.getInstance(mFlyout)
.spring(DynamicAnimation.TRANSLATION_Y,
mFlyout.getTranslationY() + stackDy,
FLYOUT_IME_ANIMATION_SPRING_CONFIG)
.start();
}
} }
} }

View File

@@ -68,9 +68,10 @@ public class StackAnimationController extends
/** /**
* Values to use for the default {@link SpringForce} provided to the physics animation layout. * Values to use for the default {@link SpringForce} provided to the physics animation layout.
*/ */
private static final int DEFAULT_STIFFNESS = 12000; public static final int DEFAULT_STIFFNESS = 12000;
public static final float IME_ANIMATION_STIFFNESS = SpringForce.STIFFNESS_LOW;
private static final int FLING_FOLLOW_STIFFNESS = 20000; private static final int FLING_FOLLOW_STIFFNESS = 20000;
private static final float DEFAULT_BOUNCINESS = 0.9f; public static final float DEFAULT_BOUNCINESS = 0.9f;
/** /**
* Friction applied to fling animations. Since the stack must land on one of the sides of the * Friction applied to fling animations. Since the stack must land on one of the sides of the
@@ -503,8 +504,10 @@ public class StackAnimationController extends
/** /**
* Animates the stack either away from the newly visible IME, or back to its original position * Animates the stack either away from the newly visible IME, or back to its original position
* due to the IME going away. * due to the IME going away.
*
* @return The destination Y value of the stack due to the IME movement.
*/ */
public void animateForImeVisibility(boolean imeVisible) { public float animateForImeVisibility(boolean imeVisible) {
final float maxBubbleY = getAllowableStackPositionRegion().bottom; final float maxBubbleY = getAllowableStackPositionRegion().bottom;
float destinationY = Float.MIN_VALUE; float destinationY = Float.MIN_VALUE;
@@ -525,12 +528,14 @@ public class StackAnimationController extends
springFirstBubbleWithStackFollowing( springFirstBubbleWithStackFollowing(
DynamicAnimation.TRANSLATION_Y, DynamicAnimation.TRANSLATION_Y,
getSpringForce(DynamicAnimation.TRANSLATION_Y, /* view */ null) getSpringForce(DynamicAnimation.TRANSLATION_Y, /* view */ null)
.setStiffness(SpringForce.STIFFNESS_LOW), .setStiffness(IME_ANIMATION_STIFFNESS),
/* startVel */ 0f, /* startVel */ 0f,
destinationY); destinationY);
notifyFloatingCoordinatorStackAnimatingTo(mStackPosition.x, destinationY); notifyFloatingCoordinatorStackAnimatingTo(mStackPosition.x, destinationY);
} }
return destinationY;
} }
/** /**
@@ -585,7 +590,7 @@ public class StackAnimationController extends
- mBubblePaddingTop - mBubblePaddingTop
- (mImeHeight > Float.MIN_VALUE ? mImeHeight + mBubblePaddingTop : 0f) - (mImeHeight > Float.MIN_VALUE ? mImeHeight + mBubblePaddingTop : 0f)
- Math.max( - Math.max(
insets.getSystemWindowInsetBottom(), insets.getStableInsetBottom(),
insets.getDisplayCutout() != null insets.getDisplayCutout() != null
? insets.getDisplayCutout().getSafeInsetBottom() ? insets.getDisplayCutout().getSafeInsetBottom()
: 0); : 0);