summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/CustomizePagedView.java
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2011-02-10 13:32:01 -0800
committerMichael Jurka <mikejurka@google.com>2011-02-16 10:50:35 -0800
commitc4e772e4b3f21bde342e475ebc49b5b76b8f74e8 (patch)
tree715641720d17f5fdcb03377bbbb19d606a9a285e /src/com/android/launcher2/CustomizePagedView.java
parentaefd4e1f519838852d9e870031a85c9ea55a05f3 (diff)
downloadandroid_packages_apps_Trebuchet-c4e772e4b3f21bde342e475ebc49b5b76b8f74e8.tar.gz
android_packages_apps_Trebuchet-c4e772e4b3f21bde342e475ebc49b5b76b8f74e8.tar.bz2
android_packages_apps_Trebuchet-c4e772e4b3f21bde342e475ebc49b5b76b8f74e8.zip
Fix drag and drop behavior
- Place items close to where they are dropped when workspaces are small - Properly fix positioning of items in spring-loaded mode - Remove blank padding below icons when dragging
Diffstat (limited to 'src/com/android/launcher2/CustomizePagedView.java')
-rw-r--r--src/com/android/launcher2/CustomizePagedView.java17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index d08bf5459..93e1394af 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -479,12 +479,11 @@ public class CustomizePagedView extends PagedViewWithDraggableItems
}
}
- Bitmap drawableToBitmap(Drawable d, View v, boolean clipHeight) {
- int height = clipHeight ? v.getPaddingTop() + d.getIntrinsicHeight() : v.getHeight();
- Bitmap b = Bitmap.createBitmap(v.getWidth(), height, Bitmap.Config.ARGB_8888);
- Canvas c = new Canvas(b);
- c.translate((v.getWidth() - d.getIntrinsicWidth()) / 2, v.getPaddingTop());
- d.draw(c);
+ Bitmap drawableToBitmap(Drawable d) {
+ int w = d.getIntrinsicWidth();
+ int h = d.getIntrinsicHeight();
+ Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
+ renderDrawableToBitmap(d, b, 0, 0, w, h);
return b;
}
@@ -509,7 +508,7 @@ public class CustomizePagedView extends PagedViewWithDraggableItems
// Get the widget preview as the drag representation
final LinearLayout l = (LinearLayout) v;
final ImageView i = (ImageView) l.findViewById(R.id.widget_preview);
- Bitmap b = drawableToBitmap(i.getDrawable(), i, true);
+ Bitmap b = drawableToBitmap(i.getDrawable());
PendingAddWidgetInfo createWidgetInfo = (PendingAddWidgetInfo) v.getTag();
int[] spanXY = CellLayout.rectToCell(
@@ -529,7 +528,7 @@ public class CustomizePagedView extends PagedViewWithDraggableItems
// get icon (top compound drawable, index is 1)
final TextView tv = (TextView) v;
final Drawable icon = tv.getCompoundDrawables()[1];
- Bitmap b = drawableToBitmap(icon, tv, false);
+ Bitmap b = drawableToBitmap(icon);
PendingAddItemInfo createItemInfo = (PendingAddItemInfo) v.getTag();
mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b);
@@ -546,7 +545,7 @@ public class CustomizePagedView extends PagedViewWithDraggableItems
// get icon (top compound drawable, index is 1)
final TextView tv = (TextView) v;
final Drawable icon = tv.getCompoundDrawables()[1];
- Bitmap b = drawableToBitmap(icon, tv, false);
+ Bitmap b = drawableToBitmap(icon);
ApplicationInfo app = (ApplicationInfo) v.getTag();
app = new ApplicationInfo(app);