summaryrefslogtreecommitdiffstats
path: root/iconloaderlib
diff options
context:
space:
mode:
authorSamuel Fufa <sfufa@google.com>2019-10-04 16:37:12 -0700
committerSamuel Fufa <sfufa@google.com>2019-10-04 17:06:33 -0700
commitaa038af6b3da0633c229f053c3f272bb452e4632 (patch)
tree4d4865aa8c36920e0be28496d770875cdb3363a2 /iconloaderlib
parente5865a03bb661887910f0c1809bc3eda56092996 (diff)
downloadandroid_packages_apps_Trebuchet-aa038af6b3da0633c229f053c3f272bb452e4632.tar.gz
android_packages_apps_Trebuchet-aa038af6b3da0633c229f053c3f272bb452e4632.tar.bz2
android_packages_apps_Trebuchet-aa038af6b3da0633c229f053c3f272bb452e4632.zip
Scale Icon badges for shortcut and widgets
Test: Manual Bug: 141262820 Change-Id: I03edc986e3fe1876b6b7ed179b96864d587cb137
Diffstat (limited to 'iconloaderlib')
-rw-r--r--iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
index fc7d6b329..f491ed73f 100644
--- a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
+++ b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
@@ -22,6 +22,7 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
+
import androidx.annotation.NonNull;
/**
@@ -35,6 +36,8 @@ public class BaseIconFactory implements AutoCloseable {
static final boolean ATLEAST_OREO = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
static final boolean ATLEAST_P = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P;
+ private static final float ICON_BADGE_SCALE = 0.444f;
+
private final Rect mOldBounds = new Rect();
protected final Context mContext;
private final Canvas mCanvas;
@@ -254,7 +257,7 @@ public class BaseIconFactory implements AutoCloseable {
* Adds the {@param badge} on top of {@param target} using the badge dimensions.
*/
public void badgeWithDrawable(Canvas target, Drawable badge) {
- int badgeSize = mContext.getResources().getDimensionPixelSize(R.dimen.profile_badge_size);
+ int badgeSize = getBadgeSizeForIconSize(mIconBitmapSize);
badge.setBounds(mIconBitmapSize - badgeSize, mIconBitmapSize - badgeSize,
mIconBitmapSize, mIconBitmapSize);
badge.draw(target);
@@ -335,6 +338,13 @@ public class BaseIconFactory implements AutoCloseable {
}
/**
+ * Returns the correct badge size given an icon size
+ */
+ public static int getBadgeSizeForIconSize(int iconSize) {
+ return (int) (ICON_BADGE_SCALE * iconSize);
+ }
+
+ /**
* 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.