diff options
author | Hyunyoung Song <hyunyoungs@google.com> | 2017-01-13 01:34:03 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-01-13 01:34:03 +0000 |
commit | e495056bd31c7803e44544237ec89460a1272387 (patch) | |
tree | ad7e523dfd19c422981488360ebfa08bd6d5a2c1 /src | |
parent | 3e9be43b6ea75c8b82b57aa58508a0c3e8e1d721 (diff) | |
parent | 9a5203a5391b9ad06ad4e1b806c17cbec2e968dd (diff) | |
download | android_packages_apps_Trebuchet-e495056bd31c7803e44544237ec89460a1272387.tar.gz android_packages_apps_Trebuchet-e495056bd31c7803e44544237ec89460a1272387.tar.bz2 android_packages_apps_Trebuchet-e495056bd31c7803e44544237ec89460a1272387.zip |
Merge "Use MaskableIconDrawable only in dogfood builds" into ub-launcher3-master
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/graphics/LauncherIcons.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java index 01bae0e66..8d8f3d914 100644 --- a/src/com/android/launcher3/graphics/LauncherIcons.java +++ b/src/com/android/launcher3/graphics/LauncherIcons.java @@ -34,7 +34,11 @@ import android.os.UserHandle; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; +import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; +import com.android.launcher3.config.ProviderConfig; + +import java.lang.reflect.Method; /** * Helper methods for generating various launcher icons @@ -157,6 +161,7 @@ public class LauncherIcons { * @param scale the scale to apply before drawing {@param icon} on the canvas */ public static Bitmap createIconBitmap(Drawable icon, Context context, float scale) { + icon = castToMaskableIconDrawable(icon); synchronized (sCanvas) { final int iconBitmapSize = LauncherAppState.getIDP(context).iconBitmapSize; @@ -212,6 +217,19 @@ public class LauncherIcons { } } + static Drawable castToMaskableIconDrawable(Drawable drawable) { + if (!(ProviderConfig.IS_DOGFOOD_BUILD && Utilities.isAtLeastO())) { + return drawable; + } + try { + Class clazz = Class.forName("android.graphics.drawable.MaskableIconDrawable"); + Method method = clazz.getDeclaredMethod("wrap", Drawable.class); + return (Drawable) method.invoke(null, drawable); + } catch (Exception e) { + return drawable; + } + } + /** * 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 |