summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMathew Inwood <mathewi@google.com>2014-04-16 14:17:39 +0100
committerMathew Inwood <mathewi@google.com>2014-04-16 14:17:39 +0100
commit859002985e0e5d73f54c942f2024607431db60fc (patch)
treedb3c1972f66828de1da82b2b8b18d038c1465074 /src
parent1a1fdf4185637610b37953e901605c55ef8ba0a6 (diff)
downloadandroid_packages_apps_Trebuchet-859002985e0e5d73f54c942f2024607431db60fc.tar.gz
android_packages_apps_Trebuchet-859002985e0e5d73f54c942f2024607431db60fc.tar.bz2
android_packages_apps_Trebuchet-859002985e0e5d73f54c942f2024607431db60fc.zip
Take account of bounds set on drag drawables.
If bounds are set on a compound drawable in a textview, drawing it into a bitmap set to the intrinsic size of the drawable results in it being scaled down in the top corner. Scaling it down again into the grid icon size then gives a tiny icon. Use the drawable bounds if any are set, otherwise use the intrinsic size. Bug: 14103508 Change-Id: Idadd7bb891dc33d092eb9ceb3025b9a5d9e1bfd8
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Workspace.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index c984ad65d..9800cf376 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1992,6 +1992,15 @@ public class Workspace extends SmoothPagedView
mDragOutline = createDragOutline(v, canvas, DRAG_BITMAP_PADDING);
}
+ private Rect getDrawableBounds(Drawable d) {
+ Rect bounds = new Rect();
+ d.copyBounds(bounds);
+ if (bounds.width() == 0 || bounds.height() == 0) {
+ bounds.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
+ }
+ return bounds;
+ }
+
public void onExternalDragStartedWithItem(View v) {
final Canvas canvas = new Canvas();
@@ -2006,8 +2015,9 @@ public class Workspace extends SmoothPagedView
if (v instanceof TextView) {
TextView tv = (TextView) v;
Drawable d = tv.getCompoundDrawables()[1];
- bmpWidth = d.getIntrinsicWidth();
- bmpHeight = d.getIntrinsicHeight();
+ Rect bounds = getDrawableBounds(d);
+ bmpWidth = bounds.width();
+ bmpHeight = bounds.height();
}
// Compose the bitmap to create the icon from
@@ -2527,7 +2537,8 @@ public class Workspace extends SmoothPagedView
destCanvas.save();
if (v instanceof TextView && pruneToDrawable) {
Drawable d = ((TextView) v).getCompoundDrawables()[1];
- clipRect.set(0, 0, d.getIntrinsicWidth() + padding, d.getIntrinsicHeight() + padding);
+ Rect bounds = getDrawableBounds(d);
+ clipRect.set(0, 0, bounds.width() + padding, bounds.height() + padding);
destCanvas.translate(padding / 2, padding / 2);
d.draw(destCanvas);
} else {
@@ -2568,8 +2579,9 @@ public class Workspace extends SmoothPagedView
if (v instanceof TextView) {
Drawable d = ((TextView) v).getCompoundDrawables()[1];
- b = Bitmap.createBitmap(d.getIntrinsicWidth() + padding,
- d.getIntrinsicHeight() + padding, Bitmap.Config.ARGB_8888);
+ Rect bounds = getDrawableBounds(d);
+ b = Bitmap.createBitmap(bounds.width() + padding,
+ bounds.height() + padding, Bitmap.Config.ARGB_8888);
} else {
b = Bitmap.createBitmap(
v.getWidth() + padding, v.getHeight() + padding, Bitmap.Config.ARGB_8888);