summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-01-12 22:35:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-01-12 22:35:16 +0000
commit5255c87c6f215010aeeb690eed4eae28177b0a93 (patch)
treedb2c42ee3f8a3f1c5e2d8305d2676d9a76a85c04
parentecdc24f6f667319db56a16dd7d1efda16dfe662e (diff)
parente1483fb1cdabb33e7031bdebba96212d920c7416 (diff)
downloadandroid_packages_apps_Trebuchet-5255c87c6f215010aeeb690eed4eae28177b0a93.tar.gz
android_packages_apps_Trebuchet-5255c87c6f215010aeeb690eed4eae28177b0a93.tar.bz2
android_packages_apps_Trebuchet-5255c87c6f215010aeeb690eed4eae28177b0a93.zip
Merge "Fixing icon badging being done on scaled bitmap size" into ub-launcher3-burnaby-polish
-rw-r--r--src/com/android/launcher3/Utilities.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index f9524a1c4..87c9262d7 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -210,7 +210,7 @@ public final class Utilities {
Bitmap bitmap = createIconBitmap(icon, context, scale);
if (Utilities.ATLEAST_LOLLIPOP && user != null
&& !UserHandleCompat.myUserHandle().equals(user)) {
- BitmapDrawable drawable = new BitmapDrawable(context.getResources(), bitmap);
+ BitmapDrawable drawable = new FixedSizeBitmapDrawable(bitmap);
Drawable badged = context.getPackageManager().getUserBadgedIcon(
drawable, user.getUser());
if (badged instanceof BitmapDrawable) {
@@ -805,4 +805,26 @@ public final class Utilities {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
return ATLEAST_LOLLIPOP && powerManager.isPowerSaveMode();
}
+
+ /**
+ * An extension of {@link BitmapDrawable} which returns the bitmap pixel size as intrinsic size.
+ * This allows the badging to be done based on the action bitmap size rather than
+ * the scaled bitmap size.
+ */
+ private static class FixedSizeBitmapDrawable extends BitmapDrawable {
+
+ public FixedSizeBitmapDrawable(Bitmap bitmap) {
+ super(null, bitmap);
+ }
+
+ @Override
+ public int getIntrinsicHeight() {
+ return getBitmap().getWidth();
+ }
+
+ @Override
+ public int getIntrinsicWidth() {
+ return getBitmap().getWidth();
+ }
+ }
}