summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Utilities.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-12-04 10:04:54 -0800
committerSunny Goyal <sunnygoyal@google.com>2015-12-04 10:04:54 -0800
commit2d2b42ba3ced1a9b68124804f7b73e50359a4ea2 (patch)
tree403a541f7476eeed4df2e9af7bf9037c36ae44b4 /src/com/android/launcher3/Utilities.java
parent9ec6d402fab5ec988a5c8cce10fb61df6acef31a (diff)
parent39b700fcc501a5c9b2fb83d4b754fb24d43d5c49 (diff)
downloadandroid_packages_apps_Trebuchet-2d2b42ba3ced1a9b68124804f7b73e50359a4ea2.tar.gz
android_packages_apps_Trebuchet-2d2b42ba3ced1a9b68124804f7b73e50359a4ea2.tar.bz2
android_packages_apps_Trebuchet-2d2b42ba3ced1a9b68124804f7b73e50359a4ea2.zip
resolve merge conflicts of 39b700fcc5 to ub-launcher3-master.
Change-Id: I394258be0c75289cab2f5141c0fb765504527420
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 b353f82ce..a102203e8 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -62,6 +62,7 @@ import android.widget.Toast;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.config.ProviderConfig;
+import com.android.launcher3.util.IconNormalizer;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -209,12 +210,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 = ProviderConfig.IS_DOGFOOD_BUILD ?
+ 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);
@@ -234,6 +238,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();
@@ -289,7 +300,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);
@@ -346,7 +360,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) {