added support for dragging widgets and app icons to mini screens
- gave mini screens a rounded rect background
- mini screens change color when dragged over
- added a way to specify the active region of dragged items, to allow for clipping of whitespace at borders
- fixed: feedback while dragging was often one cell off
- fixed: bug when adding to almost-full screen
- removed unused classes
Change-Id: I2fbd2aaaee6831b288cca8dec75e7b446068e8d1
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index 4a955b2..ef619be 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -166,12 +166,26 @@
final View animView = v;
switch (mCustomizationType) {
case WidgetCustomization:
+ // We assume that the view v is a TextView with a compound drawable on top, and that the
+ // whole text view is centered horizontally and top aligned. We get a more precise
+ // drag point using this information
+ final TextView textView = (TextView) animView;
+ final Drawable[] drawables = textView.getCompoundDrawables();
+ final Drawable icon = drawables[1];
+ int dragPointOffsetX = 0;
+ int dragPointOffsetY = 0;
+ Rect bounds = null;
+ if (icon != null) {
+ bounds = icon.getBounds();
+ bounds.left = (v.getWidth() - bounds.right) / 2;
+ bounds.right += bounds.left;
+ }
+
AppWidgetProviderInfo appWidgetInfo = (AppWidgetProviderInfo) v.getTag();
LauncherAppWidgetInfo dragInfo = new LauncherAppWidgetInfo(appWidgetInfo.provider);
dragInfo.minWidth = appWidgetInfo.minWidth;
dragInfo.minHeight = appWidgetInfo.minHeight;
- mDragController.startDrag(v, this, dragInfo, DragController.DRAG_ACTION_COPY);
- mLauncher.hideCustomizationDrawer();
+ mDragController.startDrag(v, this, dragInfo, DragController.DRAG_ACTION_COPY, bounds);
return true;
case FolderCustomization:
// animate some feedback to the long press