Animate scrim within open/close PendingAnimation.

AbstractSlideInView implementations can override how the scrim is
interpolated.

Test: Manual
Flag: NONE Trivial
Bug: 341784466
Change-Id: Id184a5753b369f8f6b4c3d905d26c1a27209dad6
This commit is contained in:
Brian Isganitis committed 2024-05-21 15:06:54 -04:00
1 parent 91ff82f9f7
commit 08a7ef9d6d
1 file changed
+8 -4
@@ -92,7 +92,7 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
protected @NonNull AnimatorPlaybackController mOpenCloseAnimation;
protected ViewGroup mContent;
protected final View mColorScrim;
protected final @Nullable View mColorScrim;
/**
* Interpolator for {@link #mOpenCloseAnimation} when we are closing due to dragging downwards.
@@ -216,6 +216,9 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
animation.addFloat(
this, TRANSLATION_SHIFT, fromTranslationShift, toTranslationShift, LINEAR);
if (mColorScrim != null) {
animation.setViewAlpha(mColorScrim, 1 - toTranslationShift, getScrimInterpolator());
}
onOpenCloseAnimationPending(animation);
mOpenCloseAnimation = animation.createPlaybackController();
@@ -254,9 +257,6 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
protected void setTranslationShift(float translationShift) {
mTranslationShift = translationShift;
mContent.setTranslationY(mTranslationShift * getShiftRange());
if (mColorScrim != null) {
mColorScrim.setAlpha(1 - mTranslationShift);
}
invalidate();
}
@@ -500,6 +500,10 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
return Interpolators.ACCELERATE;
}
protected Interpolator getScrimInterpolator() {
return LINEAR;
}
protected void onCloseComplete() {
mIsOpen = false;
getPopupContainer().removeView(this);