Merge "[MANUAL] resolve merge conflicts of 59c0e0e91 to ub-launcher3-dorval-polish" into ub-launcher3-dorval-polish

This commit is contained in:
TreeHugger Robot
2017-04-27 18:52:58 +00:00
committed by Android (Google) Code Review
4 changed files with 24 additions and 20 deletions
+8 -7
View File
@@ -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());
@@ -437,10 +438,9 @@ public class IconCache {
* Updates {@param application} only if a valid entry is found.
*/
public synchronized void updateTitleAndIcon(AppInfo application) {
boolean usePackageIcon = application instanceof PromiseAppInfo;
CacheEntry entry = cacheLocked(application.componentName,
Provider.<LauncherActivityInfo>of(null),
application.user, usePackageIcon, application.usingLowResIcon);
application.user, false, application.usingLowResIcon);
if (entry.icon != null && !isDefaultIcon(entry.icon, application.user)) {
applyCacheEntry(entry, application);
}
@@ -538,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(
@@ -635,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);
@@ -768,7 +769,7 @@ public class IconCache {
}
private static final class IconDB extends SQLiteCacheHelper {
private final static int DB_VERSION = 11;
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;
@@ -435,20 +436,19 @@ public class WidgetPreviewLoader {
float shadowBlur = res.getDimension(R.dimen.widget_preview_shadow_blur);
float keyShadowDistance = res.getDimension(R.dimen.widget_preview_key_shadow_distance);
float corner = res.getDimension(R.dimen.widget_preview_corner_radius);
int shadowColor = ColorUtils.setAlphaComponent(
res.getColor(R.color.default_shadow_color_no_alpha),
ShadowGenerator.AMBIENT_SHADOW_ALPHA);
RectF bounds = new RectF(shadowBlur, shadowBlur,
width - shadowBlur, height - shadowBlur - keyShadowDistance);
p.setColor(Color.WHITE);
// Key shadow
p.setShadowLayer(shadowBlur, 0, keyShadowDistance, shadowColor);
p.setShadowLayer(shadowBlur, 0, keyShadowDistance,
ShadowGenerator.KEY_SHADOW_ALPHA << 24);
c.drawRoundRect(bounds, corner, corner, p);
// Ambient shadow
p.setShadowLayer(shadowBlur, 0, 0, shadowColor);
p.setShadowLayer(shadowBlur, 0, 0,
ColorUtils.setAlphaComponent(Color.BLACK, ShadowGenerator.AMBIENT_SHADOW_ALPHA));
c.drawRoundRect(bounds, corner, corner, p);
p.clearShadowLayer();
@@ -482,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();