From d2ae944a439bbc590b67d48cd35e5242593fa281 Mon Sep 17 00:00:00 2001 From: Josh Tsuji Date: Mon, 2 May 2022 14:06:34 -0400 Subject: [PATCH] Actually interpolate the time value. This was broken and always linear. Bug: 229890190 Test: atest SystemUITests Change-Id: I7db6f5025c0fc70c9899c97ee23e486ede61a085 --- .../android/launcher3/anim/Interpolators.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/anim/Interpolators.java b/src/com/android/launcher3/anim/Interpolators.java index 4ff5d5e973..f8a2c79ab1 100644 --- a/src/com/android/launcher3/anim/Interpolators.java +++ b/src/com/android/launcher3/anim/Interpolators.java @@ -156,14 +156,18 @@ public class Interpolators { String.format("upperBound (%f) must be greater than lowerBound (%f)", upperBound, lowerBound)); } - return t -> clampToProgress(t, lowerBound, upperBound); + return t -> clampToProgress(interpolator, t, lowerBound, upperBound); } /** * Returns the progress value's progress between the lower and upper bounds. That is, the * progress will be 0f from 0f to lowerBound, and reach 1f by upperBound. + * + * Between lowerBound and upperBound, the progress value will be interpolated using the provided + * interpolator. */ - public static float clampToProgress(float progress, float lowerBound, float upperBound) { + public static float clampToProgress( + Interpolator interpolator, float progress, float lowerBound, float upperBound) { if (upperBound < lowerBound) { throw new IllegalArgumentException( String.format("upperBound (%f) must be greater than lowerBound (%f)", @@ -179,7 +183,15 @@ public class Interpolators { if (progress > upperBound) { return 1; } - return (progress - lowerBound) / (upperBound - lowerBound); + return interpolator.getInterpolation((progress - lowerBound) / (upperBound - lowerBound)); + } + + /** + * Returns the progress value's progress between the lower and upper bounds. That is, the + * progress will be 0f from 0f to lowerBound, and reach 1f by upperBound. + */ + public static float clampToProgress(float progress, float lowerBound, float upperBound) { + return clampToProgress(Interpolators.LINEAR, progress, lowerBound, upperBound); } /**