From 3b19ff1e0f7a0c8b180c91e4227db48ab40c03af Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Wed, 1 Apr 2020 19:48:16 +0200 Subject: [PATCH] WindowInsetsAnimation: Fix app driven closing of IME When using controlWindowInsetsAnimation to close the IME, delay reporting this to the IME until the animation is actually finished. Otherwise, the IME will self-hide and start a transition that breaks the just-begun app-driven transition. (Regression from I7f6098a61a5942795ffd33a60329e4dd5fb5d6cb which changed InputMethodService to hide itself in reponse to notifyHidden) Bug: 151980214 Test: make WindowInsetsTests, ensure that dragging the IME closed doesnt get cancelled Change-Id: If4e64cc78742a4e1e8c98137bd97d65dd567f674 --- core/java/android/view/ImeInsetsSourceConsumer.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/core/java/android/view/ImeInsetsSourceConsumer.java b/core/java/android/view/ImeInsetsSourceConsumer.java index 35286ba007c4d..2461e96c5b492 100644 --- a/core/java/android/view/ImeInsetsSourceConsumer.java +++ b/core/java/android/view/ImeInsetsSourceConsumer.java @@ -16,7 +16,6 @@ package android.view; -import static android.view.InsetsController.ANIMATION_TYPE_USER; import static android.view.InsetsController.AnimationType; import static android.view.InsetsState.ITYPE_IME; @@ -104,13 +103,9 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer { void hide(boolean animationFinished, @AnimationType int animationType) { super.hide(); - if (!animationFinished) { - if (animationType == ANIMATION_TYPE_USER) { - // if controlWindowInsetsAnimation is hiding keyboard. - notifyHidden(); - } - } else { + if (animationFinished) { // remove IME surface as IME has finished hide animation. + notifyHidden(); removeSurface(); } }