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

Commit 77239f8b authored by Tiger Huang's avatar Tiger Huang
Browse files

Don't use the user's fraction to decide the visibility of a leash

The caller might pass any fraction to
WindowInsetsAnimationController#setInsetsAndAlpha. The fraction should
not control visibility of the leash.

This CL flags mCancelling when an insets animation is being cancelled
instead of setting mPendingFraction to 1f, and stops using
mPendingFraction to decide the leash visibility if the animation is
ANIMATION_TYPE_USER.

Bug: 376232646
Flag: EXEMPT bugfix
Test: Manual, i.e. verified that IME does not jump hide anymore when
      swiping down and up again on all-apps.
Change-Id: I297758f665460bd6db8ff1da8267e9b9a862b328
parent 271ede58
Loading
Loading
Loading
Loading
+10 −9
Original line number Original line Diff line number Diff line
@@ -112,6 +112,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro
    private Insets mPendingInsets;
    private Insets mPendingInsets;
    private float mPendingFraction;
    private float mPendingFraction;
    private boolean mFinished;
    private boolean mFinished;
    private boolean mCancelling;
    private boolean mCancelled;
    private boolean mCancelled;
    private boolean mShownOnFinish;
    private boolean mShownOnFinish;
    private float mCurrentAlpha = 1.0f;
    private float mCurrentAlpha = 1.0f;
@@ -371,7 +372,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro
        mPendingInsets = mLayoutInsetsDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN
        mPendingInsets = mLayoutInsetsDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN
                ? mShownInsets : mHiddenInsets;
                ? mShownInsets : mHiddenInsets;
        mPendingAlpha = 1f;
        mPendingAlpha = 1f;
        mPendingFraction = 1f;
        mCancelling = true;
        applyChangeInsets(null);
        applyChangeInsets(null);
        mCancelled = true;
        mCancelled = true;
        mListener.onCancelled(mReadyDispatched ? this : null);
        mListener.onCancelled(mReadyDispatched ? this : null);
@@ -488,15 +489,15 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro
            return;
            return;
        }
        }


        final boolean visible = mPendingFraction == 0
        final boolean visible = mFinished
                // The first frame of ANIMATION_TYPE_SHOW should be invisible since it is
                // animated from the hidden state.
                ? mAnimationType != ANIMATION_TYPE_SHOW
                : mPendingFraction < 1f || (mFinished
                ? mShownOnFinish
                ? mShownOnFinish
                        // If the animation is cancelled, mFinished and mShownOnFinish are not set.
                : (mCancelling
                        // If the animation is being cancelled, mShownOnFinish is not valid.
                        // Here uses mLayoutInsetsDuringAnimation to decide if it should be visible.
                        // Here uses mLayoutInsetsDuringAnimation to decide if it should be visible.
                        : mLayoutInsetsDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN);
                        ? mLayoutInsetsDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN
                        // The first frame of ANIMATION_TYPE_SHOW should be invisible since it is
                        // animated from the hidden state.
                        : (mAnimationType != ANIMATION_TYPE_SHOW || mPendingFraction != 0));


        // TODO: Implement behavior when inset spans over multiple types
        // TODO: Implement behavior when inset spans over multiple types
        for (int i = controls.size() - 1; i >= 0; i--) {
        for (int i = controls.size() - 1; i >= 0; i--) {