summaryrefslogtreecommitdiff
path: root/src/com/android/launcher3/anim
diff options
context:
space:
mode:
authorJosh Tsuji <tsuji@google.com>2022-03-29 18:41:25 -0400
committerJosh Tsuji <tsuji@google.com>2022-04-06 14:26:50 -0400
commitfeb31ca56716f9ab839753bf7cbfb40e378d7867 (patch)
treee2f49189257dfda21be8a9a652eb0cf49474ac45 /src/com/android/launcher3/anim
parent690661159e3012dacd6ccab0d09d4f1858659eaa (diff)
downloadLauncher3-feb31ca56716f9ab839753bf7cbfb40e378d7867.tar.gz
Add the staggered ring appear animation!
Bug: 197636896 Test: a lot of unlocking Change-Id: I9a713ac12eae5128d409166110cece0b86d89ae4
Diffstat (limited to 'src/com/android/launcher3/anim')
-rw-r--r--src/com/android/launcher3/anim/Interpolators.java48
1 files changed, 34 insertions, 14 deletions
diff --git a/src/com/android/launcher3/anim/Interpolators.java b/src/com/android/launcher3/anim/Interpolators.java
index 9c12abdf4e..3fe1082e29 100644
--- a/src/com/android/launcher3/anim/Interpolators.java
+++ b/src/com/android/launcher3/anim/Interpolators.java
@@ -47,6 +47,13 @@ public class Interpolators {
public static final Interpolator DEACCEL_2_5 = new DecelerateInterpolator(2.5f);
public static final Interpolator DEACCEL_3 = new DecelerateInterpolator(3f);
+ /**
+ * The decelerating emphasized interpolator. Used for hero / emphasized movement of content that
+ * is appearing e.g. when coming from off screen
+ */
+ public static final Interpolator EMPHASIZED_DECELERATE = new PathInterpolator(
+ 0.05f, 0.7f, 0.1f, 1f);
+
public static final Interpolator ACCEL_DEACCEL = new AccelerateDecelerateInterpolator();
public static final Interpolator FAST_OUT_SLOW_IN = new PathInterpolator(0.4f, 0f, 0.2f, 1f);
@@ -162,8 +169,9 @@ public class Interpolators {
}
/**
- * Runs the given interpolator such that the entire progress is set between the given bounds.
- * That is, we set the interpolation to 0 until lowerBound and reach 1 by upperBound.
+ * Returns a function that runs the given interpolator such that the entire progress is set
+ * between the given bounds. That is, we set the interpolation to 0 until lowerBound and reach
+ * 1 by upperBound.
*/
public static Interpolator clampToProgress(Interpolator interpolator, float lowerBound,
float upperBound) {
@@ -172,18 +180,30 @@ public class Interpolators {
String.format("upperBound (%f) must be greater than lowerBound (%f)",
upperBound, lowerBound));
}
- return t -> {
- if (t == lowerBound && t == upperBound) {
- return t == 0f ? 0 : 1;
- }
- if (t < lowerBound) {
- return 0;
- }
- if (t > upperBound) {
- return 1;
- }
- return interpolator.getInterpolation((t - lowerBound) / (upperBound - lowerBound));
- };
+ return t -> clampToProgress(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.
+ */
+ public static float clampToProgress(float progress, float lowerBound, float upperBound) {
+ if (upperBound < lowerBound) {
+ throw new IllegalArgumentException(
+ String.format("upperBound (%f) must be greater than lowerBound (%f)",
+ upperBound, lowerBound));
+ }
+
+ if (progress == lowerBound && progress == upperBound) {
+ return progress == 0f ? 0 : 1;
+ }
+ if (progress < lowerBound) {
+ return 0;
+ }
+ if (progress > upperBound) {
+ return 1;
+ }
+ return (progress - lowerBound) / (upperBound - lowerBound);
}
/**