summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-01-08 12:16:15 -0800
committerSunny Goyal <sunnygoyal@google.com>2016-01-08 12:16:15 -0800
commite1483fb1cdabb33e7031bdebba96212d920c7416 (patch)
treed9bd61466e651a622d6fc045017d849ed87b3a84
parente70fb6f8ef03561b7875b872d0efa4ae2a5926af (diff)
downloadandroid_packages_apps_Trebuchet-e1483fb1cdabb33e7031bdebba96212d920c7416.tar.gz
android_packages_apps_Trebuchet-e1483fb1cdabb33e7031bdebba96212d920c7416.tar.bz2
android_packages_apps_Trebuchet-e1483fb1cdabb33e7031bdebba96212d920c7416.zip
Fixing icon badging being done on scaled bitmap size
Launcher already scales the bitmap during the icon creaiton. The badging should be done based on the actual size Bug: 26345646 Change-Id: I1b1f7ac736322ba10db9083d602eec221b99687a
-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();
+ }
+ }
}