summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-01-12 22:39:23 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-01-12 22:39:23 +0000
commite3a593a025c61117c6441ce66a911492fc5690d5 (patch)
tree577322f453c6e355f3abcd08060c32b3a3f71f68
parent92899800b7e9bd192fc50d44015a7850e77d47d4 (diff)
parent5255c87c6f215010aeeb690eed4eae28177b0a93 (diff)
downloadandroid_packages_apps_Trebuchet-e3a593a025c61117c6441ce66a911492fc5690d5.tar.gz
android_packages_apps_Trebuchet-e3a593a025c61117c6441ce66a911492fc5690d5.tar.bz2
android_packages_apps_Trebuchet-e3a593a025c61117c6441ce66a911492fc5690d5.zip
Merge "Fixing icon badging being done on scaled bitmap size" into ub-launcher3-burnaby-polish
am: 5255c87c6f * commit '5255c87c6f215010aeeb690eed4eae28177b0a93': Fixing icon badging being done on scaled bitmap size
-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 91a063a92..57b583b32 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -222,7 +222,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) {
@@ -827,4 +827,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();
+ }
+ }
}