From c378e64b757dbb83b6024be462a6752bc6a2c5f2 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Wed, 10 Jul 2024 12:45:17 +0100 Subject: [PATCH] focusTransitionScaleAndDimOut should always go from 1f to 0f - Also updated AnimatedFloat to accept a Consumer, so a lambda can be used as updateCallback with refernce to udpated value - Also updated PendingAnimation to accept Animator with TimedInterpolator without specifying SpringProperty Fix: 352195519 Test: manual Flag: EXEMPT bugfix Change-Id: Ifb78c1bcd3ca215a5d214f986a107d0988bff13b --- .../android/quickstep/util/BorderAnimator.kt | 3 +- .../android/quickstep/views/RecentsView.java | 2 +- .../com/android/quickstep/views/TaskView.kt | 29 +++++++------------ .../android/launcher3/anim/AnimatedFloat.java | 17 +++++++++-- .../launcher3/anim/PendingAnimation.java | 7 +++++ 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/BorderAnimator.kt b/quickstep/src/com/android/quickstep/util/BorderAnimator.kt index 85238ed826..7e51fcfedc 100644 --- a/quickstep/src/com/android/quickstep/util/BorderAnimator.kt +++ b/quickstep/src/com/android/quickstep/util/BorderAnimator.kt @@ -50,7 +50,7 @@ private constructor( private val disappearanceDurationMs: Long, private val interpolator: Interpolator, ) { - private val borderAnimationProgress = AnimatedFloat { updateOutline() } + private val borderAnimationProgress = AnimatedFloat { _ -> updateOutline() } private val borderPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { color = borderColor @@ -224,6 +224,7 @@ private constructor( val borderWidth: Float get() = borderWidthPx * animationProgress + val alignmentAdjustment: Float // Outset the border by half the width to create an outwards-growth animation get() = -borderWidth / 2f + alignmentAdjustmentInset diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 7b6d383adc..cb3ed5a9ea 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -3814,7 +3814,7 @@ public abstract class RecentsView + focusTransitionScaleAndDim.value = + FOCUS_TRANSITION_FAST_OUT_INTERPOLATOR.getInterpolation(v) + } + .animateToValue(1f, 0f) private var iconAndDimAnimator: ObjectAnimator? = null // The current background requests to load the task thumbnail and icon @@ -1615,16 +1616,6 @@ constructor( override fun get(taskView: TaskView) = taskView.focusTransitionProgress } - @JvmField - val SCALE_AND_DIM_OUT: FloatProperty = - object : FloatProperty("scaleAndDimFastOut") { - override fun setValue(taskView: TaskView, v: Float) { - taskView.focusTransitionScaleAndDimOut = v - } - - override fun get(taskView: TaskView) = taskView.focusTransitionScaleAndDimOut - } - private val SPLIT_SELECT_TRANSLATION_X: FloatProperty = object : FloatProperty("splitSelectTranslationX") { override fun setValue(taskView: TaskView, v: Float) { diff --git a/src/com/android/launcher3/anim/AnimatedFloat.java b/src/com/android/launcher3/anim/AnimatedFloat.java index b414ab6e35..44411640fb 100644 --- a/src/com/android/launcher3/anim/AnimatedFloat.java +++ b/src/com/android/launcher3/anim/AnimatedFloat.java @@ -20,6 +20,8 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.util.FloatProperty; +import java.util.function.Consumer; + /** * A mutable float which allows animating the value */ @@ -38,9 +40,9 @@ public class AnimatedFloat { } }; - private static final Runnable NO_OP = () -> { }; + private static final Consumer NO_OP = t -> { }; - private final Runnable mUpdateCallback; + private final Consumer mUpdateCallback; private ObjectAnimator mValueAnimator; // Only non-null when an animation is playing to this value. private Float mEndValue; @@ -52,6 +54,10 @@ public class AnimatedFloat { } public AnimatedFloat(Runnable updateCallback) { + this(v -> updateCallback.run()); + } + + public AnimatedFloat(Consumer updateCallback) { mUpdateCallback = updateCallback; } @@ -60,6 +66,11 @@ public class AnimatedFloat { value = initialValue; } + public AnimatedFloat(Consumer updateCallback, float initialValue) { + this(updateCallback); + value = initialValue; + } + /** * Returns an animation from the current value to the given value. */ @@ -99,7 +110,7 @@ public class AnimatedFloat { public void updateValue(float v) { if (Float.compare(v, value) != 0) { value = v; - mUpdateCallback.run(); + mUpdateCallback.accept(value); } } diff --git a/src/com/android/launcher3/anim/PendingAnimation.java b/src/com/android/launcher3/anim/PendingAnimation.java index e58890f7ca..47a2bdd6de 100644 --- a/src/com/android/launcher3/anim/PendingAnimation.java +++ b/src/com/android/launcher3/anim/PendingAnimation.java @@ -59,6 +59,13 @@ public class PendingAnimation extends AnimatedPropertySetter { add(anim, springProperty); } + /** + * Utility method to sent an interpolator on an animation and add it to the list + */ + public void add(Animator anim, TimeInterpolator interpolator) { + add(anim, interpolator, SpringProperty.DEFAULT); + } + @Override public void add(Animator anim) { add(anim, SpringProperty.DEFAULT);