summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/CustomizePagedView.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2010-12-09 18:52:32 -0800
committerWinson Chung <winsonc@google.com>2010-12-09 19:02:07 -0800
commitcd4bc491c40c8a01a62d6846577da124e5e00718 (patch)
tree5e7ace59cfabe9c3085418bc05b8f3f65d7ed1a0 /src/com/android/launcher2/CustomizePagedView.java
parentbf54662596481406fbc70855847d26b6557cc677 (diff)
downloadandroid_packages_apps_Trebuchet-cd4bc491c40c8a01a62d6846577da124e5e00718.tar.gz
android_packages_apps_Trebuchet-cd4bc491c40c8a01a62d6846577da124e5e00718.tar.bz2
android_packages_apps_Trebuchet-cd4bc491c40c8a01a62d6846577da124e5e00718.zip
Changing AllApps checked visualization, fixing drag offset issue in AllApps/Customize.
- fixing previous change which clobbered pressed/focused state padding Change-Id: I229d803322554e51bc9c1f15d3687b01b0f6679f
Diffstat (limited to 'src/com/android/launcher2/CustomizePagedView.java')
-rw-r--r--src/com/android/launcher2/CustomizePagedView.java40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index 799e01793..694d4d015 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -24,10 +24,10 @@ import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import android.animation.Animator;
+import android.animation.Animator.AnimatorListener;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.TimeInterpolator;
-import android.animation.Animator.AnimatorListener;
import android.app.WallpaperManager;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
@@ -41,8 +41,9 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.Bitmap;
-import android.graphics.Canvas;
import android.graphics.Bitmap.Config;
+import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
@@ -571,10 +572,10 @@ public class CustomizePagedView extends PagedView
return super.onTouchEvent(ev);
}
- Bitmap drawableToBitmap(Drawable d) {
- Bitmap b = Bitmap.createBitmap(d.getIntrinsicWidth(), d.getIntrinsicHeight(),
- Bitmap.Config.ARGB_8888);
+ Bitmap drawableToBitmap(Drawable d, View v) {
+ Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
+ c.translate((v.getWidth() - d.getIntrinsicWidth()) / 2, v.getPaddingTop());
d.draw(c);
return b;
}
@@ -595,10 +596,10 @@ public class CustomizePagedView extends PagedView
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);
+ final ImageView i = (ImageView) l.findViewById(R.id.widget_preview);
+ final Drawable icon = i.getDrawable();
+ Bitmap b = drawableToBitmap(icon, i);
PendingAddWidgetInfo createWidgetInfo = (PendingAddWidgetInfo) v.getTag();
- final View dragView = v.findViewById(R.id.widget_preview);
int[] spanXY = CellLayout.rectToCell(
getResources(), createWidgetInfo.minWidth, createWidgetInfo.minHeight, null);
@@ -606,30 +607,35 @@ public class CustomizePagedView extends PagedView
createWidgetInfo.spanY = spanXY[1];
mLauncher.getWorkspace().onDragStartedWithItemSpans(spanXY[0], spanXY[1], b);
mDragController.startDrag(
- v, b, this, createWidgetInfo, DragController.DRAG_ACTION_COPY, null);
-
+ i, b, this, createWidgetInfo, DragController.DRAG_ACTION_COPY, null);
+ b.recycle();
return true;
}
case ShortcutCustomization: {
// get icon (top compound drawable, index is 1)
- final Drawable icon = ((TextView) v).getCompoundDrawables()[1];
- Bitmap b = drawableToBitmap(icon);
+ final TextView tv = (TextView) v;
+ final Drawable icon = tv.getCompoundDrawables()[1];
+ Bitmap b = drawableToBitmap(icon, tv);
PendingAddItemInfo createItemInfo = (PendingAddItemInfo) v.getTag();
- mDragController.startDrag(
- v, b, this, createItemInfo, DragController.DRAG_ACTION_COPY, null);
+
mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b);
+ mDragController.startDrag(v, b, this, createItemInfo, DragController.DRAG_ACTION_COPY,
+ null);
+ b.recycle();
return true;
}
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);
+ final TextView tv = (TextView) v;
+ final Drawable icon = tv.getCompoundDrawables()[1];
+ Bitmap b = drawableToBitmap(icon, tv);
ApplicationInfo app = (ApplicationInfo) v.getTag();
app = new ApplicationInfo(app);
- mDragController.startDrag(v, b, this, app, DragController.DRAG_ACTION_COPY, null);
mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b);
+ mDragController.startDrag(v, b, this, app, DragController.DRAG_ACTION_COPY, null);
+ b.recycle();
return true;
}
}