Adding drag outlines for dragging out of folders

Change-Id: I264f66af5f03035bac17ff00eacc1a1da3d027a4
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 636b041..2b3bb9a 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -16,7 +16,7 @@
 
 package com.android.launcher2;
 
-import com.android.launcher.R;
+import java.util.Arrays;
 
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
@@ -39,7 +39,6 @@
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
 import android.util.Log;
-import android.view.ContextMenu;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewDebug;
@@ -48,7 +47,7 @@
 import android.view.animation.DecelerateInterpolator;
 import android.view.animation.LayoutAnimationController;
 
-import java.util.Arrays;
+import com.android.launcher.R;
 
 public class CellLayout extends ViewGroup {
     static final String TAG = "CellLayout";
@@ -983,6 +982,10 @@
                 // outside the bounds of the view.
                 left += (v.getWidth() - dragOutline.getWidth()) / 2;
                 top += (v.getHeight() - dragOutline.getHeight()) / 2;
+            } else {
+                // Center the drag outline in the cell
+                left += (mCellWidth - dragOutline.getWidth()) / 2;
+                top += (mCellHeight - dragOutline.getHeight()) / 2;
             }
 
             final int oldIndex = mDragOutlineCurrent;
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index 33a1cd3..e00023f 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -21,9 +21,7 @@
 import android.util.AttributeSet;
 import android.view.View;
 import android.view.View.OnClickListener;
-import android.widget.AbsListView;
 import android.widget.AdapterView;
-import android.widget.BaseAdapter;
 import android.widget.Button;
 import android.widget.LinearLayout;
 import android.widget.AdapterView.OnItemClickListener;
diff --git a/src/com/android/launcher2/UserFolder.java b/src/com/android/launcher2/UserFolder.java
index b800b07..24b9ae2 100644
--- a/src/com/android/launcher2/UserFolder.java
+++ b/src/com/android/launcher2/UserFolder.java
@@ -1,18 +1,15 @@
 package com.android.launcher2;
 
+import java.util.ArrayList;
+
 import android.content.Context;
 import android.graphics.Rect;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.View;
-import android.widget.AdapterView;
-import android.widget.BaseAdapter;
-import android.widget.Button;
-import android.widget.GridView;
 import android.widget.TextView;
 
 import com.android.launcher.R;
-import java.util.ArrayList;
 
 /**
  * Folder which contains applications or shortcuts chosen by the user.
@@ -81,7 +78,9 @@
                 return false;
             }
 
+            mLauncher.getWorkspace().onDragStartedWithItem(v);
             mDragController.startDrag(v, this, item, DragController.DRAG_ACTION_COPY);
+
             mLauncher.closeFolder(this);
             mDragItem = item;
 
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 98cf62b..ce8fa40 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -16,8 +16,9 @@
 
 package com.android.launcher2;
 
-import com.android.launcher.R;
-import com.android.launcher2.InstallWidgetReceiver.WidgetMimeTypeHandlerData;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
 
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
@@ -66,9 +67,8 @@
 import android.widget.TextView;
 import android.widget.Toast;
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
+import com.android.launcher.R;
+import com.android.launcher2.InstallWidgetReceiver.WidgetMimeTypeHandlerData;
 
 /**
  * The workspace is a wide area with a wallpaper and a finite number of pages.
@@ -1730,14 +1730,26 @@
     }
 
     /*
-     *
-     * We call these methods (onDragStartedWithItemSpans/onDragStartedWithItemMinSize) whenever we
-     * start a drag in Launcher, regardless of whether the drag has ever entered the Workspace
-     *
-     * These methods mark the appropriate pages as accepting drops (which alters their visual
-     * appearance).
-     *
-     */
+    *
+    * We call these methods (onDragStartedWithItemSpans/onDragStartedWithSize) whenever we
+    * start a drag in Launcher, regardless of whether the drag has ever entered the Workspace
+    *
+    * These methods mark the appropriate pages as accepting drops (which alters their visual
+    * appearance).
+    *
+    */
+    public void onDragStartedWithItem(View v) {
+        mIsDragInProcess = true;
+
+        final Canvas canvas = new Canvas();
+
+        // We need to add extra padding to the bitmap to make room for the glow effect
+        final int bitmapPadding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS;
+
+        // The outline is used to visualize where the item will land if dropped
+        mDragOutline = createDragOutline(v, canvas, bitmapPadding);
+    }
+
     public void onDragStartedWithItemSpans(int spanX, int spanY, Bitmap b) {
         mIsDragInProcess = true;
 
@@ -1747,9 +1759,11 @@
         final int bitmapPadding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS;
 
         CellLayout cl = (CellLayout) getChildAt(0);
-        int[] desiredSize = cl.cellSpansToSize(spanX, spanY);
+
+        int[] size = cl.cellSpansToSize(spanX, spanY);
+
         // The outline is used to visualize where the item will land if dropped
-        mDragOutline = createDragOutline(b, canvas, bitmapPadding, desiredSize[0], desiredSize[1]);
+        mDragOutline = createDragOutline(b, canvas, bitmapPadding, size[0], size[1]);
 
         updateWhichPagesAcceptDropsDuringDrag(mShrinkState, spanX, spanY);
     }