diff options
author | Winson Chung <winsonc@google.com> | 2010-08-19 17:16:59 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2010-08-19 17:28:24 -0700 |
commit | 03c568e608573d5199c03936ed3ad9937cb96732 (patch) | |
tree | 69e07ec45600d3a0b0f70314a6cf00907ed445c4 /src/com/android | |
parent | b3347bb9f4ccf41fb7043bca66c3a565bde1083b (diff) | |
download | packages_apps_trebuchet-03c568e608573d5199c03936ed3ad9937cb96732.zip packages_apps_trebuchet-03c568e608573d5199c03936ed3ad9937cb96732.tar.gz packages_apps_trebuchet-03c568e608573d5199c03936ed3ad9937cb96732.tar.bz2 |
Fixing issue where recycled views' holographic overlays were not being regenerated.
Change-Id: I879eaf2379490ce99d20cb6c0887b7881e580021
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher2/PagedViewIcon.java | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java index e2c22c3..ea5e6d7 100644 --- a/src/com/android/launcher2/PagedViewIcon.java +++ b/src/com/android/launcher2/PagedViewIcon.java @@ -29,9 +29,10 @@ import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.Region.Op; +import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.DisplayMetrics; -import android.view.View; +import android.widget.Checkable; import android.widget.TextView; class HolographicOutlineHelper { @@ -42,8 +43,11 @@ class HolographicOutlineHelper { private static final float STROKE_WIDTH = 6.0f; private static final float BLUR_FACTOR = 3.5f; + public static final int HOLOGRAPHIC_BLUE = 0xFF6699FF; + public static final int HOLOGRAPHIC_GREEN = 0xFF66FF66; + HolographicOutlineHelper(float density) { - mHolographicPaint.setColor(0xFF6699ff); + mHolographicPaint.setColor(HOLOGRAPHIC_BLUE); mHolographicPaint.setFilterBitmap(true); mHolographicPaint.setAntiAlias(true); mBlurPaint.setMaskFilter(new BlurMaskFilter(BLUR_FACTOR * density, @@ -84,6 +88,13 @@ class HolographicOutlineHelper { } /** + * Sets the color of the holographic paint to be used when applying the outline/blur. + */ + void setColor(int color) { + mHolographicPaint.setColor(color); + } + + /** * Applies an outline to whatever is currently drawn in the specified bitmap. */ void applyOutline(Bitmap srcDst, Canvas srcDstCanvas, PointF offset) { @@ -117,7 +128,7 @@ class HolographicOutlineHelper { * An icon on a PagedView, specifically for items in the launcher's paged view (with compound * drawables on the top). */ -public class PagedViewIcon extends TextView { +public class PagedViewIcon extends TextView implements Checkable { private static final String TAG = "PagedViewIcon"; // holographic outline @@ -131,6 +142,8 @@ public class PagedViewIcon extends TextView { private int mAlpha; private int mHolographicAlpha; + private boolean mIsChecked; + public PagedViewIcon(Context context) { this(context, null); } @@ -172,6 +185,21 @@ public class PagedViewIcon extends TextView { } @Override + public void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, + Drawable right, Drawable bottom) { + invalidateHolographicImage(); + super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom); + } + + public void invalidateHolographicImage() { + if (mHolographicOutline != null) { + mHolographicOutline.recycle(); + mHolographicOutline = null; + mHolographicOutlineCanvas = null; + } + } + + @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); @@ -191,7 +219,8 @@ public class PagedViewIcon extends TextView { mHolographicOutlineCanvas = new Canvas(mHolographicOutline); mHolographicOutlineCanvas.concat(getMatrix()); draw(mHolographicOutlineCanvas); - sHolographicOutlineHelper.applyOutline(mHolographicOutline, mHolographicOutlineCanvas, + sHolographicOutlineHelper.setColor(HolographicOutlineHelper.HOLOGRAPHIC_BLUE); + sHolographicOutlineHelper.applyOutline(mHolographicOutline, mHolographicOutlineCanvas, offset); sHolographicOutlineHelper.applyBlur(mHolographicOutline, mHolographicOutlineCanvas); mIsHolographicUpdatePass = false; @@ -231,4 +260,20 @@ public class PagedViewIcon extends TextView { canvas.drawBitmap(mHolographicOutline, 0, 0, mPaint); } } + + @Override + public boolean isChecked() { + return mIsChecked; + } + + @Override + public void setChecked(boolean checked) { + mIsChecked = checked; + invalidate(); + } + + @Override + public void toggle() { + setChecked(!mIsChecked); + } } |