diff options
author | Adam Cohen <adamcohen@google.com> | 2011-04-18 14:36:25 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-04-18 14:36:25 -0700 |
commit | 0bfd88c56b2fcd13620661a173137678a19d6ae3 (patch) | |
tree | 657c6ed0d05a2edd69acb302040eb1f6b8ab93e3 | |
parent | 8aa9e5251bdee5e83ea3791d2df2b06ff48f8c17 (diff) | |
parent | 6639687cd67bab1aeef2a75e5c6bc458b20dc082 (diff) | |
download | android_packages_apps_Trebuchet-0bfd88c56b2fcd13620661a173137678a19d6ae3.tar.gz android_packages_apps_Trebuchet-0bfd88c56b2fcd13620661a173137678a19d6ae3.tar.bz2 android_packages_apps_Trebuchet-0bfd88c56b2fcd13620661a173137678a19d6ae3.zip |
Merge "Adding drag outlines for dragging out of folders"
-rw-r--r-- | src/com/android/launcher2/CellLayout.java | 9 | ||||
-rw-r--r-- | src/com/android/launcher2/Folder.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher2/UserFolder.java | 9 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 44 |
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); } |