summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Utilities.java
diff options
context:
space:
mode:
authorDanesh Mondegarian <daneshm90@gmail.com>2014-02-10 00:40:23 -0800
committerDanesh M <daneshm90@gmail.com>2014-02-12 16:25:53 -0800
commitc4627bba1f76f8ee7abfb577bf24aafcae7b182f (patch)
tree61071208e97ba780902c19307bd1f3b29f7f49d2 /src/com/android/launcher3/Utilities.java
parentd5f4c6614f69b79fb0c2a96d97b24bcf8eff6c3b (diff)
downloadandroid_packages_apps_Trebuchet-c4627bba1f76f8ee7abfb577bf24aafcae7b182f.tar.gz
android_packages_apps_Trebuchet-c4627bba1f76f8ee7abfb577bf24aafcae7b182f.tar.bz2
android_packages_apps_Trebuchet-c4627bba1f76f8ee7abfb577bf24aafcae7b182f.zip
Trebuchet : Add iconMask/iconBack/iconUpon/iconScale support
Change-Id: I85ecee3b5c26f79918fe0c4d220e09c943eec3e6
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r--src/com/android/launcher3/Utilities.java31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index f41a1c2e5..9b5cbe7eb 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -103,10 +103,15 @@ final class Utilities {
}
}
+ static Bitmap createIconBitmap(Drawable icon, Context context) {
+ return createIconBitmap(icon, context, null, null, null, 1f);
+ }
+
/**
* Returns a bitmap suitable for the all apps view.
*/
- static Bitmap createIconBitmap(Drawable icon, Context context) {
+ static Bitmap createIconBitmap(Drawable icon, Context context, Drawable iconBack,
+ Drawable iconMask, Drawable iconUpon, float scale) {
synchronized (sCanvas) { // we share the statics :-(
if (sIconWidth == -1) {
initStatics(context);
@@ -143,7 +148,7 @@ final class Utilities {
int textureWidth = sIconTextureWidth;
int textureHeight = sIconTextureHeight;
- final Bitmap bitmap = Bitmap.createBitmap(textureWidth, textureHeight,
+ Bitmap bitmap = Bitmap.createBitmap(textureWidth, textureHeight,
Bitmap.Config.ARGB_8888);
final Canvas canvas = sCanvas;
canvas.setBitmap(bitmap);
@@ -164,7 +169,29 @@ final class Utilities {
sOldBounds.set(icon.getBounds());
icon.setBounds(left, top, left+width, top+height);
+ canvas.save();
+ if (iconMask != null && iconBack != null) {
+ canvas.scale(scale, scale, width / 2, height/2);
+ }
icon.draw(canvas);
+ canvas.restore();
+ if (iconBack != null && iconMask != null) {
+ iconMask.setBounds(icon.getBounds());
+ ((BitmapDrawable) iconMask).getPaint().setXfermode(
+ new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
+ iconMask.draw(canvas);
+ canvas.setBitmap(null);
+ Bitmap finalBitmap = Bitmap.createBitmap(textureWidth, textureHeight,
+ Bitmap.Config.ARGB_8888);
+ canvas.setBitmap(finalBitmap);
+ iconBack.setBounds(icon.getBounds());
+ iconBack.draw(canvas);
+ canvas.drawBitmap(bitmap, null, icon.getBounds(), null);
+ bitmap = finalBitmap;
+ }
+ if (iconUpon != null) {
+ iconUpon.draw(canvas);
+ }
icon.setBounds(sOldBounds);
canvas.setBitmap(null);