Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1b9cb77 authored by Joshua Tsuji's avatar Joshua Tsuji
Browse files

Surprisingly you can translate to Float.MIN_VALUE - stackPos.y, but you should not.

Test: open/close IME with a flyout open, with bubbles both below and above the IME
Fixes: 141780462
Change-Id: Ib45068a8f01d41a5e6e74bb101f7706e08619fd0
parent 259c66b8
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -89,6 +89,9 @@ public class StackAnimationController extends
    private static final int SPRING_AFTER_FLING_STIFFNESS = 750;
    private static final float SPRING_AFTER_FLING_DAMPING_RATIO = 0.85f;

    /** Sentinel value for unset position value. */
    private static final float UNSET = -Float.MIN_VALUE;

    /**
     * Minimum fling velocity required to trigger moving the stack from one side of the screen to
     * the other.
@@ -133,7 +136,7 @@ public class StackAnimationController extends
     * The Y position of the stack before the IME became visible, or {@link Float#MIN_VALUE} if the
     * IME is not visible or the user moved the stack since the IME became visible.
     */
    private float mPreImeY = Float.MIN_VALUE;
    private float mPreImeY = UNSET;

    /**
     * Animations on the stack position itself, which would have been started in
@@ -263,7 +266,7 @@ public class StackAnimationController extends

        // If we manually move the bubbles with the IME open, clear the return point since we don't
        // want the stack to snap away from the new position.
        mPreImeY = Float.MIN_VALUE;
        mPreImeY = UNSET;

        moveFirstBubbleWithStackFollowing(DynamicAnimation.TRANSLATION_X, x);
        moveFirstBubbleWithStackFollowing(DynamicAnimation.TRANSLATION_Y, y);
@@ -512,26 +515,27 @@ public class StackAnimationController extends
     * Animates the stack either away from the newly visible IME, or back to its original position
     * due to the IME going away.
     *
     * @return The destination Y value of the stack due to the IME movement.
     * @return The destination Y value of the stack due to the IME movement (or the current position
     * of the stack if it's not moving).
     */
    public float animateForImeVisibility(boolean imeVisible) {
        final float maxBubbleY = getAllowableStackPositionRegion().bottom;
        float destinationY = Float.MIN_VALUE;
        float destinationY = UNSET;

        if (imeVisible) {
            // Stack is lower than it should be and overlaps the now-visible IME.
            if (mStackPosition.y > maxBubbleY && mPreImeY == Float.MIN_VALUE) {
            if (mStackPosition.y > maxBubbleY && mPreImeY == UNSET) {
                mPreImeY = mStackPosition.y;
                destinationY = maxBubbleY;
            }
        } else {
            if (mPreImeY > Float.MIN_VALUE) {
            if (mPreImeY != UNSET) {
                destinationY = mPreImeY;
                mPreImeY = Float.MIN_VALUE;
                mPreImeY = UNSET;
            }
        }

        if (destinationY > Float.MIN_VALUE) {
        if (destinationY != UNSET) {
            springFirstBubbleWithStackFollowing(
                    DynamicAnimation.TRANSLATION_Y,
                    getSpringForce(DynamicAnimation.TRANSLATION_Y, /* view */ null)
@@ -542,7 +546,7 @@ public class StackAnimationController extends
            notifyFloatingCoordinatorStackAnimatingTo(mStackPosition.x, destinationY);
        }

        return destinationY;
        return destinationY != UNSET ? destinationY : mStackPosition.y;
    }

    /**
@@ -595,7 +599,7 @@ public class StackAnimationController extends
                    mLayout.getHeight()
                            - mBubbleSize
                            - mBubblePaddingTop
                            - (mImeHeight > Float.MIN_VALUE ? mImeHeight + mBubblePaddingTop : 0f)
                            - (mImeHeight != UNSET ? mImeHeight + mBubblePaddingTop : 0f)
                            - Math.max(
                            insets.getStableInsetBottom(),
                            insets.getDisplayCutout() != null