Loading core/java/android/view/ImeBackAnimationController.java +26 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.view; import static android.view.InsetsController.ANIMATION_TYPE_USER; import static android.view.WindowInsets.Type.ime; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST; Loading Loading @@ -60,6 +61,7 @@ public class ImeBackAnimationController implements OnBackAnimationCallback { private float mLastProgress = 0f; private boolean mTriggerBack = false; private boolean mIsPreCommitAnimationInProgress = false; private int mStartRootScrollY = 0; public ImeBackAnimationController(ViewRootImpl viewRoot) { mInsetsController = viewRoot.getInsetsController(); Loading Loading @@ -96,6 +98,7 @@ public class ImeBackAnimationController implements OnBackAnimationCallback { public void onReady(@NonNull WindowInsetsAnimationController controller, @WindowInsets.Type.InsetsType int types) { mWindowInsetsAnimationController = controller; if (isAdjustPan()) mStartRootScrollY = mViewRoot.mScrollY; if (mIsPreCommitAnimationInProgress) { setPreCommitProgress(mLastProgress); } else { Loading Loading @@ -146,6 +149,10 @@ public class ImeBackAnimationController implements OnBackAnimationCallback { float imeHeight = shownY - hiddenY; float interpolatedProgress = BACK_GESTURE.getInterpolation(progress); int newY = (int) (imeHeight - interpolatedProgress * (imeHeight * PEEK_FRACTION)); if (mStartRootScrollY != 0) { mViewRoot.setScrollY( (int) (mStartRootScrollY * (1 - interpolatedProgress * PEEK_FRACTION))); } mWindowInsetsAnimationController.setInsetsAndAlpha(Insets.of(0, 0, 0, newY), 1f, progress); } Loading Loading @@ -199,6 +206,19 @@ 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(); } } } private void notifyHideIme() { Loading @@ -222,6 +242,7 @@ public class ImeBackAnimationController implements OnBackAnimationCallback { mTriggerBack = false; mIsPreCommitAnimationInProgress = false; mInsetsController.setPredictiveBackImeHideAnimInProgress(false); mStartRootScrollY = 0; } private void resetPostCommitAnimator() { Loading @@ -236,6 +257,11 @@ public class ImeBackAnimationController implements OnBackAnimationCallback { == SOFT_INPUT_ADJUST_RESIZE; } private boolean isAdjustPan() { return (mViewRoot.mWindowAttributes.softInputMode & SOFT_INPUT_MASK_ADJUST) == SOFT_INPUT_ADJUST_PAN; } private boolean isHideAnimationInProgress() { return mPostCommitAnimator != null && mTriggerBack; } Loading core/java/android/view/ImeInsetsSourceConsumer.java +6 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,12 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer { "ImeInsetsSourceConsumer#onAnimationFinished", mController.getHost().getInputMethodManager(), null /* icProto */); } final boolean insetsChanged = super.onAnimationStateChanged(running); boolean insetsChanged = super.onAnimationStateChanged(running); if (running && !isShowRequested() && mController.isPredictiveBackImeHideAnimInProgress()) { // IME predictive back animation switched from pre-commit to post-commit. insetsChanged |= applyLocalVisibilityOverride(); } if (!isShowRequested()) { mIsRequestedVisibleAwaitingLeash = false; if (!running && !mHasPendingRequest) { Loading core/java/android/view/InsetsController.java +1 −1 Original line number Diff line number Diff line Loading @@ -1620,7 +1620,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation onAnimationStateChanged(removedTypes, false /* running */); } private void onAnimationStateChanged(@InsetsType int types, boolean running) { void onAnimationStateChanged(@InsetsType int types, boolean running) { boolean insetsChanged = false; for (int i = mSourceConsumers.size() - 1; i >= 0; i--) { final InsetsSourceConsumer consumer = mSourceConsumers.valueAt(i); Loading core/java/android/view/ViewRootImpl.java +7 −0 Original line number Diff line number Diff line Loading @@ -5952,6 +5952,13 @@ public final class ViewRootImpl implements ViewParent, return handled; } void setScrollY(int scrollY) { if (mScroller != null) { mScroller.abortAnimation(); } mScrollY = scrollY; } /** * @hide */ Loading Loading
core/java/android/view/ImeBackAnimationController.java +26 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.view; import static android.view.InsetsController.ANIMATION_TYPE_USER; import static android.view.WindowInsets.Type.ime; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST; Loading Loading @@ -60,6 +61,7 @@ public class ImeBackAnimationController implements OnBackAnimationCallback { private float mLastProgress = 0f; private boolean mTriggerBack = false; private boolean mIsPreCommitAnimationInProgress = false; private int mStartRootScrollY = 0; public ImeBackAnimationController(ViewRootImpl viewRoot) { mInsetsController = viewRoot.getInsetsController(); Loading Loading @@ -96,6 +98,7 @@ public class ImeBackAnimationController implements OnBackAnimationCallback { public void onReady(@NonNull WindowInsetsAnimationController controller, @WindowInsets.Type.InsetsType int types) { mWindowInsetsAnimationController = controller; if (isAdjustPan()) mStartRootScrollY = mViewRoot.mScrollY; if (mIsPreCommitAnimationInProgress) { setPreCommitProgress(mLastProgress); } else { Loading Loading @@ -146,6 +149,10 @@ public class ImeBackAnimationController implements OnBackAnimationCallback { float imeHeight = shownY - hiddenY; float interpolatedProgress = BACK_GESTURE.getInterpolation(progress); int newY = (int) (imeHeight - interpolatedProgress * (imeHeight * PEEK_FRACTION)); if (mStartRootScrollY != 0) { mViewRoot.setScrollY( (int) (mStartRootScrollY * (1 - interpolatedProgress * PEEK_FRACTION))); } mWindowInsetsAnimationController.setInsetsAndAlpha(Insets.of(0, 0, 0, newY), 1f, progress); } Loading Loading @@ -199,6 +206,19 @@ 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(); } } } private void notifyHideIme() { Loading @@ -222,6 +242,7 @@ public class ImeBackAnimationController implements OnBackAnimationCallback { mTriggerBack = false; mIsPreCommitAnimationInProgress = false; mInsetsController.setPredictiveBackImeHideAnimInProgress(false); mStartRootScrollY = 0; } private void resetPostCommitAnimator() { Loading @@ -236,6 +257,11 @@ public class ImeBackAnimationController implements OnBackAnimationCallback { == SOFT_INPUT_ADJUST_RESIZE; } private boolean isAdjustPan() { return (mViewRoot.mWindowAttributes.softInputMode & SOFT_INPUT_MASK_ADJUST) == SOFT_INPUT_ADJUST_PAN; } private boolean isHideAnimationInProgress() { return mPostCommitAnimator != null && mTriggerBack; } Loading
core/java/android/view/ImeInsetsSourceConsumer.java +6 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,12 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer { "ImeInsetsSourceConsumer#onAnimationFinished", mController.getHost().getInputMethodManager(), null /* icProto */); } final boolean insetsChanged = super.onAnimationStateChanged(running); boolean insetsChanged = super.onAnimationStateChanged(running); if (running && !isShowRequested() && mController.isPredictiveBackImeHideAnimInProgress()) { // IME predictive back animation switched from pre-commit to post-commit. insetsChanged |= applyLocalVisibilityOverride(); } if (!isShowRequested()) { mIsRequestedVisibleAwaitingLeash = false; if (!running && !mHasPendingRequest) { Loading
core/java/android/view/InsetsController.java +1 −1 Original line number Diff line number Diff line Loading @@ -1620,7 +1620,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation onAnimationStateChanged(removedTypes, false /* running */); } private void onAnimationStateChanged(@InsetsType int types, boolean running) { void onAnimationStateChanged(@InsetsType int types, boolean running) { boolean insetsChanged = false; for (int i = mSourceConsumers.size() - 1; i >= 0; i--) { final InsetsSourceConsumer consumer = mSourceConsumers.valueAt(i); Loading
core/java/android/view/ViewRootImpl.java +7 −0 Original line number Diff line number Diff line Loading @@ -5952,6 +5952,13 @@ public final class ViewRootImpl implements ViewParent, return handled; } void setScrollY(int scrollY) { if (mScroller != null) { mScroller.abortAnimation(); } mScrollY = scrollY; } /** * @hide */ Loading