summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Johannes Gallmann <gallmann@google.com> 2024-05-07 09:26:41 +0000
committer Johannes Gallmann <gallmann@google.com> 2024-05-07 09:26:41 +0000
commit2ff61aafd46c5b9b5d58c8b33cc50c3709258c36 (patch)
tree06f66d29c7682f0a332e6b9cd95501a54fe454df
parentc78496f980b85d5a398be06c40e65c40e6d38d89 (diff)
Fix IME not hidden by back gesture in split screen
Bug: 322836622 Flag: android.view.inputmethod.predictive_back_ime STAGING Test: atest FrameworksCoreTests:ImeBackAnimationControllerTest Change-Id: Ie95363dd5b414dbaaa73782c2ffe256fb3ba8226
-rw-r--r--core/java/android/view/ImeBackAnimationController.java4
-rw-r--r--core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java17
2 files changed, 20 insertions, 1 deletions
diff --git a/core/java/android/view/ImeBackAnimationController.java b/core/java/android/view/ImeBackAnimationController.java
index 1afedc185c85..4530157d2fe1 100644
--- a/core/java/android/view/ImeBackAnimationController.java
+++ b/core/java/android/view/ImeBackAnimationController.java
@@ -134,7 +134,9 @@ public class ImeBackAnimationController implements OnBackAnimationCallback {
@Override
public void onBackInvoked() {
- if (!isBackAnimationAllowed()) {
+ if (!isBackAnimationAllowed() || !mIsPreCommitAnimationInProgress) {
+ // play regular hide animation if back-animation is not allowed or if insets control has
+ // been cancelled by the system (this can happen in split screen for example)
mInsetsController.hide(ime());
return;
}
diff --git a/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java b/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java
index c00ebe487620..57bbb1cc9b57 100644
--- a/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java
+++ b/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java
@@ -241,6 +241,23 @@ public class ImeBackAnimationControllerTest {
});
}
+ @Test
+ public void testOnBackInvokedHidesImeEvenIfInsetsControlCancelled() {
+ InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
+ // start back gesture
+ WindowInsetsAnimationControlListener animationControlListener = startBackGesture();
+
+ // simulate ImeBackAnimationController not receiving control (e.g. due to split screen)
+ animationControlListener.onCancelled(mWindowInsetsAnimationController);
+
+ // commit back gesture
+ mBackAnimationController.onBackInvoked();
+
+ // verify that InsetsController#hide is called
+ verify(mInsetsController, times(1)).hide(ime());
+ });
+ }
+
private WindowInsetsAnimationControlListener startBackGesture() {
// start back gesture
mBackAnimationController.onBackStarted(new BackEvent(0f, 0f, 0f, EDGE_LEFT));