mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
Merge "Only apply legacy treatment on app icons that is targeting O" into ub-launcher3-dorval
This commit is contained in:
committed by
Android (Google) Code Review
commit
59c0e0e919
@@ -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;
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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());
|
||||
@@ -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(
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
@@ -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();
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user