summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Johannes Gallmann <gallmann@google.com> 2024-05-22 12:06:40 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-05-22 12:06:40 +0000
commit67e9be91c201acadc41f13e0b729ae7edb1e3d79 (patch)
treeb95c46acb72f3d1e91ba097582f5722bbbb681a7
parentcaf288b33978c9770e94c4f7a71090544814b2fa (diff)
parente703a82865ff0f3e56a2e5a8c1c17d3e13f4be23 (diff)
Merge "Allow IME predictive back anim when edge-to-edge enabled" into main
-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 8c14de6156a3..fc1852d739e2 100644
--- a/core/java/android/view/ImeBackAnimationController.java
+++ b/core/java/android/view/ImeBackAnimationController.java
@@ -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() {
diff --git a/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java b/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java
index 5917cc181b47..58e5be2b823d 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;