From 8ff9e1d6790d64eb5f8ad9e9721e607978b50583 Mon Sep 17 00:00:00 2001 From: Mario Bertschler Date: Tue, 8 Aug 2017 16:26:18 -0700 Subject: Integrating suggested app by handling new status flags for shortcut items. Guarded via feature flag SUGGESTED_APP. Bug: 62483883 Change-Id: I7e0c8a9875bc37c435aa4316b44322a628cd4826 --- src/com/android/launcher3/graphics/LauncherIcons.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/com/android/launcher3/graphics') diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java index d95567492..7c80c3098 100644 --- a/src/com/android/launcher3/graphics/LauncherIcons.java +++ b/src/com/android/launcher3/graphics/LauncherIcons.java @@ -38,6 +38,7 @@ import android.os.UserHandle; import android.support.annotation.Nullable; import com.android.launcher3.AppInfo; +import com.android.launcher3.FastBitmapDrawable; import com.android.launcher3.IconCache; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; @@ -192,13 +193,16 @@ public class LauncherIcons { * Adds the {@param badge} on top of {@param srcTgt} using the badge dimensions. */ public static Bitmap badgeWithBitmap(Bitmap srcTgt, Bitmap badge, Context context) { + return badgeWithDrawable(srcTgt, new FastBitmapDrawable(badge), context); + } + + public static Bitmap badgeWithDrawable(Bitmap srcTgt, Drawable badge, Context context) { int badgeSize = context.getResources().getDimensionPixelSize(R.dimen.profile_badge_size); synchronized (sCanvas) { sCanvas.setBitmap(srcTgt); - sCanvas.drawBitmap(badge, new Rect(0, 0, badge.getWidth(), badge.getHeight()), - new Rect(srcTgt.getWidth() - badgeSize, - srcTgt.getHeight() - badgeSize, srcTgt.getWidth(), srcTgt.getHeight()), - new Paint(Paint.FILTER_BITMAP_FLAG)); + int iconSize = srcTgt.getWidth(); + badge.setBounds(iconSize - badgeSize, iconSize - badgeSize, iconSize, iconSize); + badge.draw(sCanvas); sCanvas.setBitmap(null); } return srcTgt; -- cgit v1.2.3 From 7927b032875d3233df7a888471aac2c139258eb4 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Tue, 29 Aug 2017 11:06:30 -0700 Subject: Fix @SuppressWarnings('deprecation') typo. http://errorprone.info/bugpattern/SuppressWarningsDeprecated This typo throws a build error on oc-mr1-dev. Bug: 64937210 Change-Id: I4c48a22c5ac0f296053753d4058385581037ab06 --- src/com/android/launcher3/graphics/IconShapeOverride.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/com/android/launcher3/graphics') diff --git a/src/com/android/launcher3/graphics/IconShapeOverride.java b/src/com/android/launcher3/graphics/IconShapeOverride.java index e2d1d50e4..654fa98bc 100644 --- a/src/com/android/launcher3/graphics/IconShapeOverride.java +++ b/src/com/android/launcher3/graphics/IconShapeOverride.java @@ -130,7 +130,7 @@ public class IconShapeOverride { private final int mOverrideId; private final String mOverrideValue; - @SuppressWarnings("deprecated") + @SuppressWarnings("deprecation") public ResourcesOverride(Resources parent, int overrideId, String overrideValue) { super(parent.getAssets(), parent.getDisplayMetrics(), parent.getConfiguration()); mOverrideId = overrideId; -- cgit v1.2.3 From e24cb63b811e2885a69e7df794e9972cdf5a57b9 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Mon, 11 Sep 2017 11:18:03 -0700 Subject: WallpaperManagerCompat should target correct platform Also replace Utilities.isAtLeastO() to static final constant. Bug: 65544683 Change-Id: I39fbea66939d72c31702748716c4e65b4f9bee6a --- src/com/android/launcher3/graphics/DrawableFactory.java | 2 +- src/com/android/launcher3/graphics/IconNormalizer.java | 4 ++-- .../android/launcher3/graphics/IconShapeOverride.java | 4 ++-- src/com/android/launcher3/graphics/LauncherIcons.java | 16 ++++++++-------- src/com/android/launcher3/graphics/ShadowDrawable.java | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/com/android/launcher3/graphics') diff --git a/src/com/android/launcher3/graphics/DrawableFactory.java b/src/com/android/launcher3/graphics/DrawableFactory.java index 45344c020..371479b36 100644 --- a/src/com/android/launcher3/graphics/DrawableFactory.java +++ b/src/com/android/launcher3/graphics/DrawableFactory.java @@ -80,7 +80,7 @@ public class DrawableFactory { protected Path getPreloadProgressPath(Context context) { - if (Utilities.isAtLeastO()) { + if (Utilities.ATLEAST_OREO) { try { // Try to load the path from Mask Icon Drawable icon = context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper); diff --git a/src/com/android/launcher3/graphics/IconNormalizer.java b/src/com/android/launcher3/graphics/IconNormalizer.java index 8ed62bcdc..28fc42368 100644 --- a/src/com/android/launcher3/graphics/IconNormalizer.java +++ b/src/com/android/launcher3/graphics/IconNormalizer.java @@ -231,7 +231,7 @@ public class IconNormalizer { */ public synchronized float getScale(@NonNull Drawable d, @Nullable RectF outBounds, @Nullable Path path, @Nullable boolean[] outMaskShape) { - if (Utilities.isAtLeastO() && d instanceof AdaptiveIconDrawable && + if (Utilities.ATLEAST_OREO && d instanceof AdaptiveIconDrawable && mAdaptiveIconScale != SCALE_NOT_INITIALIZED) { if (outBounds != null) { outBounds.set(mAdaptiveIconBounds); @@ -347,7 +347,7 @@ public class IconNormalizer { float areaScale = area / (width * height); // Use sqrt of the final ratio as the images is scaled across both width and height. float scale = areaScale > scaleRequired ? (float) Math.sqrt(scaleRequired / areaScale) : 1; - if (Utilities.isAtLeastO() && d instanceof AdaptiveIconDrawable && + if (Utilities.ATLEAST_OREO && d instanceof AdaptiveIconDrawable && mAdaptiveIconScale == SCALE_NOT_INITIALIZED) { mAdaptiveIconScale = scale; mAdaptiveIconBounds.set(mBounds); diff --git a/src/com/android/launcher3/graphics/IconShapeOverride.java b/src/com/android/launcher3/graphics/IconShapeOverride.java index 654fa98bc..223243b7a 100644 --- a/src/com/android/launcher3/graphics/IconShapeOverride.java +++ b/src/com/android/launcher3/graphics/IconShapeOverride.java @@ -59,7 +59,7 @@ public class IconShapeOverride { private static final int RESTART_REQUEST_CODE = 42; // the answer to everything public static boolean isSupported(Context context) { - if (!Utilities.isAtLeastO()) { + if (!Utilities.ATLEAST_OREO) { return false; } // Only supported when developer settings is enabled @@ -82,7 +82,7 @@ public class IconShapeOverride { } public static void apply(Context context) { - if (!Utilities.isAtLeastO()) { + if (!Utilities.ATLEAST_OREO) { return; } String path = getAppliedValue(context); diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java index 7c80c3098..d55baf0f8 100644 --- a/src/com/android/launcher3/graphics/LauncherIcons.java +++ b/src/com/android/launcher3/graphics/LauncherIcons.java @@ -104,7 +104,7 @@ public class LauncherIcons { float scale = 1f; if (!FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION) { normalizer = IconNormalizer.getInstance(context); - if (Utilities.isAtLeastO() && iconAppTargetSdk >= Build.VERSION_CODES.O) { + if (Utilities.ATLEAST_OREO && iconAppTargetSdk >= Build.VERSION_CODES.O) { boolean[] outShape = new boolean[1]; AdaptiveIconDrawable dr = (AdaptiveIconDrawable) context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate(); @@ -123,7 +123,7 @@ public class LauncherIcons { } } Bitmap bitmap = createIconBitmap(icon, context, scale); - if (FeatureFlags.ADAPTIVE_ICON_SHADOW && Utilities.isAtLeastO() && + if (FeatureFlags.ADAPTIVE_ICON_SHADOW && Utilities.ATLEAST_OREO && icon instanceof AdaptiveIconDrawable) { bitmap = ShadowGenerator.getInstance(context).recreateIcon(bitmap); } @@ -158,13 +158,13 @@ public class LauncherIcons { float scale = 1f; if (!FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION) { normalizer = IconNormalizer.getInstance(context); - if (Utilities.isAtLeastO() && iconAppTargetSdk >= Build.VERSION_CODES.O) { + if (Utilities.ATLEAST_OREO && iconAppTargetSdk >= Build.VERSION_CODES.O) { boolean[] outShape = new boolean[1]; AdaptiveIconDrawable dr = (AdaptiveIconDrawable) context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate(); dr.setBounds(0, 0, 1, 1); scale = normalizer.getScale(icon, iconBounds, dr.getIconMask(), outShape); - if (Utilities.isAtLeastO() && FeatureFlags.LEGACY_ICON_TREATMENT && + if (Utilities.ATLEAST_OREO && FeatureFlags.LEGACY_ICON_TREATMENT && !outShape[0]) { Drawable wrappedIcon = wrapToAdaptiveIconDrawable(context, icon, scale); if (wrappedIcon != icon) { @@ -213,12 +213,12 @@ public class LauncherIcons { */ public static Bitmap createIconBitmap(Drawable icon, Context context) { float scale = 1f; - if (FeatureFlags.ADAPTIVE_ICON_SHADOW && Utilities.isAtLeastO() && + if (FeatureFlags.ADAPTIVE_ICON_SHADOW && Utilities.ATLEAST_OREO && icon instanceof AdaptiveIconDrawable) { scale = ShadowGenerator.getScaleForBounds(new RectF(0, 0, 0, 0)); } Bitmap bitmap = createIconBitmap(icon, context, scale); - if (FeatureFlags.ADAPTIVE_ICON_SHADOW && Utilities.isAtLeastO() && + if (FeatureFlags.ADAPTIVE_ICON_SHADOW && Utilities.ATLEAST_OREO && icon instanceof AdaptiveIconDrawable) { bitmap = ShadowGenerator.getInstance(context).recreateIcon(bitmap); } @@ -271,7 +271,7 @@ public class LauncherIcons { final int top = (textureHeight-height) / 2; sOldBounds.set(icon.getBounds()); - if (Utilities.isAtLeastO() && icon instanceof AdaptiveIconDrawable) { + if (Utilities.ATLEAST_OREO && icon instanceof AdaptiveIconDrawable) { int offset = Math.max((int)(ShadowGenerator.BLUR_FACTOR * iconBitmapSize), Math.min(left, top)); int size = Math.max(width, height); @@ -296,7 +296,7 @@ public class LauncherIcons { * create AdaptiveIconDrawable. */ static Drawable wrapToAdaptiveIconDrawable(Context context, Drawable drawable, float scale) { - if (!(FeatureFlags.LEGACY_ICON_TREATMENT && Utilities.isAtLeastO())) { + if (!(FeatureFlags.LEGACY_ICON_TREATMENT && Utilities.ATLEAST_OREO)) { return drawable; } diff --git a/src/com/android/launcher3/graphics/ShadowDrawable.java b/src/com/android/launcher3/graphics/ShadowDrawable.java index ffcedb26a..b40bf7828 100644 --- a/src/com/android/launcher3/graphics/ShadowDrawable.java +++ b/src/com/android/launcher3/graphics/ShadowDrawable.java @@ -146,7 +146,7 @@ public class ShadowDrawable extends Drawable { d.draw(canvas); } - if (Utilities.isAtLeastO()) { + if (Utilities.ATLEAST_OREO) { bitmap = bitmap.copy(Bitmap.Config.HARDWARE, false); } mState.mLastDrawnBitmap = bitmap; -- cgit v1.2.3