diff options
author | Tony Wickham <twickham@google.com> | 2016-11-15 19:53:32 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-11-15 19:53:32 +0000 |
commit | 075b8788427729ab144b79fdc3e3739ecab8ecda (patch) | |
tree | 1e9947a21d4bdafb0e76edaf27fa5c797fe77f35 /src/com/android/launcher3/dragndrop | |
parent | f8d5370a9f74127c20e1ecd371a68918fe1f14ce (diff) | |
parent | ea62fe0be19c54f8fbb434c6334418b96626f70d (diff) | |
download | android_packages_apps_Trebuchet-075b8788427729ab144b79fdc3e3739ecab8ecda.tar.gz android_packages_apps_Trebuchet-075b8788427729ab144b79fdc3e3739ecab8ecda.tar.bz2 android_packages_apps_Trebuchet-075b8788427729ab144b79fdc3e3739ecab8ecda.zip |
Merge "Animate icons back to where they were picked up." into ub-launcher3-master
Diffstat (limited to 'src/com/android/launcher3/dragndrop')
-rw-r--r-- | src/com/android/launcher3/dragndrop/DragController.java | 29 | ||||
-rw-r--r-- | src/com/android/launcher3/dragndrop/DragView.java | 16 |
2 files changed, 31 insertions, 14 deletions
diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index e11bfc682..67ef5fc3c 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -295,10 +295,6 @@ public class DragController implements DragDriver.EventListener, TouchController mIsInPreDrag = false; } - public boolean isInPreDrag() { - return mIsInPreDrag; - } - /** * Call this from a drag source view like this: * @@ -361,6 +357,8 @@ public class DragController implements DragDriver.EventListener, TouchController isDeferred = mDragObject.deferDragViewCleanupPostAnimation; if (!isDeferred) { mDragObject.dragView.remove(); + } else if (mIsInPreDrag) { + animateDragViewToOriginalPosition(null, null, -1); } mDragObject.dragView = null; } @@ -374,6 +372,22 @@ public class DragController implements DragDriver.EventListener, TouchController releaseVelocityTracker(); } + public void animateDragViewToOriginalPosition(final Runnable onComplete, + final View originalIcon, int duration) { + Runnable onCompleteRunnable = new Runnable() { + @Override + public void run() { + if (originalIcon != null) { + originalIcon.setVisibility(View.VISIBLE); + } + if (onComplete != null) { + onComplete.run(); + } + } + }; + mDragObject.dragView.animateTo(mMotionDownX, mMotionDownY, onCompleteRunnable, duration); + } + private void callOnDragEnd() { if (mIsInPreDrag && mOptions.preDragCondition != null) { mOptions.preDragCondition.onPreDragEnd(false /* dragStarted*/); @@ -738,7 +752,7 @@ public class DragController implements DragDriver.EventListener, TouchController if (dropTarget.acceptDrop(mDragObject)) { if (flingVel != null) { dropTarget.onFlingToDelete(mDragObject, flingVel); - } else { + } else if (!mIsInPreDrag) { dropTarget.onDrop(mDragObject); } accepted = true; @@ -749,11 +763,6 @@ public class DragController implements DragDriver.EventListener, TouchController if (!mIsInPreDrag) { mDragObject.dragSource.onDropCompleted( dropTargetAsView, mDragObject, flingVel != null, accepted); - } else { - // Only defer the drag view cleanup if the drag source handles the drop. - if (!(mDragObject.dragSource instanceof DropTarget)) { - mDragObject.deferDragViewCleanupPostAnimation = false; - } } } diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java index 8a2ae94f6..22e077bb1 100644 --- a/src/com/android/launcher3/dragndrop/DragView.java +++ b/src/com/android/launcher3/dragndrop/DragView.java @@ -23,7 +23,6 @@ import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.annotation.SuppressLint; import android.annotation.TargetApi; -import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; @@ -38,12 +37,10 @@ import android.view.animation.DecelerateInterpolator; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAnimUtils; +import com.android.launcher3.R; import com.android.launcher3.Utilities; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.Thunk; -import com.android.launcher3.R; - import java.util.Arrays; public class DragView extends View { @@ -57,6 +54,8 @@ public class DragView extends View { @Thunk Paint mPaint; private final int mRegistrationX; private final int mRegistrationY; + private final float mInitialScale; + private final int[] mTempLoc = new int[2]; private Point mDragVisualizeOffset = null; private Rect mDragRegion = null; @@ -138,6 +137,8 @@ public class DragView extends View { mRegistrationX = registrationX; mRegistrationY = registrationY; + mInitialScale = initialScale; + // Force a measure, because Workspace uses getMeasuredHeight() before the layout pass int ms = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); measure(ms, ms); @@ -356,6 +357,13 @@ public class DragView extends View { applyTranslation(); } + public void animateTo(int toTouchX, int toTouchY, Runnable onCompleteRunnable, int duration) { + mTempLoc[0] = toTouchX - mRegistrationX; + mTempLoc[1] = toTouchY - mRegistrationY; + mDragLayer.animateViewIntoPosition(this, mTempLoc, 1f, mInitialScale, mInitialScale, + DragLayer.ANIMATION_END_DISAPPEAR, onCompleteRunnable, duration); + } + public void animateShift(final int shiftX, final int shiftY) { if (mAnim.isStarted()) { return; |