summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/com/android/launcher2/AllAppsPagedView.java32
-rw-r--r--src/com/android/launcher2/CustomizePagedView.java40
-rw-r--r--src/com/android/launcher2/PagedViewIcon.java29
-rw-r--r--src/com/android/launcher2/Workspace.java3
4 files changed, 64 insertions, 40 deletions
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index 2fd0b6569..1ad7e078a 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
@@ -246,16 +247,6 @@ public class AllAppsPagedView extends PagedView
return false;
}
- if (v instanceof Checkable) {
- // In preparation for drag, we always reset the checked grand children regardless of
- // what choice mode we are in
- resetCheckedGrandchildren();
-
- // Toggle the selection on the dragged app
- Checkable c = (Checkable) v;
- c.toggle();
- }
-
// Start drag mode after the item is selected
setupDragMode();
@@ -263,13 +254,30 @@ public class AllAppsPagedView extends PagedView
app = new ApplicationInfo(app);
// get icon (top compound drawable, index is 1)
- final Drawable icon = ((TextView) v).getCompoundDrawables()[1];
- Bitmap b = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(),
+ final TextView tv = (TextView) v;
+ final Drawable icon = tv.getCompoundDrawables()[1];
+ Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
+ c.translate((v.getWidth() - icon.getIntrinsicWidth()) / 2, v.getPaddingTop());
icon.draw(c);
+
+ // We toggle the checked state _after_ we create the view for the drag in case toggling the
+ // checked state changes the view's look
+ if (v instanceof Checkable) {
+ // In preparation for drag, we always reset the checked grand children regardless of
+ // what choice mode we are in
+ resetCheckedGrandchildren();
+
+ // Toggle the selection on the dragged app
+ Checkable checkable = (Checkable) v;
+ checkable.toggle();
+ }
+
+ // Start the drag
mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b);
mDragController.startDrag(v, b, this, app, DragController.DRAG_ACTION_COPY, null);
+ b.recycle();
return true;
}
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;
}
}
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index fbc67d8a0..884884e31 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -16,6 +16,7 @@
package com.android.launcher2;
+import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
@@ -28,7 +29,6 @@ import android.os.HandlerThread;
import android.os.Message;
import android.util.AttributeSet;
import android.widget.Checkable;
-import android.widget.TextView;
import com.android.launcher.R;
import com.android.launcher2.PagedView.PagedViewIconCache;
@@ -56,6 +56,10 @@ public class PagedViewIcon extends CacheableTextView implements Checkable {
private int mHolographicAlpha;
private boolean mIsChecked;
+ private ObjectAnimator mCheckedAlphaAnimator;
+ private final static float sCheckedAlpha = 0.4f;
+ private final static int sCheckedFadeInDuration = 150;
+ private final static int sCheckedFadeOutDuration = 200;
// Highlight colors
private int mHoloBlurColor;
@@ -230,19 +234,24 @@ public class PagedViewIcon extends CacheableTextView implements Checkable {
if (mIsChecked != checked) {
mIsChecked = checked;
+ float alpha;
+ int duration;
if (mIsChecked) {
- mCheckedOutline = Bitmap.createBitmap(mIcon.getWidth(), mIcon.getHeight(),
- Bitmap.Config.ARGB_8888);
- Canvas checkedOutlineCanvas = new Canvas(mCheckedOutline);
- mPaint.setAlpha(255);
- checkedOutlineCanvas.drawBitmap(mIcon, 0, 0, mPaint);
-
- sHolographicOutlineHelper.applyThickExpensiveOutlineWithBlur(mCheckedOutline,
- checkedOutlineCanvas, mCheckedBlurColor, mCheckedOutlineColor);
+ alpha = sCheckedAlpha;
+ duration = sCheckedFadeInDuration;
} else {
- invalidateCheckedImage();
+ alpha = 1.0f;
+ duration = sCheckedFadeOutDuration;
}
+ // Initialize the animator
+ if (mCheckedAlphaAnimator != null) {
+ mCheckedAlphaAnimator.cancel();
+ }
+ mCheckedAlphaAnimator = ObjectAnimator.ofFloat(this, "alpha", alpha);
+ mCheckedAlphaAnimator.setDuration(duration);
+ mCheckedAlphaAnimator.start();
+
invalidate();
}
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 969fbd7cc..705453d3a 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -21,12 +21,12 @@ import java.util.HashSet;
import java.util.List;
import android.animation.Animator;
+import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
-import android.animation.Animator.AnimatorListener;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.app.AlertDialog;
import android.app.WallpaperManager;
@@ -44,6 +44,7 @@ import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Camera;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;