Loading src/com/android/launcher3/IconCache.java +7 −5 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Handler; import android.os.Process; import android.os.SystemClock; Loading Loading @@ -194,7 +195,7 @@ public class IconCache { protected Bitmap makeDefaultIcon(UserHandle user) { Drawable unbadged = getFullResDefaultActivityIcon(); return LauncherIcons.createBadgedIconBitmap(unbadged, user, mContext); return LauncherIcons.createBadgedIconBitmap(unbadged, user, mContext, Build.VERSION_CODES.O); } /** Loading Loading @@ -380,7 +381,7 @@ public class IconCache { if (entry == null) { entry = new CacheEntry(); entry.icon = LauncherIcons.createBadgedIconBitmap(getFullResIcon(app), app.getUser(), mContext); mContext, app.getApplicationInfo().targetSdkVersion); } entry.title = app.getLabel(); entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, app.getUser()); Loading Loading @@ -537,7 +538,8 @@ public class IconCache { if (info != null) { entry.icon = LauncherIcons.createBadgedIconBitmap( getFullResIcon(info), info.getUser(), mContext); getFullResIcon(info), info.getUser(), mContext, infoProvider.get().getApplicationInfo().targetSdkVersion); } else { if (usePackageIcon) { CacheEntry packageEntry = getEntryForPackageLocked( Loading Loading @@ -634,7 +636,7 @@ public class IconCache { // Load the full res icon for the application, but if useLowResIcon is set, then // only keep the low resolution icon instead of the larger full-sized icon Bitmap icon = LauncherIcons.createBadgedIconBitmap( appInfo.loadIcon(mPackageManager), user, mContext); appInfo.loadIcon(mPackageManager), user, mContext, appInfo.targetSdkVersion); Bitmap lowResIcon = generateLowResIcon(icon, mPackageBgColor); entry.title = appInfo.loadLabel(mPackageManager); entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user); Loading Loading @@ -767,7 +769,7 @@ public class IconCache { } private static final class IconDB extends SQLiteCacheHelper { private final static int DB_VERSION = 12; private final static int DB_VERSION = 13; private final static int RELEASE_VERSION = DB_VERSION + (FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION ? 0 : 1); Loading src/com/android/launcher3/WidgetPreviewLoader.java +2 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Build; import android.os.CancellationSignal; import android.os.Handler; import android.os.UserHandle; Loading Loading @@ -481,7 +482,7 @@ public class WidgetPreviewLoader { RectF boxRect = drawBoxWithShadow(c, p, size, size); Bitmap icon = LauncherIcons.createScaledBitmapWithoutShadow( mutateOnMainThread(info.getFullResIcon(mIconCache)), mContext); mutateOnMainThread(info.getFullResIcon(mIconCache)), mContext, Build.VERSION_CODES.O); Rect src = new Rect(0, 0, icon.getWidth(), icon.getHeight()); boxRect.set(0, 0, iconSize, iconSize); Loading src/com/android/launcher3/graphics/LauncherIcons.java +8 −6 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.PaintDrawable; import android.os.Build; import android.os.Process; import android.os.UserHandle; Loading Loading @@ -94,13 +95,13 @@ public class LauncherIcons { * The bitmap is also visually normalized with other icons. */ public static Bitmap createBadgedIconBitmap( Drawable icon, UserHandle user, Context context) { Drawable icon, UserHandle user, Context context, int iconAppTargetSdk) { IconNormalizer normalizer; float scale = 1f; if (!FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION) { normalizer = IconNormalizer.getInstance(context); if (Utilities.isAtLeastO()) { if (Utilities.isAtLeastO() && iconAppTargetSdk >= Build.VERSION_CODES.O) { boolean[] outShape = new boolean[1]; AdaptiveIconDrawable dr = (AdaptiveIconDrawable) context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate(); Loading Loading @@ -148,13 +149,13 @@ public class LauncherIcons { * Creates a normalized bitmap suitable for the all apps view. The bitmap is also visually * normalized with other icons and has enough spacing to add shadow. */ public static Bitmap createScaledBitmapWithoutShadow(Drawable icon, Context context) { public static Bitmap createScaledBitmapWithoutShadow(Drawable icon, Context context, int iconAppTargetSdk) { RectF iconBounds = new RectF(); IconNormalizer normalizer; float scale = 1f; if (!FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION) { normalizer = IconNormalizer.getInstance(context); if (Utilities.isAtLeastO()) { if (Utilities.isAtLeastO() && iconAppTargetSdk >= Build.VERSION_CODES.O) { boolean[] outShape = new boolean[1]; AdaptiveIconDrawable dr = (AdaptiveIconDrawable) context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate(); Loading @@ -179,7 +180,7 @@ public class LauncherIcons { /** * Adds a shadow to the provided icon. It assumes that the icon has already been scaled using * {@link #createScaledBitmapWithoutShadow(Drawable, Context)} * {@link #createScaledBitmapWithoutShadow(Drawable, Context, int)} */ public static Bitmap addShadowToIcon(Bitmap icon, Context context) { return ShadowGenerator.getInstance(context).recreateIcon(icon); Loading Loading @@ -318,7 +319,8 @@ public class LauncherIcons { IconCache cache = app.getIconCache(); Bitmap unbadgedBitmap = unbadgedDrawable == null ? cache.getDefaultIcon(Process.myUserHandle()) : LauncherIcons.createScaledBitmapWithoutShadow(unbadgedDrawable, context); : LauncherIcons.createScaledBitmapWithoutShadow(unbadgedDrawable, context, Build.VERSION_CODES.O); if (!badged) { return unbadgedBitmap; Loading src/com/android/launcher3/widget/PendingItemDragHelper.java +2 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; import android.view.View; import android.widget.RemoteViews; Loading Loading @@ -115,7 +116,7 @@ public class PendingItemDragHelper extends DragPreviewProvider { } else { PendingAddShortcutInfo createShortcutInfo = (PendingAddShortcutInfo) mAddInfo; Drawable icon = createShortcutInfo.activityInfo.getFullResIcon(app.getIconCache()); preview = LauncherIcons.createScaledBitmapWithoutShadow(icon, launcher); preview = LauncherIcons.createScaledBitmapWithoutShadow(icon, launcher, Build.VERSION_CODES.O); mAddInfo.spanX = mAddInfo.spanY = 1; scale = ((float) launcher.getDeviceProfile().iconSizePx) / preview.getWidth(); Loading Loading
src/com/android/launcher3/IconCache.java +7 −5 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Handler; import android.os.Process; import android.os.SystemClock; Loading Loading @@ -194,7 +195,7 @@ public class IconCache { protected Bitmap makeDefaultIcon(UserHandle user) { Drawable unbadged = getFullResDefaultActivityIcon(); return LauncherIcons.createBadgedIconBitmap(unbadged, user, mContext); return LauncherIcons.createBadgedIconBitmap(unbadged, user, mContext, Build.VERSION_CODES.O); } /** Loading Loading @@ -380,7 +381,7 @@ public class IconCache { if (entry == null) { entry = new CacheEntry(); entry.icon = LauncherIcons.createBadgedIconBitmap(getFullResIcon(app), app.getUser(), mContext); mContext, app.getApplicationInfo().targetSdkVersion); } entry.title = app.getLabel(); entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, app.getUser()); Loading Loading @@ -537,7 +538,8 @@ public class IconCache { if (info != null) { entry.icon = LauncherIcons.createBadgedIconBitmap( getFullResIcon(info), info.getUser(), mContext); getFullResIcon(info), info.getUser(), mContext, infoProvider.get().getApplicationInfo().targetSdkVersion); } else { if (usePackageIcon) { CacheEntry packageEntry = getEntryForPackageLocked( Loading Loading @@ -634,7 +636,7 @@ public class IconCache { // Load the full res icon for the application, but if useLowResIcon is set, then // only keep the low resolution icon instead of the larger full-sized icon Bitmap icon = LauncherIcons.createBadgedIconBitmap( appInfo.loadIcon(mPackageManager), user, mContext); appInfo.loadIcon(mPackageManager), user, mContext, appInfo.targetSdkVersion); Bitmap lowResIcon = generateLowResIcon(icon, mPackageBgColor); entry.title = appInfo.loadLabel(mPackageManager); entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user); Loading Loading @@ -767,7 +769,7 @@ public class IconCache { } private static final class IconDB extends SQLiteCacheHelper { private final static int DB_VERSION = 12; private final static int DB_VERSION = 13; private final static int RELEASE_VERSION = DB_VERSION + (FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION ? 0 : 1); Loading
src/com/android/launcher3/WidgetPreviewLoader.java +2 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Build; import android.os.CancellationSignal; import android.os.Handler; import android.os.UserHandle; Loading Loading @@ -481,7 +482,7 @@ public class WidgetPreviewLoader { RectF boxRect = drawBoxWithShadow(c, p, size, size); Bitmap icon = LauncherIcons.createScaledBitmapWithoutShadow( mutateOnMainThread(info.getFullResIcon(mIconCache)), mContext); mutateOnMainThread(info.getFullResIcon(mIconCache)), mContext, Build.VERSION_CODES.O); Rect src = new Rect(0, 0, icon.getWidth(), icon.getHeight()); boxRect.set(0, 0, iconSize, iconSize); Loading
src/com/android/launcher3/graphics/LauncherIcons.java +8 −6 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.PaintDrawable; import android.os.Build; import android.os.Process; import android.os.UserHandle; Loading Loading @@ -94,13 +95,13 @@ public class LauncherIcons { * The bitmap is also visually normalized with other icons. */ public static Bitmap createBadgedIconBitmap( Drawable icon, UserHandle user, Context context) { Drawable icon, UserHandle user, Context context, int iconAppTargetSdk) { IconNormalizer normalizer; float scale = 1f; if (!FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION) { normalizer = IconNormalizer.getInstance(context); if (Utilities.isAtLeastO()) { if (Utilities.isAtLeastO() && iconAppTargetSdk >= Build.VERSION_CODES.O) { boolean[] outShape = new boolean[1]; AdaptiveIconDrawable dr = (AdaptiveIconDrawable) context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate(); Loading Loading @@ -148,13 +149,13 @@ public class LauncherIcons { * Creates a normalized bitmap suitable for the all apps view. The bitmap is also visually * normalized with other icons and has enough spacing to add shadow. */ public static Bitmap createScaledBitmapWithoutShadow(Drawable icon, Context context) { public static Bitmap createScaledBitmapWithoutShadow(Drawable icon, Context context, int iconAppTargetSdk) { RectF iconBounds = new RectF(); IconNormalizer normalizer; float scale = 1f; if (!FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION) { normalizer = IconNormalizer.getInstance(context); if (Utilities.isAtLeastO()) { if (Utilities.isAtLeastO() && iconAppTargetSdk >= Build.VERSION_CODES.O) { boolean[] outShape = new boolean[1]; AdaptiveIconDrawable dr = (AdaptiveIconDrawable) context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate(); Loading @@ -179,7 +180,7 @@ public class LauncherIcons { /** * Adds a shadow to the provided icon. It assumes that the icon has already been scaled using * {@link #createScaledBitmapWithoutShadow(Drawable, Context)} * {@link #createScaledBitmapWithoutShadow(Drawable, Context, int)} */ public static Bitmap addShadowToIcon(Bitmap icon, Context context) { return ShadowGenerator.getInstance(context).recreateIcon(icon); Loading Loading @@ -318,7 +319,8 @@ public class LauncherIcons { IconCache cache = app.getIconCache(); Bitmap unbadgedBitmap = unbadgedDrawable == null ? cache.getDefaultIcon(Process.myUserHandle()) : LauncherIcons.createScaledBitmapWithoutShadow(unbadgedDrawable, context); : LauncherIcons.createScaledBitmapWithoutShadow(unbadgedDrawable, context, Build.VERSION_CODES.O); if (!badged) { return unbadgedBitmap; Loading
src/com/android/launcher3/widget/PendingItemDragHelper.java +2 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; import android.view.View; import android.widget.RemoteViews; Loading Loading @@ -115,7 +116,7 @@ public class PendingItemDragHelper extends DragPreviewProvider { } else { PendingAddShortcutInfo createShortcutInfo = (PendingAddShortcutInfo) mAddInfo; Drawable icon = createShortcutInfo.activityInfo.getFullResIcon(app.getIconCache()); preview = LauncherIcons.createScaledBitmapWithoutShadow(icon, launcher); preview = LauncherIcons.createScaledBitmapWithoutShadow(icon, launcher, Build.VERSION_CODES.O); mAddInfo.spanX = mAddInfo.spanY = 1; scale = ((float) launcher.getDeviceProfile().iconSizePx) / preview.getWidth(); Loading