summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Utilities.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-09-17 14:59:10 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-12-02 19:46:36 -0800
commitfc21830e6b904c8d156adebb793da0b6a51b7d5c (patch)
tree8a2094007ce30cc10627f68f19c2b2e71cd67bd2 /src/com/android/launcher3/Utilities.java
parentaa4011e63ed3a226e2876850fd93e7eec01f8845 (diff)
downloadandroid_packages_apps_Trebuchet-fc21830e6b904c8d156adebb793da0b6a51b7d5c.tar.gz
android_packages_apps_Trebuchet-fc21830e6b904c8d156adebb793da0b6a51b7d5c.tar.bz2
android_packages_apps_Trebuchet-fc21830e6b904c8d156adebb793da0b6a51b7d5c.zip
Normalizing app icons based on the standard icon guidelines
Bug: 18245189 Change-Id: Iaadcddbe3f966733a13b2e1fb60ba09a8b3aef9a
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r--src/com/android/launcher3/Utilities.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 54d050ff5..0a7028603 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -61,6 +61,7 @@ import android.view.View;
import android.widget.Toast;
import com.android.launcher3.compat.UserHandleCompat;
+import com.android.launcher3.util.IconNormalizer;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -197,12 +198,15 @@ public final class Utilities {
}
/**
- * Returns a bitmap suitable for the all apps view. The icon is badged for {@param user}
+ * Returns a bitmap suitable for the all apps view. The icon is badged for {@param user}.
+ * The bitmap is also visually normalized with other icons.
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Bitmap createBadgedIconBitmap(
Drawable icon, UserHandleCompat user, Context context) {
- Bitmap bitmap = createIconBitmap(icon, context);
+ float scale = LauncherAppState.isDogfoodBuild() ?
+ IconNormalizer.getInstance().getScale(icon) : 1;
+ Bitmap bitmap = createIconBitmap(icon, context, scale);
if (Utilities.ATLEAST_LOLLIPOP && user != null
&& !UserHandleCompat.myUserHandle().equals(user)) {
BitmapDrawable drawable = new BitmapDrawable(context.getResources(), bitmap);
@@ -222,6 +226,13 @@ public final class Utilities {
* Returns a bitmap suitable for the all apps view.
*/
public static Bitmap createIconBitmap(Drawable icon, Context context) {
+ return createIconBitmap(icon, context, 1.0f /* scale */);
+ }
+
+ /**
+ * @param scale the scale to apply before drawing {@param icon} on the canvas
+ */
+ public static Bitmap createIconBitmap(Drawable icon, Context context, float scale) {
synchronized (sCanvas) {
final int iconBitmapSize = getIconBitmapSize();
@@ -277,7 +288,10 @@ public final class Utilities {
sOldBounds.set(icon.getBounds());
icon.setBounds(left, top, left+width, top+height);
+ canvas.save(Canvas.MATRIX_SAVE_FLAG);
+ canvas.scale(scale, scale, textureWidth / 2, textureHeight / 2);
icon.draw(canvas);
+ canvas.restore();
icon.setBounds(sOldBounds);
canvas.setBitmap(null);
@@ -334,7 +348,7 @@ public final class Utilities {
}
/**
- * Inverse of {@link #getDescendantCoordRelativeToSelf(View, int[])}.
+ * Inverse of {@link #getDescendantCoordRelativeToParent(View, View, int[], boolean)}.
*/
public static float mapCoordInSelfToDescendent(View descendant, View root,
int[] coord) {