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

Commit b8f5e5c7 authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

Allow predictive IME back animation when app handles animating insets

Bug: 322836622
Flag: ACONFIG android.view.inputmethod.predictive_back_ime DISABLED
Test: separate CL
Change-Id: Iaba60d76d445852bf2b08aa8caac2957cae56ef4
parent b2820aea
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -70,13 +70,13 @@ public class ImeBackAnimationController implements OnBackAnimationCallback {

    @Override
    public void onBackStarted(@NonNull BackEvent backEvent) {
        if (isAdjustResize()) {
        if (!isBackAnimationAllowed()) {
            // There is no good solution for a predictive back animation if the app uses
            // adjustResize, since we can't relayout the whole app for every frame. We also don't
            // want to reveal any black areas behind the IME. Therefore let's not play any animation
            // in that case for now.
            Log.d(TAG, "onBackStarted -> not playing predictive back animation due to softinput"
                    + " mode adjustResize");
                    + " mode adjustResize AND no animation callback registered");
            return;
        }
        if (isHideAnimationInProgress()) {
@@ -128,13 +128,13 @@ public class ImeBackAnimationController implements OnBackAnimationCallback {

    @Override
    public void onBackCancelled() {
        if (isAdjustResize()) return;
        if (!isBackAnimationAllowed()) return;
        startPostCommitAnim(/*hideIme*/ false);
    }

    @Override
    public void onBackInvoked() {
        if (isAdjustResize()) {
        if (!isBackAnimationAllowed()) {
            mInsetsController.hide(ime());
            return;
        }
@@ -252,9 +252,12 @@ public class ImeBackAnimationController implements OnBackAnimationCallback {
        }
    }

    private boolean isAdjustResize() {
    private boolean isBackAnimationAllowed() {
        // back animation is allowed in all cases except when softInputMode is adjust_resize AND
        // there is no app-registered WindowInsetsAnimationCallback.
        return (mViewRoot.mWindowAttributes.softInputMode & SOFT_INPUT_MASK_ADJUST)
                == SOFT_INPUT_ADJUST_RESIZE;
                != SOFT_INPUT_ADJUST_RESIZE
                || (mViewRoot.mView != null && mViewRoot.mView.hasWindowInsetsAnimationCallback());
    }

    private boolean isAdjustPan() {