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

Commit 67e9be91 authored by Johannes Gallmann's avatar Johannes Gallmann Committed by Android (Google) Code Review
Browse files

Merge "Allow IME predictive back anim when edge-to-edge enabled" into main

parents caf288b3 e703a828
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -255,10 +255,11 @@ public class ImeBackAnimationController implements OnBackAnimationCallback {

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

    private boolean isAdjustPan() {
+15 −0
Original line number Diff line number Diff line
@@ -99,6 +99,8 @@ public class ImeBackAnimationControllerTest {
            } catch (WindowManager.BadTokenException e) {
                // activity isn't running, we will ignore BadTokenException.
            }
            mViewRoot.setOnContentApplyWindowInsetsListener(
                    mock(Window.OnContentApplyWindowInsetsListener.class));
            mBackAnimationController = new ImeBackAnimationController(mViewRoot, mInsetsController);

            when(mWindowInsetsAnimationController.getHiddenStateInsets()).thenReturn(Insets.NONE);
@@ -131,6 +133,19 @@ public class ImeBackAnimationControllerTest {
                anyBoolean(), anyLong(), any(), anyInt(), anyBoolean());
    }

    @Test
    public void testAdjustResizeWithEdgeToEdgePlaysAnim() {
        // set OnContentApplyWindowInsetsListener to null (to simulate edge-to-edge enabled) and
        // softInputMode=adjustResize
        mViewRoot.mWindowAttributes.softInputMode = SOFT_INPUT_ADJUST_RESIZE;
        mViewRoot.setOnContentApplyWindowInsetsListener(null);
        // start back gesture
        mBackAnimationController.onBackStarted(new BackEvent(0f, 0f, 0f, EDGE_LEFT));
        // verify that ImeBackAnimationController takes control over IME insets
        verify(mInsetsController, times(1)).controlWindowInsetsAnimation(anyInt(), any(), any(),
                anyBoolean(), anyLong(), any(), anyInt(), anyBoolean());
    }

    @Test
    public void testAdjustResizeWithoutAppWindowInsetsListenerNotPlayingAnim() {
        // setup ViewRoot with softInputMode=adjustResize