diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-07-22 10:50:11 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2016-07-27 17:37:23 -0700 |
commit | a2454ad2d8dcffa94f670853eb464726c73597f1 (patch) | |
tree | 63899483e75a7faadff477cb117bf5c5cfc54962 /src/com/android/launcher3/dragndrop | |
parent | 71538da6e2e70af15684cc270a6e67c9b5a010dc (diff) | |
download | android_packages_apps_Trebuchet-a2454ad2d8dcffa94f670853eb464726c73597f1.tar.gz android_packages_apps_Trebuchet-a2454ad2d8dcffa94f670853eb464726c73597f1.tar.bz2 android_packages_apps_Trebuchet-a2454ad2d8dcffa94f670853eb464726c73597f1.zip |
Launcher shortcuts animations update.
> The shortcut container closes with an animation
> When opening/closing the animation only the icon scales
and not the title and drag handle
> When dragging the icon, it starts from the original icon position and
moves under the user finger. The container grows to follow the drag view.
Bug: 28980830
Change-Id: Ic0353c30b682d1f018cbf4d62e8a6e8e7d7d4664
Diffstat (limited to 'src/com/android/launcher3/dragndrop')
-rw-r--r-- | src/com/android/launcher3/dragndrop/DragView.java | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java index e95f07b3c..8a2ae94f6 100644 --- a/src/com/android/launcher3/dragndrop/DragView.java +++ b/src/com/android/launcher3/dragndrop/DragView.java @@ -47,7 +47,8 @@ import com.android.launcher3.R; import java.util.Arrays; public class DragView extends View { - public static int COLOR_CHANGE_DURATION = 120; + public static final int COLOR_CHANGE_DURATION = 120; + public static final int VIEW_ZOOM_DURATION = 150; @Thunk static float sDragAlpha = 1f; @@ -73,6 +74,11 @@ public class DragView extends View { @Thunk float[] mCurrentFilter; private ValueAnimator mFilterAnimator; + private int mLastTouchX; + private int mLastTouchY; + private int mAnimatedShiftX; + private int mAnimatedShiftY; + /** * Construct the drag view. * <p> @@ -98,7 +104,7 @@ public class DragView extends View { // Animate the view into the correct position mAnim = LauncherAnimUtils.ofFloat(this, 0f, 1f); - mAnim.setDuration(150); + mAnim.setDuration(VIEW_ZOOM_DURATION); mAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { @@ -310,7 +316,6 @@ public class DragView extends View { /** * Create a window containing this view and show it. * - * @param windowToken obtained from v.getWindowToken() from one of your views * @param touchX the x coordinate the user touched in DragLayer coordinates * @param touchY the y coordinate the user touched in DragLayer coordinates */ @@ -323,8 +328,7 @@ public class DragView extends View { lp.height = mBitmap.getHeight(); lp.customPosition = true; setLayoutParams(lp); - setTranslationX(touchX - mRegistrationX); - setTranslationY(touchY - mRegistrationY); + move(touchX, touchY); // Post the animation to skip other expensive work happening on the first frame post(new Runnable() { public void run() { @@ -347,8 +351,32 @@ public class DragView extends View { * @param touchY the y coordinate the user touched in DragLayer coordinates */ public void move(int touchX, int touchY) { - setTranslationX(touchX - mRegistrationX); - setTranslationY(touchY - mRegistrationY); + mLastTouchX = touchX; + mLastTouchY = touchY; + applyTranslation(); + } + + public void animateShift(final int shiftX, final int shiftY) { + if (mAnim.isStarted()) { + return; + } + mAnimatedShiftX = shiftX; + mAnimatedShiftY = shiftY; + applyTranslation(); + mAnim.addUpdateListener(new AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + float fraction = 1 - animation.getAnimatedFraction(); + mAnimatedShiftX = (int) (fraction * shiftX); + mAnimatedShiftY = (int) (fraction * shiftY); + applyTranslation(); + } + }); + } + + private void applyTranslation() { + setTranslationX(mLastTouchX - mRegistrationX + mAnimatedShiftX); + setTranslationY(mLastTouchY - mRegistrationY + mAnimatedShiftY); } public void remove() { |