From 08a7ef9d6d57f2f0e5be054cc0632c729777c885 Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Tue, 21 May 2024 15:00:59 -0400 Subject: [PATCH] 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 --- .../android/launcher3/views/AbstractSlideInView.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/views/AbstractSlideInView.java b/src/com/android/launcher3/views/AbstractSlideInView.java index 5ce455a115..85aad8982c 100644 --- a/src/com/android/launcher3/views/AbstractSlideInView.java +++ b/src/com/android/launcher3/views/AbstractSlideInView.java @@ -92,7 +92,7 @@ public abstract class AbstractSlideInView 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 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 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 return Interpolators.ACCELERATE; } + protected Interpolator getScrimInterpolator() { + return LINEAR; + } + protected void onCloseComplete() { mIsOpen = false; getPopupContainer().removeView(this);