Loading quickstep/src/com/android/quickstep/views/TaskMenuView.java +1 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import android.widget.TextView; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.FastBitmapDrawable; import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.R; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.Interpolators; Loading Loading @@ -241,7 +240,7 @@ public class TaskMenuView extends AbstractFloatingView { if (mOpenCloseAnimator != null && mOpenCloseAnimator.isRunning()) { mOpenCloseAnimator.end(); } mOpenCloseAnimator = LauncherAnimUtils.createAnimatorSet(); mOpenCloseAnimator = new AnimatorSet(); final Animator revealAnimator = createOpenCloseOutlineProvider() .createRevealAnimator(this, closing); Loading src/com/android/launcher3/AppWidgetResizeFrame.java +10 −14 Original line number Diff line number Diff line Loading @@ -433,22 +433,18 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O } requestLayout(); } else { PropertyValuesHolder width = PropertyValuesHolder.ofInt("width", lp.width, newWidth); PropertyValuesHolder height = PropertyValuesHolder.ofInt("height", lp.height, newHeight); PropertyValuesHolder x = PropertyValuesHolder.ofInt("x", lp.x, newX); PropertyValuesHolder y = PropertyValuesHolder.ofInt("y", lp.y, newY); ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(lp, this, width, height, x, y); oa.addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { requestLayout(); } }); AnimatorSet set = LauncherAnimUtils.createAnimatorSet(); ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(lp, this, PropertyValuesHolder.ofInt("width", lp.width, newWidth), PropertyValuesHolder.ofInt("height", lp.height, newHeight), PropertyValuesHolder.ofInt("x", lp.x, newX), PropertyValuesHolder.ofInt("y", lp.y, newY)); oa.addUpdateListener(a -> requestLayout()); AnimatorSet set = new AnimatorSet(); set.play(oa); for (int i = 0; i < HANDLE_COUNT; i++) { set.play(LauncherAnimUtils.ofFloat(mDragHandles[i], ALPHA, 1.0f)); set.play(LauncherAnimUtils.ofPropertyValuesHolder(mDragHandles[i], PropertyValuesHolder.ofFloat(ALPHA, 1f))); } set.setDuration(SNAP_DURATION); Loading src/com/android/launcher3/CellLayout.java +32 −17 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.launcher3; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; Loading @@ -34,11 +35,13 @@ import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Parcelable; import android.os.SystemClock; import android.support.annotation.IntDef; import android.support.v4.view.ViewCompat; import android.util.ArrayMap; import android.util.AttributeSet; import android.util.Log; import android.util.Property; import android.util.SparseArray; import android.view.MotionEvent; import android.view.View; Loading Loading @@ -243,7 +246,7 @@ public class CellLayout extends ViewGroup { for (int i = 0; i < mDragOutlineAnims.length; i++) { final InterruptibleInOutAnimator anim = new InterruptibleInOutAnimator(this, duration, fromAlphaValue, toAlphaValue); new InterruptibleInOutAnimator(duration, fromAlphaValue, toAlphaValue); anim.getAnimator().setInterpolator(mEaseOutInterpolator); final int thisIndex = i; anim.getAnimator().addUpdateListener(new AnimatorUpdateListener() { Loading Loading @@ -877,7 +880,7 @@ public class CellLayout extends ViewGroup { return true; } ValueAnimator va = LauncherAnimUtils.ofFloat(0f, 1f); ValueAnimator va = ValueAnimator.ofFloat(0f, 1f); va.setDuration(duration); mReorderAnimators.put(lp, va); Loading Loading @@ -1884,6 +1887,19 @@ public class CellLayout extends ViewGroup { } } private static final Property<ReorderPreviewAnimation, Float> ANIMATION_PROGRESS = new Property<ReorderPreviewAnimation, Float>(float.class, "animationProgress") { @Override public Float get(ReorderPreviewAnimation anim) { return anim.animationProgress; } @Override public void set(ReorderPreviewAnimation anim, Float progress) { anim.setAnimationProgress(progress); } }; // Class which represents the reorder preview animations. These animations show that an item is // in a temporary state, and hint at where the item will return to. class ReorderPreviewAnimation { Loading @@ -1904,6 +1920,7 @@ public class CellLayout extends ViewGroup { public static final int MODE_HINT = 0; public static final int MODE_PREVIEW = 1; float animationProgress = 0; Animator a; public ReorderPreviewAnimation(View child, int mode, int cellX0, int cellY0, int cellX1, Loading Loading @@ -1974,7 +1991,7 @@ public class CellLayout extends ViewGroup { if (noMovement) { return; } ValueAnimator va = LauncherAnimUtils.ofFloat(0f, 1f); ValueAnimator va = ObjectAnimator.ofFloat(this, ANIMATION_PROGRESS, 0, 1); a = va; // Animations are disabled in power save mode, causing the repeated animation to jump Loading @@ -1987,20 +2004,6 @@ public class CellLayout extends ViewGroup { va.setDuration(mode == MODE_HINT ? HINT_DURATION : PREVIEW_DURATION); va.setStartDelay((int) (Math.random() * 60)); va.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float r = (Float) animation.getAnimatedValue(); float r1 = (mode == MODE_HINT && repeating) ? 1.0f : r; float x = r1 * finalDeltaX + (1 - r1) * initDeltaX; float y = r1 * finalDeltaY + (1 - r1) * initDeltaY; child.setTranslationX(x); child.setTranslationY(y); float s = r * finalScale + (1 - r) * initScale; child.setScaleX(s); child.setScaleY(s); } }); va.addListener(new AnimatorListenerAdapter() { public void onAnimationRepeat(Animator animation) { // We make sure to end only after a full period Loading @@ -2012,6 +2015,18 @@ public class CellLayout extends ViewGroup { va.start(); } private void setAnimationProgress(float progress) { animationProgress = progress; float r1 = (mode == MODE_HINT && repeating) ? 1.0f : animationProgress; float x = r1 * finalDeltaX + (1 - r1) * initDeltaX; float y = r1 * finalDeltaY + (1 - r1) * initDeltaY; child.setTranslationX(x); child.setTranslationY(y); float s = animationProgress * finalScale + (1 - animationProgress) * initScale; child.setScaleX(s); child.setScaleY(s); } private void cancel() { if (a != null) { a.cancel(); Loading src/com/android/launcher3/FirstFrameAnimatorHelper.java +6 −24 Original line number Diff line number Diff line Loading @@ -16,24 +16,21 @@ package com.android.launcher3; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import static com.android.launcher3.Utilities.SINGLE_FRAME_MS; import android.animation.ValueAnimator; import android.util.Log; import android.view.View; import android.view.ViewPropertyAnimator; import android.view.ViewTreeObserver; import com.android.launcher3.util.Thunk; import static com.android.launcher3.Utilities.SINGLE_FRAME_MS; import com.android.launcher3.util.Thunk; /* * This is a helper class that listens to updates from the corresponding animation. * For the first two frames, it adjusts the current play time of the animation to * prevent jank at the beginning of the animation */ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter implements ValueAnimator.AnimatorUpdateListener { public class FirstFrameAnimatorHelper implements ValueAnimator.AnimatorUpdateListener { private static final String TAG = "FirstFrameAnimatorHlpr"; private static final boolean DEBUG = false; private static final int MAX_DELAY = 1000; Loading @@ -52,18 +49,6 @@ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter animator.addUpdateListener(this); } public FirstFrameAnimatorHelper(ViewPropertyAnimator vpa, View target) { mTarget = target; vpa.setListener(this); } // only used for ViewPropertyAnimators public void onAnimationStart(Animator animation) { final ValueAnimator va = (ValueAnimator) animation; va.addUpdateListener(FirstFrameAnimatorHelper.this); onAnimationUpdate(va); } public static void setIsVisible(boolean visible) { sVisible = visible; } Loading @@ -78,6 +63,7 @@ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter sVisible = true; } @Override public void onAnimationUpdate(final ValueAnimator animation) { final long currentTime = System.currentTimeMillis(); if (mStartTime == -1) { Loading Loading @@ -115,11 +101,7 @@ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter mAdjustedSecondFrameTime = true; } else { if (frameNum > 1) { mTarget.post(new Runnable() { public void run() { animation.removeUpdateListener(FirstFrameAnimatorHelper.this); } }); mTarget.post(() -> animation.removeUpdateListener(this)); } if (DEBUG) print(animation); } Loading src/com/android/launcher3/InterruptibleInOutAnimator.java +21 −4 Original line number Diff line number Diff line Loading @@ -18,7 +18,9 @@ package com.android.launcher3; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.util.Property; import android.view.View; import com.android.launcher3.util.Thunk; Loading @@ -31,11 +33,27 @@ import com.android.launcher3.util.Thunk; * interpolator in the same direction. */ public class InterruptibleInOutAnimator { private static final Property<InterruptibleInOutAnimator, Float> VALUE = new Property<InterruptibleInOutAnimator, Float>(Float.TYPE, "value") { @Override public Float get(InterruptibleInOutAnimator anim) { return anim.mValue; } @Override public void set(InterruptibleInOutAnimator anim, Float value) { anim.mValue = value; } }; private long mOriginalDuration; private float mOriginalFromValue; private float mOriginalToValue; private ValueAnimator mAnimator; private float mValue; private boolean mFirstRun = true; private Object mTag = null; Loading @@ -47,8 +65,8 @@ public class InterruptibleInOutAnimator { // TODO: This isn't really necessary, but is here to help diagnose a bug in the drag viz @Thunk int mDirection = STOPPED; public InterruptibleInOutAnimator(View view, long duration, float fromValue, float toValue) { mAnimator = LauncherAnimUtils.ofFloat(fromValue, toValue).setDuration(duration); public InterruptibleInOutAnimator(long duration, float fromValue, float toValue) { mAnimator = ObjectAnimator.ofFloat(this, VALUE, fromValue, toValue).setDuration(duration); mOriginalDuration = duration; mOriginalFromValue = fromValue; mOriginalToValue = toValue; Loading @@ -64,8 +82,7 @@ public class InterruptibleInOutAnimator { private void animate(int direction) { final long currentPlayTime = mAnimator.getCurrentPlayTime(); final float toValue = (direction == IN) ? mOriginalToValue : mOriginalFromValue; final float startValue = mFirstRun ? mOriginalFromValue : ((Float) mAnimator.getAnimatedValue()).floatValue(); final float startValue = mFirstRun ? mOriginalFromValue : mValue; // Make sure it's stopped before we modify any values cancel(); Loading Loading
quickstep/src/com/android/quickstep/views/TaskMenuView.java +1 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import android.widget.TextView; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.FastBitmapDrawable; import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.R; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.Interpolators; Loading Loading @@ -241,7 +240,7 @@ public class TaskMenuView extends AbstractFloatingView { if (mOpenCloseAnimator != null && mOpenCloseAnimator.isRunning()) { mOpenCloseAnimator.end(); } mOpenCloseAnimator = LauncherAnimUtils.createAnimatorSet(); mOpenCloseAnimator = new AnimatorSet(); final Animator revealAnimator = createOpenCloseOutlineProvider() .createRevealAnimator(this, closing); Loading
src/com/android/launcher3/AppWidgetResizeFrame.java +10 −14 Original line number Diff line number Diff line Loading @@ -433,22 +433,18 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O } requestLayout(); } else { PropertyValuesHolder width = PropertyValuesHolder.ofInt("width", lp.width, newWidth); PropertyValuesHolder height = PropertyValuesHolder.ofInt("height", lp.height, newHeight); PropertyValuesHolder x = PropertyValuesHolder.ofInt("x", lp.x, newX); PropertyValuesHolder y = PropertyValuesHolder.ofInt("y", lp.y, newY); ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(lp, this, width, height, x, y); oa.addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { requestLayout(); } }); AnimatorSet set = LauncherAnimUtils.createAnimatorSet(); ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(lp, this, PropertyValuesHolder.ofInt("width", lp.width, newWidth), PropertyValuesHolder.ofInt("height", lp.height, newHeight), PropertyValuesHolder.ofInt("x", lp.x, newX), PropertyValuesHolder.ofInt("y", lp.y, newY)); oa.addUpdateListener(a -> requestLayout()); AnimatorSet set = new AnimatorSet(); set.play(oa); for (int i = 0; i < HANDLE_COUNT; i++) { set.play(LauncherAnimUtils.ofFloat(mDragHandles[i], ALPHA, 1.0f)); set.play(LauncherAnimUtils.ofPropertyValuesHolder(mDragHandles[i], PropertyValuesHolder.ofFloat(ALPHA, 1f))); } set.setDuration(SNAP_DURATION); Loading
src/com/android/launcher3/CellLayout.java +32 −17 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.launcher3; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; Loading @@ -34,11 +35,13 @@ import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Parcelable; import android.os.SystemClock; import android.support.annotation.IntDef; import android.support.v4.view.ViewCompat; import android.util.ArrayMap; import android.util.AttributeSet; import android.util.Log; import android.util.Property; import android.util.SparseArray; import android.view.MotionEvent; import android.view.View; Loading Loading @@ -243,7 +246,7 @@ public class CellLayout extends ViewGroup { for (int i = 0; i < mDragOutlineAnims.length; i++) { final InterruptibleInOutAnimator anim = new InterruptibleInOutAnimator(this, duration, fromAlphaValue, toAlphaValue); new InterruptibleInOutAnimator(duration, fromAlphaValue, toAlphaValue); anim.getAnimator().setInterpolator(mEaseOutInterpolator); final int thisIndex = i; anim.getAnimator().addUpdateListener(new AnimatorUpdateListener() { Loading Loading @@ -877,7 +880,7 @@ public class CellLayout extends ViewGroup { return true; } ValueAnimator va = LauncherAnimUtils.ofFloat(0f, 1f); ValueAnimator va = ValueAnimator.ofFloat(0f, 1f); va.setDuration(duration); mReorderAnimators.put(lp, va); Loading Loading @@ -1884,6 +1887,19 @@ public class CellLayout extends ViewGroup { } } private static final Property<ReorderPreviewAnimation, Float> ANIMATION_PROGRESS = new Property<ReorderPreviewAnimation, Float>(float.class, "animationProgress") { @Override public Float get(ReorderPreviewAnimation anim) { return anim.animationProgress; } @Override public void set(ReorderPreviewAnimation anim, Float progress) { anim.setAnimationProgress(progress); } }; // Class which represents the reorder preview animations. These animations show that an item is // in a temporary state, and hint at where the item will return to. class ReorderPreviewAnimation { Loading @@ -1904,6 +1920,7 @@ public class CellLayout extends ViewGroup { public static final int MODE_HINT = 0; public static final int MODE_PREVIEW = 1; float animationProgress = 0; Animator a; public ReorderPreviewAnimation(View child, int mode, int cellX0, int cellY0, int cellX1, Loading Loading @@ -1974,7 +1991,7 @@ public class CellLayout extends ViewGroup { if (noMovement) { return; } ValueAnimator va = LauncherAnimUtils.ofFloat(0f, 1f); ValueAnimator va = ObjectAnimator.ofFloat(this, ANIMATION_PROGRESS, 0, 1); a = va; // Animations are disabled in power save mode, causing the repeated animation to jump Loading @@ -1987,20 +2004,6 @@ public class CellLayout extends ViewGroup { va.setDuration(mode == MODE_HINT ? HINT_DURATION : PREVIEW_DURATION); va.setStartDelay((int) (Math.random() * 60)); va.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float r = (Float) animation.getAnimatedValue(); float r1 = (mode == MODE_HINT && repeating) ? 1.0f : r; float x = r1 * finalDeltaX + (1 - r1) * initDeltaX; float y = r1 * finalDeltaY + (1 - r1) * initDeltaY; child.setTranslationX(x); child.setTranslationY(y); float s = r * finalScale + (1 - r) * initScale; child.setScaleX(s); child.setScaleY(s); } }); va.addListener(new AnimatorListenerAdapter() { public void onAnimationRepeat(Animator animation) { // We make sure to end only after a full period Loading @@ -2012,6 +2015,18 @@ public class CellLayout extends ViewGroup { va.start(); } private void setAnimationProgress(float progress) { animationProgress = progress; float r1 = (mode == MODE_HINT && repeating) ? 1.0f : animationProgress; float x = r1 * finalDeltaX + (1 - r1) * initDeltaX; float y = r1 * finalDeltaY + (1 - r1) * initDeltaY; child.setTranslationX(x); child.setTranslationY(y); float s = animationProgress * finalScale + (1 - animationProgress) * initScale; child.setScaleX(s); child.setScaleY(s); } private void cancel() { if (a != null) { a.cancel(); Loading
src/com/android/launcher3/FirstFrameAnimatorHelper.java +6 −24 Original line number Diff line number Diff line Loading @@ -16,24 +16,21 @@ package com.android.launcher3; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import static com.android.launcher3.Utilities.SINGLE_FRAME_MS; import android.animation.ValueAnimator; import android.util.Log; import android.view.View; import android.view.ViewPropertyAnimator; import android.view.ViewTreeObserver; import com.android.launcher3.util.Thunk; import static com.android.launcher3.Utilities.SINGLE_FRAME_MS; import com.android.launcher3.util.Thunk; /* * This is a helper class that listens to updates from the corresponding animation. * For the first two frames, it adjusts the current play time of the animation to * prevent jank at the beginning of the animation */ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter implements ValueAnimator.AnimatorUpdateListener { public class FirstFrameAnimatorHelper implements ValueAnimator.AnimatorUpdateListener { private static final String TAG = "FirstFrameAnimatorHlpr"; private static final boolean DEBUG = false; private static final int MAX_DELAY = 1000; Loading @@ -52,18 +49,6 @@ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter animator.addUpdateListener(this); } public FirstFrameAnimatorHelper(ViewPropertyAnimator vpa, View target) { mTarget = target; vpa.setListener(this); } // only used for ViewPropertyAnimators public void onAnimationStart(Animator animation) { final ValueAnimator va = (ValueAnimator) animation; va.addUpdateListener(FirstFrameAnimatorHelper.this); onAnimationUpdate(va); } public static void setIsVisible(boolean visible) { sVisible = visible; } Loading @@ -78,6 +63,7 @@ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter sVisible = true; } @Override public void onAnimationUpdate(final ValueAnimator animation) { final long currentTime = System.currentTimeMillis(); if (mStartTime == -1) { Loading Loading @@ -115,11 +101,7 @@ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter mAdjustedSecondFrameTime = true; } else { if (frameNum > 1) { mTarget.post(new Runnable() { public void run() { animation.removeUpdateListener(FirstFrameAnimatorHelper.this); } }); mTarget.post(() -> animation.removeUpdateListener(this)); } if (DEBUG) print(animation); } Loading
src/com/android/launcher3/InterruptibleInOutAnimator.java +21 −4 Original line number Diff line number Diff line Loading @@ -18,7 +18,9 @@ package com.android.launcher3; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.util.Property; import android.view.View; import com.android.launcher3.util.Thunk; Loading @@ -31,11 +33,27 @@ import com.android.launcher3.util.Thunk; * interpolator in the same direction. */ public class InterruptibleInOutAnimator { private static final Property<InterruptibleInOutAnimator, Float> VALUE = new Property<InterruptibleInOutAnimator, Float>(Float.TYPE, "value") { @Override public Float get(InterruptibleInOutAnimator anim) { return anim.mValue; } @Override public void set(InterruptibleInOutAnimator anim, Float value) { anim.mValue = value; } }; private long mOriginalDuration; private float mOriginalFromValue; private float mOriginalToValue; private ValueAnimator mAnimator; private float mValue; private boolean mFirstRun = true; private Object mTag = null; Loading @@ -47,8 +65,8 @@ public class InterruptibleInOutAnimator { // TODO: This isn't really necessary, but is here to help diagnose a bug in the drag viz @Thunk int mDirection = STOPPED; public InterruptibleInOutAnimator(View view, long duration, float fromValue, float toValue) { mAnimator = LauncherAnimUtils.ofFloat(fromValue, toValue).setDuration(duration); public InterruptibleInOutAnimator(long duration, float fromValue, float toValue) { mAnimator = ObjectAnimator.ofFloat(this, VALUE, fromValue, toValue).setDuration(duration); mOriginalDuration = duration; mOriginalFromValue = fromValue; mOriginalToValue = toValue; Loading @@ -64,8 +82,7 @@ public class InterruptibleInOutAnimator { private void animate(int direction) { final long currentPlayTime = mAnimator.getCurrentPlayTime(); final float toValue = (direction == IN) ? mOriginalToValue : mOriginalFromValue; final float startValue = mFirstRun ? mOriginalFromValue : ((Float) mAnimator.getAnimatedValue()).floatValue(); final float startValue = mFirstRun ? mOriginalFromValue : mValue; // Make sure it's stopped before we modify any values cancel(); Loading