summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/ImeBackAnimationController.java5
-rw-r--r--core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java15
2 files changed, 18 insertions, 2 deletions
diff --git a/core/java/android/view/ImeBackAnimationController.java b/core/java/android/view/ImeBackAnimationController.java
index 13a20e305158..30daaf7f6242 100644
--- a/core/java/android/view/ImeBackAnimationController.java
+++ b/core/java/android/view/ImeBackAnimationController.java
@@ -251,10 +251,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() {
diff --git a/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java b/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java
index d78169acb9ed..9c2a465c10a1 100644
--- a/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java
+++ b/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java
@@ -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);
@@ -132,6 +134,19 @@ public class ImeBackAnimationControllerTest {
}
@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
mViewRoot.mWindowAttributes.softInputMode = SOFT_INPUT_ADJUST_RESIZE;