Loading core/java/android/view/ImeBackAnimationController.java +3 −2 Original line number Diff line number Diff line Loading @@ -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() { Loading core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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 Loading Loading
core/java/android/view/ImeBackAnimationController.java +3 −2 Original line number Diff line number Diff line Loading @@ -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() { Loading
core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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 Loading