diff options
Diffstat (limited to 'core/java/android/view/InsetsAnimationControlImpl.java')
| -rw-r--r-- | core/java/android/view/InsetsAnimationControlImpl.java | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/core/java/android/view/InsetsAnimationControlImpl.java b/core/java/android/view/InsetsAnimationControlImpl.java index cd56ca9251ab..baeae2fd2cdd 100644 --- a/core/java/android/view/InsetsAnimationControlImpl.java +++ b/core/java/android/view/InsetsAnimationControlImpl.java @@ -16,13 +16,14 @@ package android.view; +import static android.view.InsetsController.ANIMATION_TYPE_SHOW; import static android.view.InsetsController.AnimationType; import static android.view.InsetsController.DEBUG; import static android.view.InsetsState.ISIDE_BOTTOM; -import static android.view.InsetsState.ISIDE_FLOATING; import static android.view.InsetsState.ISIDE_LEFT; import static android.view.InsetsState.ISIDE_RIGHT; import static android.view.InsetsState.ISIDE_TOP; +import static android.view.InsetsState.ITYPE_IME; import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE; @@ -74,6 +75,8 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll private final @InsetsType int mTypes; private final InsetsAnimationControlCallbacks mController; private final WindowInsetsAnimation mAnimation; + /** @see WindowInsetsAnimationController#hasZeroInsetsIme */ + private final boolean mHasZeroInsetsIme; private Insets mCurrentInsets; private Insets mPendingInsets; private float mPendingFraction; @@ -102,6 +105,12 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll null /* typeSideMap */); mShownInsets = calculateInsets(mInitialInsetsState, frame, controls, true /* shown */, mTypeSideMap); + mHasZeroInsetsIme = mShownInsets.bottom == 0 && controlsInternalType(ITYPE_IME); + if (mHasZeroInsetsIme) { + // IME has shownInsets of ZERO, and can't map to a side by default. + // Map zero insets IME to bottom, making it a special case of bottom insets. + mTypeSideMap.put(ITYPE_IME, ISIDE_BOTTOM); + } buildTypeSourcesMap(mTypeSideMap, mSideSourceMap, mControls); mAnimation = new WindowInsetsAnimation(mTypes, interpolator, @@ -113,6 +122,11 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll } @Override + public boolean hasZeroInsetsIme() { + return mHasZeroInsetsIme; + } + + @Override public Insets getHiddenStateInsets() { return mHiddenInsets; } @@ -182,8 +196,6 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll params, state, mPendingAlpha); updateLeashesForSide(ISIDE_BOTTOM, offset.bottom, mShownInsets.bottom, mPendingInsets.bottom, params, state, mPendingAlpha); - updateLeashesForSide(ISIDE_FLOATING, 0 /* offset */, 0 /* inset */, 0 /* maxInset */, - params, state, mPendingAlpha); mController.applySurfaceParams(params.toArray(new SurfaceParams[params.size()])); mCurrentInsets = mPendingInsets; @@ -290,6 +302,9 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll if (insets == null) { insets = getCurrentInsets(); } + if (hasZeroInsetsIme()) { + return insets; + } return Insets.max(Insets.min(insets, mShownInsets), mHiddenInsets); } @@ -313,17 +328,19 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll mTmpFrame.set(source.getFrame()); addTranslationToMatrix(side, offset, mTmpMatrix, mTmpFrame); - state.getSource(source.getType()).setVisible(side == ISIDE_FLOATING || inset != 0); + final boolean visible = mHasZeroInsetsIme && side == ISIDE_BOTTOM + ? (mAnimationType == ANIMATION_TYPE_SHOW ? true : !mFinished) + : inset != 0; + + state.getSource(source.getType()).setVisible(visible); state.getSource(source.getType()).setFrame(mTmpFrame); // If the system is controlling the insets source, the leash can be null. if (leash != null) { SurfaceParams params = new SurfaceParams.Builder(leash) - .withAlpha(side == ISIDE_FLOATING ? 1 : alpha) + .withAlpha(alpha) .withMatrix(mTmpMatrix) - .withVisibility(side == ISIDE_FLOATING - ? mShownOnFinish - : inset != 0 /* visible */) + .withVisibility(visible) .build(); surfaceParams.add(params); } |
