From d1cb4404fe7e6751f29c9a40e0c50a815a7e6a78 Mon Sep 17 00:00:00 2001 From: Tony Huang Date: Mon, 27 Apr 2020 11:36:00 +0800 Subject: Start IME animation if its insets update after show Some IME might update its insets after showInsets callback, it should abnormal but we still should be robust to handle such case. Fix it by re-calling startAnimation. If it call while animation, it should cancel previous one and start new one. If animation end, it will run a new animation. Bug: 151628536 Test: force stop Gboard, enter split mode and click text filed on secondary split. Change-Id: I31d8e800ef9fc67406cd7c7902b1c597e9c8dcbe --- .../src/com/android/systemui/stackdivider/Divider.java | 16 +++++++++------- .../com/android/systemui/wm/DisplayImeController.java | 10 ++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java index 555202a2b02c..c02dd988b6c7 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java @@ -211,14 +211,16 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, mTargetShown = imeShouldShow; if (mLastAdjustTop < 0) { mLastAdjustTop = imeShouldShow ? hiddenTop : shownTop; - } else { - // Check for an "interruption" of an existing animation. In this case, we need to - // fake-flip the last-known state direction so that the animation completes in the - // other direction. + } else if (mLastAdjustTop != (imeShouldShow ? mShownTop : mHiddenTop)) { if (mTargetAdjusted != targetAdjusted && targetAdjusted == mAdjusted) { - if (mLastAdjustTop != (imeShouldShow ? mShownTop : mHiddenTop)) { - mAdjusted = mTargetAdjusted; - } + // Check for an "interruption" of an existing animation. In this case, we + // need to fake-flip the last-known state direction so that the animation + // completes in the other direction. + mAdjusted = mTargetAdjusted; + } else if (targetAdjusted && mTargetAdjusted && mAdjusted) { + // Already fully adjusted for IME, but IME height has changed; so, force-start + // an async animation to the new IME height. + mAdjusted = false; } } if (mPaused) { diff --git a/packages/SystemUI/src/com/android/systemui/wm/DisplayImeController.java b/packages/SystemUI/src/com/android/systemui/wm/DisplayImeController.java index c22b718fa50f..c7e9accce093 100644 --- a/packages/SystemUI/src/com/android/systemui/wm/DisplayImeController.java +++ b/packages/SystemUI/src/com/android/systemui/wm/DisplayImeController.java @@ -21,6 +21,7 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.content.res.Configuration; import android.graphics.Point; +import android.graphics.Rect; import android.os.Handler; import android.os.RemoteException; import android.util.Slog; @@ -188,7 +189,16 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged if (mInsetsState.equals(insetsState)) { return; } + + final InsetsSource newSource = insetsState.getSource(InsetsState.ITYPE_IME); + final Rect newFrame = newSource.getFrame(); + final Rect oldFrame = mInsetsState.getSource(InsetsState.ITYPE_IME).getFrame(); + mInsetsState.set(insetsState, true /* copySources */); + if (mImeShowing && !newFrame.equals(oldFrame) && newSource.isVisible()) { + if (DEBUG) Slog.d(TAG, "insetsChanged when IME showing, restart animation"); + startAnimation(mImeShowing, true /* forceRestart */); + } } @Override -- cgit v1.2.3-59-g8ed1b