diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-11-12 09:58:29 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2016-12-07 15:55:47 -0800 |
commit | 55cb70bf70d6defe84fe44e0d942998adefbb71c (patch) | |
tree | 2b2c1d472153110c3920f99f9493d6deeb19b2d1 /src/com/android/launcher3/FastBitmapDrawable.java | |
parent | 4633be64e863a96c63f814a2386b23b02d43910b (diff) | |
download | android_packages_apps_Trebuchet-55cb70bf70d6defe84fe44e0d942998adefbb71c.tar.gz android_packages_apps_Trebuchet-55cb70bf70d6defe84fe44e0d942998adefbb71c.tar.bz2 android_packages_apps_Trebuchet-55cb70bf70d6defe84fe44e0d942998adefbb71c.zip |
Adding an overridable DrawableFactory to allow creating custom icon drawables
> Adding ItemInfo as a parameter for creating drawable
Change-Id: I793acb0381d2b8df4db0a08317dddf1464788ebc
Diffstat (limited to 'src/com/android/launcher3/FastBitmapDrawable.java')
-rw-r--r-- | src/com/android/launcher3/FastBitmapDrawable.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java index 270d53939..0cefc5739 100644 --- a/src/com/android/launcher3/FastBitmapDrawable.java +++ b/src/com/android/launcher3/FastBitmapDrawable.java @@ -94,7 +94,7 @@ public class FastBitmapDrawable extends Drawable { private static final ColorMatrix sTempBrightnessMatrix = new ColorMatrix(); private static final ColorMatrix sTempFilterMatrix = new ColorMatrix(); - private final Paint mPaint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG); + protected final Paint mPaint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG); private final Bitmap mBitmap; private State mState = State.NORMAL; private boolean mIsDisabled; @@ -116,6 +116,17 @@ public class FastBitmapDrawable extends Drawable { @Override public void draw(Canvas canvas) { + drawInternal(canvas); + } + + public void drawWithBrightness(Canvas canvas, float brightness) { + float oldBrightness = getBrightness(); + setBrightness(brightness); + drawInternal(canvas); + setBrightness(oldBrightness); + } + + protected void drawInternal(Canvas canvas) { canvas.drawBitmap(mBitmap, null, getBounds(), mPaint); } @@ -278,7 +289,7 @@ public class FastBitmapDrawable extends Drawable { /** * Sets the saturation of this icon, 0 [full color] -> 1 [desaturated] */ - public void setDesaturation(float desaturation) { + private void setDesaturation(float desaturation) { int newDesaturation = (int) Math.floor(desaturation * REDUCED_FILTER_VALUE_SPACE); if (mDesaturation != newDesaturation) { mDesaturation = newDesaturation; @@ -293,7 +304,7 @@ public class FastBitmapDrawable extends Drawable { /** * Sets the brightness of this icon, 0 [no add. brightness] -> 1 [2bright2furious] */ - public void setBrightness(float brightness) { + private void setBrightness(float brightness) { int newBrightness = (int) Math.floor(brightness * REDUCED_FILTER_VALUE_SPACE); if (mBrightness != newBrightness) { mBrightness = newBrightness; @@ -301,7 +312,7 @@ public class FastBitmapDrawable extends Drawable { } } - public float getBrightness() { + private float getBrightness() { return (float) mBrightness / REDUCED_FILTER_VALUE_SPACE; } |