Loading core/java/android/view/ImeBackAnimationController.java +9 −12 Original line number Diff line number Diff line Loading @@ -210,20 +210,11 @@ 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 { if (mStartRootScrollY != 0 && !triggerBack) { // This causes RootView to update its scroll back to the panned position mInsetsController.getHost().notifyInsetsChanged(); } } } private void notifyHideIme() { ImeTracker.Token statsToken = ImeTracker.forLogging().onStart(ImeTracker.TYPE_HIDE, Loading @@ -237,6 +228,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() { Loading core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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}. * Loading Loading @@ -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(); } Loading Loading
core/java/android/view/ImeBackAnimationController.java +9 −12 Original line number Diff line number Diff line Loading @@ -210,20 +210,11 @@ 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 { if (mStartRootScrollY != 0 && !triggerBack) { // This causes RootView to update its scroll back to the panned position mInsetsController.getHost().notifyInsetsChanged(); } } } private void notifyHideIme() { ImeTracker.Token statsToken = ImeTracker.forLogging().onStart(ImeTracker.TYPE_HIDE, Loading @@ -237,6 +228,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() { Loading
core/tests/coretests/src/android/view/ImeBackAnimationControllerTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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}. * Loading Loading @@ -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(); } Loading