summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/ImeBackAnimationController.java21
-rw-r--r--core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java10
2 files changed, 19 insertions, 12 deletions
diff --git a/core/java/android/view/ImeBackAnimationController.java b/core/java/android/view/ImeBackAnimationController.java
index 1afedc185c85..13a20e305158 100644
--- a/core/java/android/view/ImeBackAnimationController.java
+++ b/core/java/android/view/ImeBackAnimationController.java
@@ -206,18 +206,9 @@ public class ImeBackAnimationController implements OnBackAnimationCallback {
mInsetsController.setPredictiveBackImeHideAnimInProgress(true);
notifyHideIme();
}
- if (mStartRootScrollY != 0) {
- // RootView is panned, ensure that it is scrolled back to the intended scroll position
- if (triggerBack) {
- // requesting ime as invisible
- mInsetsController.setRequestedVisibleTypes(0, ime());
- // changes the animation state and notifies RootView of changed insets, which
- // causes it to reset its scrollY to 0f (animated)
- mInsetsController.onAnimationStateChanged(ime(), /*running*/ true);
- } else {
- // This causes RootView to update its scroll back to the panned position
- mInsetsController.getHost().notifyInsetsChanged();
- }
+ if (mStartRootScrollY != 0 && !triggerBack) {
+ // This causes RootView to update its scroll back to the panned position
+ mInsetsController.getHost().notifyInsetsChanged();
}
}
@@ -233,6 +224,12 @@ public class ImeBackAnimationController implements OnBackAnimationCallback {
// the IME away
mInsetsController.getHost().getInputMethodManager()
.notifyImeHidden(mInsetsController.getHost().getWindowToken(), statsToken);
+
+ // requesting IME as invisible during post-commit
+ mInsetsController.setRequestedVisibleTypes(0, ime());
+ // Changes the animation state. This also notifies RootView of changed insets, which causes
+ // it to reset its scrollY to 0f (animated) if it was panned
+ mInsetsController.onAnimationStateChanged(ime(), /*running*/ true);
}
private void reset() {
diff --git a/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java b/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java
index c00ebe487620..d78169acb9ed 100644
--- a/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java
+++ b/core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java
@@ -37,6 +37,7 @@ import static org.testng.Assert.assertEquals;
import android.content.Context;
import android.graphics.Insets;
import android.platform.test.annotations.Presubmit;
+import android.util.SparseArray;
import android.view.animation.BackGestureInterpolator;
import android.view.animation.Interpolator;
import android.view.inputmethod.InputMethodManager;
@@ -54,6 +55,8 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import java.lang.reflect.Field;
+
/**
* Tests for {@link ImeBackAnimationController}.
*
@@ -104,6 +107,13 @@ public class ImeBackAnimationControllerTest {
when(mInsetsController.getHost()).thenReturn(mViewRootInsetsControllerHost);
when(mViewRootInsetsControllerHost.getInputMethodManager()).thenReturn(
inputMethodManager);
+ try {
+ Field field = InsetsController.class.getDeclaredField("mSourceConsumers");
+ field.setAccessible(true);
+ field.set(mInsetsController, new SparseArray<InsetsSourceConsumer>());
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ throw new RuntimeException("Unable to set mSourceConsumers", e);
+ }
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
}