summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Utilities.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-10-19 14:03:30 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-11-25 11:25:25 -0800
commit0b621156f336b40418120948aa93933dd26e548d (patch)
tree7672fabd5d398658ec164d8f932c210efdd5974f /src/com/android/launcher3/Utilities.java
parentd007d0722c782266f494806e750c24208d6d3ca5 (diff)
downloadandroid_packages_apps_Trebuchet-0b621156f336b40418120948aa93933dd26e548d.tar.gz
android_packages_apps_Trebuchet-0b621156f336b40418120948aa93933dd26e548d.tar.bz2
android_packages_apps_Trebuchet-0b621156f336b40418120948aa93933dd26e548d.zip
Scaling down the icon before applying the user badge
> This also saves memory only create one new bitmap while loading instead of two Bug: 25027252 Change-Id: Ia594dd65a30f32e99404190f649b334615c9e17f
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r--src/com/android/launcher3/Utilities.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 735cbebb7..54d050ff5 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -60,6 +60,8 @@ import android.util.TypedValue;
import android.view.View;
import android.widget.Toast;
+import com.android.launcher3.compat.UserHandleCompat;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
@@ -195,6 +197,28 @@ public final class Utilities {
}
/**
+ * Returns a bitmap suitable for the all apps view. The icon is badged for {@param user}
+ */
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ public static Bitmap createBadgedIconBitmap(
+ Drawable icon, UserHandleCompat user, Context context) {
+ Bitmap bitmap = createIconBitmap(icon, context);
+ if (Utilities.ATLEAST_LOLLIPOP && user != null
+ && !UserHandleCompat.myUserHandle().equals(user)) {
+ BitmapDrawable drawable = new BitmapDrawable(context.getResources(), bitmap);
+ Drawable badged = context.getPackageManager().getUserBadgedIcon(
+ drawable, user.getUser());
+ if (badged instanceof BitmapDrawable) {
+ return ((BitmapDrawable) badged).getBitmap();
+ } else {
+ return createIconBitmap(badged, context);
+ }
+ } else {
+ return bitmap;
+ }
+ }
+
+ /**
* Returns a bitmap suitable for the all apps view.
*/
public static Bitmap createIconBitmap(Drawable icon, Context context) {