Refactoring FlingToDelete
> Moving all fling related logic to FlingToDeleteHelper from DragController
> Removing fling related methods from DragSource and DropTarget
> Moving fling animation logic from DeleteDropTarget to FlingAnimation
> Simplifying DropTargetBar to directly look for all valid drop targets.
This makes it easier to add new DropTarget in xml.
Change-Id: I7214d2d30c907ab93c80d92d9f9be6dda2d63354
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index 60a2cc3..e613b3b 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -28,7 +28,6 @@
import android.content.res.TypedArray;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
-import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
@@ -119,9 +118,6 @@
}
@Override
- public void onFlingToDelete(DragObject d, PointF vec) { }
-
- @Override
public final void onDragEnter(DragObject d) {
d.dragView.setColor(mHoverColor);
if (Utilities.ATLEAST_LOLLIPOP) {
@@ -243,10 +239,7 @@
final Rect from = new Rect();
dragLayer.getViewRectRelativeToSelf(d.dragView, from);
- int width = mDrawable.getIntrinsicWidth();
- int height = mDrawable.getIntrinsicHeight();
- final Rect to = getIconRect(d.dragView.getMeasuredWidth(), d.dragView.getMeasuredHeight(),
- width, height);
+ final Rect to = getIconRect(d);
final float scale = (float) to.width() / from.width();
mDropTargetBar.deferOnDragEnd();
@@ -268,7 +261,7 @@
@Override
public void prepareAccessibilityDrop() { }
- @Thunk abstract void completeDrop(DragObject d);
+ public abstract void completeDrop(DragObject d);
@Override
public void getHitRectRelativeToDragLayer(android.graphics.Rect outRect) {
@@ -280,7 +273,11 @@
outRect.offsetTo(coords[0], coords[1]);
}
- protected Rect getIconRect(int viewWidth, int viewHeight, int drawableWidth, int drawableHeight) {
+ public Rect getIconRect(DragObject dragObject) {
+ int viewWidth = dragObject.dragView.getMeasuredWidth();
+ int viewHeight = dragObject.dragView.getMeasuredHeight();
+ int drawableWidth = mDrawable.getIntrinsicWidth();
+ int drawableHeight = mDrawable.getIntrinsicHeight();
DragLayer dragLayer = mLauncher.getDragLayer();
// Find the rect to animate to (the view is center aligned)