summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2011-04-15 17:50:36 -0700
committerAdam Cohen <adamcohen@google.com>2011-04-18 14:27:04 -0700
commit6639687cd67bab1aeef2a75e5c6bc458b20dc082 (patch)
tree41cfb3b108ab10e6f79f61f7954849041c12bdab /src
parent10b1737910ea7890ca95bbbe5363fd5aa513b856 (diff)
downloadandroid_packages_apps_Trebuchet-6639687cd67bab1aeef2a75e5c6bc458b20dc082.tar.gz
android_packages_apps_Trebuchet-6639687cd67bab1aeef2a75e5c6bc458b20dc082.tar.bz2
android_packages_apps_Trebuchet-6639687cd67bab1aeef2a75e5c6bc458b20dc082.zip
Adding drag outlines for dragging out of folders
Change-Id: I264f66af5f03035bac17ff00eacc1a1da3d027a4
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/CellLayout.java9
-rw-r--r--src/com/android/launcher2/Folder.java2
-rw-r--r--src/com/android/launcher2/UserFolder.java9
-rw-r--r--src/com/android/launcher2/Workspace.java44
4 files changed, 39 insertions, 25 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 636b0417c..2b3bb9a63 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.Region;
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.Animation;
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 @@ public class CellLayout extends ViewGroup {
// 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 33a1cd35b..e00023fc2 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -21,9 +21,7 @@ import android.graphics.Rect;
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 b800b076f..24b9ae241 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 @@ public class UserFolder extends Folder implements DropTarget {
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 98cf62bbe..ce8fa40f5 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.TabWidget;
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 @@ public class Workspace extends SmoothPagedView
}
/*
- *
- * 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 @@ public class Workspace extends SmoothPagedView
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);
}