summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/PagedViewIcon.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2010-08-20 14:49:25 -0700
committerWinson Chung <winsonc@google.com>2010-09-02 11:35:48 -0700
commit5f2aa4efeeb8b0133d891715d71553138d9f9ca7 (patch)
tree9d34aadf9e1b94db2edbb2e09aa96a9d1f02c840 /src/com/android/launcher2/PagedViewIcon.java
parent12815f5ac09055ba6a3cd04a14f3bc9d2e537a25 (diff)
downloadandroid_packages_apps_Trebuchet-5f2aa4efeeb8b0133d891715d71553138d9f9ca7.tar.gz
android_packages_apps_Trebuchet-5f2aa4efeeb8b0133d891715d71553138d9f9ca7.tar.bz2
android_packages_apps_Trebuchet-5f2aa4efeeb8b0133d891715d71553138d9f9ca7.zip
Adding single/multi selection mode to AllAppsPagedView (action bar disabled).
Also adding check to prevent scrolling mode from continuing on touch down. Change-Id: I744f2c1f6bc659219145b52b15a7ea176853ec7c
Diffstat (limited to 'src/com/android/launcher2/PagedViewIcon.java')
-rw-r--r--src/com/android/launcher2/PagedViewIcon.java68
1 files changed, 56 insertions, 12 deletions
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index e227569d7..b8cc206bf 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -40,17 +40,19 @@ import android.widget.TextView;
import com.android.launcher2.PagedView.PagedViewIconCache;
class HolographicOutlineHelper {
+ private float mDensity;
private final Paint mHolographicPaint = new Paint();
private final Paint mBlurPaint = new Paint();
private final Paint mErasePaint = new Paint();
- private static final Matrix mIdentity = new Matrix();
- private static final float STROKE_WIDTH = 6.0f;
+ private static final Matrix mIdentity = new Matrix();;
private static final float BLUR_FACTOR = 3.5f;
+ public static final float DEFAULT_STROKE_WIDTH = 6.0f;
public static final int HOLOGRAPHIC_BLUE = 0xFF6699FF;
- public static final int HOLOGRAPHIC_GREEN = 0xFF66FF66;
+ public static final int HOLOGRAPHIC_GREEN = 0xFF51E633;
HolographicOutlineHelper(float density) {
+ mDensity = density;
mHolographicPaint.setColor(HOLOGRAPHIC_BLUE);
mHolographicPaint.setFilterBitmap(true);
mHolographicPaint.setAntiAlias(true);
@@ -101,13 +103,14 @@ class HolographicOutlineHelper {
/**
* Applies an outline to whatever is currently drawn in the specified bitmap.
*/
- void applyOutline(Bitmap srcDst, Canvas srcDstCanvas, PointF offset) {
+ void applyOutline(Bitmap srcDst, Canvas srcDstCanvas, float strokeWidth, PointF offset) {
+ strokeWidth *= mDensity;
Bitmap mask = srcDst.extractAlpha();
Matrix m = new Matrix();
final int width = srcDst.getWidth();
final int height = srcDst.getHeight();
- float xScale = STROKE_WIDTH*2.0f/width;
- float yScale = STROKE_WIDTH*2.0f/height;
+ float xScale = strokeWidth*2.0f/width;
+ float yScale = strokeWidth*2.0f/height;
m.preScale(1+xScale, 1+yScale, (width / 2.0f) + offset.x,
(height / 2.0f) + offset.y);
@@ -138,6 +141,7 @@ public class PagedViewIcon extends TextView implements Checkable {
// holographic outline
private final Paint mPaint = new Paint();
private static HolographicOutlineHelper sHolographicOutlineHelper;
+ private Bitmap mCheckedOutline;
private Bitmap mHolographicOutline;
private Canvas mHolographicOutlineCanvas;
private boolean mIsHolographicUpdatePass;
@@ -207,6 +211,13 @@ public class PagedViewIcon extends TextView implements Checkable {
super.setAlpha(viewAlpha);
}
+ public void invalidateCheckedImage() {
+ if (mCheckedOutline != null) {
+ mCheckedOutline.recycle();
+ mCheckedOutline = null;
+ }
+ }
+
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
@@ -229,10 +240,11 @@ public class PagedViewIcon extends TextView implements Checkable {
draw(mHolographicOutlineCanvas);
sHolographicOutlineHelper.setColor(HolographicOutlineHelper.HOLOGRAPHIC_BLUE);
sHolographicOutlineHelper.applyOutline(mHolographicOutline, mHolographicOutlineCanvas,
- offset);
+ HolographicOutlineHelper.DEFAULT_STROKE_WIDTH, offset);
sHolographicOutlineHelper.applyBlur(mHolographicOutline, mHolographicOutlineCanvas);
mIsHolographicUpdatePass = false;
mIconCache.addOutline(mIconCacheKey, mHolographicOutline);
+ mHolographicOutlineCanvas = null;
}
}
@@ -254,9 +266,17 @@ public class PagedViewIcon extends TextView implements Checkable {
}
}
- if (!mIsHolographicUpdatePass && mHolographicOutline != null && mHolographicAlpha > 0) {
- mPaint.setAlpha(mHolographicAlpha);
- canvas.drawBitmap(mHolographicOutline, 0, 0, mPaint);
+ // draw any blended overlays
+ if (!mIsHolographicUpdatePass) {
+ if (mCheckedOutline == null) {
+ if (mHolographicOutline != null && mHolographicAlpha > 0) {
+ mPaint.setAlpha(mHolographicAlpha);
+ canvas.drawBitmap(mHolographicOutline, 0, 0, mPaint);
+ }
+ } else {
+ mPaint.setAlpha(255);
+ canvas.drawBitmap(mCheckedOutline, 0, 0, mPaint);
+ }
}
}
@@ -267,8 +287,32 @@ public class PagedViewIcon extends TextView implements Checkable {
@Override
public void setChecked(boolean checked) {
- mIsChecked = checked;
- invalidate();
+ if (mIsChecked != checked) {
+ mIsChecked = checked;
+
+ if (mIsChecked) {
+ final PointF offset = new PointF(0,
+ -(getCompoundPaddingBottom() + getCompoundPaddingTop())/2.0f);
+
+ // set a flag to indicate that we are going to draw the view at full alpha with the text
+ // clipped for the generation of the holographic icon
+ mIsHolographicUpdatePass = true;
+ mCheckedOutline = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(),
+ Bitmap.Config.ARGB_8888);
+ mHolographicOutlineCanvas = new Canvas(mCheckedOutline);
+ mHolographicOutlineCanvas.concat(getMatrix());
+ draw(mHolographicOutlineCanvas);
+ sHolographicOutlineHelper.setColor(HolographicOutlineHelper.HOLOGRAPHIC_GREEN);
+ sHolographicOutlineHelper.applyOutline(mCheckedOutline, mHolographicOutlineCanvas,
+ HolographicOutlineHelper.DEFAULT_STROKE_WIDTH + 1.0f, offset);
+ mIsHolographicUpdatePass = false;
+ mHolographicOutlineCanvas = null;
+ } else {
+ invalidateCheckedImage();
+ }
+
+ invalidate();
+ }
}
@Override