diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2018-06-08 13:01:04 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2018-06-11 09:51:42 -0700 |
commit | 0f3af75eb044ec7ec7f41c80c20ccab43d749567 (patch) | |
tree | 9438d270565e4d734da4034fb19c38cace34cabd /src/com | |
parent | 808e7cae6677695be4a139374f34c3ed87ba6385 (diff) | |
download | android_packages_apps_Trebuchet-0f3af75eb044ec7ec7f41c80c20ccab43d749567.tar.gz android_packages_apps_Trebuchet-0f3af75eb044ec7ec7f41c80c20ccab43d749567.tar.bz2 android_packages_apps_Trebuchet-0f3af75eb044ec7ec7f41c80c20ccab43d749567.zip |
Making the self always follow the vertical progress without any min height limit.
After a certain height, the self fades out, but keeps following the vertical progress.
Eventually the fade-out can be decoupled from vertical progress and tied to the state
Bug: 109829614
Change-Id: I9808ed3fa1730b938196bc6d3518a6d096a13f4c
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher3/anim/Interpolators.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher3/views/ScrimView.java | 22 |
3 files changed, 21 insertions, 10 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 5355c5e55..7fe8d35cb 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -48,6 +48,7 @@ import android.util.Log; import android.util.Pair; import android.util.TypedValue; import android.view.View; +import android.view.animation.Interpolator; import com.android.launcher3.config.FeatureFlags; @@ -281,13 +282,14 @@ public final class Utilities { * @param toMax The upper bound of the range that t is being mapped to. * @return The mapped value of t. */ - public static float mapToRange(float t, float fromMin, float fromMax, float toMin, float toMax) { + public static float mapToRange(float t, float fromMin, float fromMax, float toMin, float toMax, + Interpolator interpolator) { if (fromMin == fromMax || toMin == toMax) { Log.e(TAG, "mapToRange: range has 0 length"); return toMin; } float progress = Math.abs(t - fromMin) / Math.abs(fromMax - fromMin); - return mapRange(progress, toMin, toMax); + return mapRange(interpolator.getInterpolation(progress), toMin, toMax); } public static float mapRange(float value, float min, float max) { diff --git a/src/com/android/launcher3/anim/Interpolators.java b/src/com/android/launcher3/anim/Interpolators.java index d17572e6c..a4cba4f62 100644 --- a/src/com/android/launcher3/anim/Interpolators.java +++ b/src/com/android/launcher3/anim/Interpolators.java @@ -158,7 +158,6 @@ public class Interpolators { */ public static Interpolator mapToProgress(Interpolator interpolator, float lowerBound, float upperBound) { - return t -> Utilities.mapToRange(interpolator.getInterpolation(t), 0, 1, - lowerBound, upperBound); + return t -> Utilities.mapRange(interpolator.getInterpolation(t), lowerBound, upperBound); } }
\ No newline at end of file diff --git a/src/com/android/launcher3/views/ScrimView.java b/src/com/android/launcher3/views/ScrimView.java index 6e3ef0705..7066980a9 100644 --- a/src/com/android/launcher3/views/ScrimView.java +++ b/src/com/android/launcher3/views/ScrimView.java @@ -109,6 +109,7 @@ public class ScrimView extends View implements Insettable, OnChangeListener, protected int mEndFlatColorAlpha; protected final int mDragHandleSize; + protected float mDragHandleOffset; private final Rect mDragHandleBounds; private final RectF mHitRect = new RectF(); @@ -223,8 +224,14 @@ public class ScrimView extends View implements Insettable, OnChangeListener, if (mCurrentFlatColor != 0) { canvas.drawColor(mCurrentFlatColor); } + drawDragHandle(canvas); + } + + protected void drawDragHandle(Canvas canvas) { if (mDragHandle != null) { + canvas.translate(0, -mDragHandleOffset); mDragHandle.draw(canvas); + canvas.translate(0, mDragHandleOffset); } } @@ -237,20 +244,23 @@ public class ScrimView extends View implements Insettable, OnChangeListener, final Drawable drawable = mDragHandle; mDragHandle = null; - drawable.setBounds(mDragHandleBounds); - Rect topBounds = new Rect(mDragHandleBounds); - topBounds.offset(0, -mDragHandleBounds.height() / 2); + Rect bounds = new Rect(mDragHandleBounds); + bounds.offset(0, -(int) mDragHandleOffset); + drawable.setBounds(bounds); + + Rect topBounds = new Rect(bounds); + topBounds.offset(0, -bounds.height() / 2); - Rect invalidateRegion = new Rect(mDragHandleBounds); + Rect invalidateRegion = new Rect(bounds); invalidateRegion.top = topBounds.top; Keyframe frameTop = Keyframe.ofObject(0.6f, topBounds); frameTop.setInterpolator(DEACCEL); - Keyframe frameBot = Keyframe.ofObject(1, mDragHandleBounds); + Keyframe frameBot = Keyframe.ofObject(1, bounds); frameBot.setInterpolator(ACCEL); PropertyValuesHolder holder = PropertyValuesHolder .ofKeyframe("bounds", - Keyframe.ofObject(0, mDragHandleBounds), frameTop, frameBot); + Keyframe.ofObject(0, bounds), frameTop, frameBot); holder.setEvaluator(new RectEvaluator()); ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(drawable, holder); |