summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/CustomizePagedView.java
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2010-11-23 16:23:58 -0800
committerMichael Jurka <mikejurka@google.com>2010-12-09 02:12:19 -0800
commitd3ef3065ab0941567c45e9aec98783138b623c68 (patch)
treebe6aeb8f76931cc504a8723824920e60d292b116 /src/com/android/launcher2/CustomizePagedView.java
parent120980bd00f5eecec5717f49a3d7db96571025a9 (diff)
downloadandroid_packages_apps_Trebuchet-d3ef3065ab0941567c45e9aec98783138b623c68.tar.gz
android_packages_apps_Trebuchet-d3ef3065ab0941567c45e9aec98783138b623c68.tar.bz2
android_packages_apps_Trebuchet-d3ef3065ab0941567c45e9aec98783138b623c68.zip
added spring loaded mode for adding items to workspace
Change-Id: Ie92294fe2b1d6697d84756a2fcea91a09f72825b
Diffstat (limited to 'src/com/android/launcher2/CustomizePagedView.java')
-rw-r--r--src/com/android/launcher2/CustomizePagedView.java38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index 62dcf4a0d..342974a4b 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -60,6 +60,7 @@ import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.TextView;
import com.android.launcher.R;
@@ -587,30 +588,47 @@ public class CustomizePagedView extends PagedView
mIsDragging = true;
switch (mCustomizationType) {
- case WidgetCustomization:
+ case WidgetCustomization: {
// Get the widget preview as the drag representation
+ final LinearLayout l = (LinearLayout) v;
+ final Drawable icon = ((ImageView) l.findViewById(R.id.widget_preview)).getDrawable();
+ Bitmap b = drawableToBitmap(icon);
PendingAddWidgetInfo createWidgetInfo = (PendingAddWidgetInfo) v.getTag();
final View dragView = v.findViewById(R.id.widget_preview);
- mLauncher.getWorkspace().onDragStartedWithItemMinSize(
- createWidgetInfo.minWidth, createWidgetInfo.minHeight);
- mDragController.startDrag(dragView, this, createWidgetInfo, DragController.DRAG_ACTION_COPY, null);
+ int[] spanXY = CellLayout.rectToCell(
+ getResources(), createWidgetInfo.minWidth, createWidgetInfo.minHeight, null);
+ createWidgetInfo.spanX = spanXY[0];
+ createWidgetInfo.spanY = spanXY[1];
+ mLauncher.getWorkspace().onDragStartedWithItemSpans(spanXY[0], spanXY[1], b);
+ mDragController.startDrag(
+ v, b, this, createWidgetInfo, DragController.DRAG_ACTION_COPY, null);
return true;
- case ShortcutCustomization:
+ }
+ case ShortcutCustomization: {
+ // get icon (top compound drawable, index is 1)
+ final Drawable icon = ((TextView) v).getCompoundDrawables()[1];
+ Bitmap b = drawableToBitmap(icon);
PendingAddItemInfo createItemInfo = (PendingAddItemInfo) v.getTag();
- mDragController.startDrag(v, this, createItemInfo, DragController.DRAG_ACTION_COPY);
- mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1);
+ mDragController.startDrag(
+ v, b, this, createItemInfo, DragController.DRAG_ACTION_COPY, null);
+ mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b);
return true;
- case ApplicationCustomization:
+ }
+ case ApplicationCustomization: {
// Pick up the application for dropping
+ // get icon (top compound drawable, index is 1)
+ final Drawable icon = ((TextView) v).getCompoundDrawables()[1];
+ Bitmap b = drawableToBitmap(icon);
ApplicationInfo app = (ApplicationInfo) v.getTag();
app = new ApplicationInfo(app);
- mDragController.startDrag(v, this, app, DragController.DRAG_ACTION_COPY);
- mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1);
+ mDragController.startDrag(v, b, this, app, DragController.DRAG_ACTION_COPY, null);
+ mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b);
return true;
}
+ }
return false;
}