Adding fade when dragging items outside of the customization tray.
Change-Id: Ie8dad00bc0278053707f81d948528929e6bb6f5c
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index 60f1c90..ec9d52e 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -54,6 +54,7 @@
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
+import android.widget.Checkable;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -327,6 +328,7 @@
@Override
public void onDropCompleted(View target, boolean success) {
+ resetCheckedGrandchildren();
mLauncher.getWorkspace().onDragStopped();
}
@@ -498,6 +500,7 @@
}
super.beginDragging(v);
+ boolean result = false;
switch (mCustomizationType) {
case WidgetCustomization: {
// Get the widget preview as the drag representation
@@ -515,7 +518,8 @@
mDragController.startDrag(
i, b, this, createWidgetInfo, DragController.DRAG_ACTION_COPY, null);
b.recycle();
- return true;
+ result = true;
+ break;
}
case ShortcutCustomization: {
// get icon (top compound drawable, index is 1)
@@ -528,7 +532,8 @@
mDragController.startDrag(v, b, this, createItemInfo, DragController.DRAG_ACTION_COPY,
null);
b.recycle();
- return true;
+ result = true;
+ break;
}
case ApplicationCustomization: {
// Pick up the application for dropping
@@ -542,10 +547,28 @@
mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b);
mDragController.startDrag(v, b, this, app, DragController.DRAG_ACTION_COPY, null);
b.recycle();
- return true;
+ result = true;
+ break;
}
}
- return false;
+
+ // We toggle the checked state _after_ we create the view for the drag in case toggling the
+ // checked state changes the view's look
+ if (v instanceof Checkable) {
+ // In preparation for drag, we always reset the checked grand children regardless of
+ // what choice mode we are in
+ resetCheckedGrandchildren();
+
+ // Toggle the selection on the dragged app
+ Checkable checkable = (Checkable) v;
+
+ // Note: we toggle the checkable state to actually cause an alpha fade for the duration
+ // of the drag of the item. (The fade-in will occur when all checked states are
+ // disabled when dragging ends)
+ checkable.toggle();
+ }
+
+ return result;
}
/**