From 837eb1f47d868e22358ba7c12a4771882965be27 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Fri, 3 Mar 2017 11:14:05 -0800 Subject: [PATCH] Change application launcher icons to adaptive icons b/35429795 Change-Id: I4fa2fb167040c2470c403a293d1a172c276b2f81 --- AndroidManifest-common.xml | 2 +- AndroidManifest.xml | 6 ++--- ...xml => adaptive_icon_drawable_wrapper.xml} | 4 ++-- res/drawable-v26/ic_launcher_home.xml | 21 ++++++++++++++++++ res/drawable/ic_launcher_home.xml | 18 +++++++++++++++ .../ic_launcher_home_foreground.png | Bin 0 -> 236 bytes .../ic_launcher_home_foreground.png | Bin 0 -> 339 bytes .../ic_launcher_home_foreground.png | Bin 0 -> 357 bytes .../ic_launcher_home_foreground.png | Bin 0 -> 485 bytes res/values/colors.xml | 1 + .../launcher3/graphics/DrawableFactory.java | 6 ++--- .../launcher3/graphics/LauncherIcons.java | 19 ++++++++-------- 12 files changed, 58 insertions(+), 19 deletions(-) rename res/drawable-v26/{mask_drawable_wrapper.xml => adaptive_icon_drawable_wrapper.xml} (91%) create mode 100644 res/drawable-v26/ic_launcher_home.xml create mode 100644 res/drawable/ic_launcher_home.xml create mode 100644 res/mipmap-hdpi/ic_launcher_home_foreground.png create mode 100644 res/mipmap-mdpi/ic_launcher_home_foreground.png create mode 100644 res/mipmap-xhdpi/ic_launcher_home_foreground.png create mode 100644 res/mipmap-xxhdpi/ic_launcher_home_foreground.png diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml index 86ae73e6ee..da1679f7fb 100644 --- a/AndroidManifest-common.xml +++ b/AndroidManifest-common.xml @@ -49,7 +49,7 @@ android:fullBackupOnly="true" android:fullBackupContent="@xml/backupscheme" android:hardwareAccelerated="true" - android:icon="@mipmap/ic_launcher_home" + android:icon="@drawable/ic_launcher_home" android:label="@string/derived_app_name" android:largeHeap="@bool/config_largeHeap" android:restoreAnyVersion="true" diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 3b721ab576..bcb522b21f 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -54,7 +54,7 @@ android:fullBackupOnly="true" android:fullBackupContent="@xml/backupscheme" android:hardwareAccelerated="true" - android:icon="@mipmap/ic_launcher_home" + android:icon="@drawable/ic_launcher_home" android:label="@string/derived_app_name" android:theme="@style/LauncherTheme" android:largeHeap="@bool/config_largeHeap" @@ -135,7 +135,7 @@ android:theme="@android:style/Theme.NoDisplay" android:label="* HPROF" android:excludeFromRecents="true" - android:icon="@mipmap/ic_launcher_home" + android:icon="@drawable/ic_launcher_home" > @@ -147,7 +147,7 @@ + android:icon="@drawable/ic_launcher_home"> diff --git a/res/drawable-v26/mask_drawable_wrapper.xml b/res/drawable-v26/adaptive_icon_drawable_wrapper.xml similarity index 91% rename from res/drawable-v26/mask_drawable_wrapper.xml rename to res/drawable-v26/adaptive_icon_drawable_wrapper.xml index 36efd0f952..7ad8e2c64e 100644 --- a/res/drawable-v26/mask_drawable_wrapper.xml +++ b/res/drawable-v26/adaptive_icon_drawable_wrapper.xml @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. --> - + - + diff --git a/res/drawable-v26/ic_launcher_home.xml b/res/drawable-v26/ic_launcher_home.xml new file mode 100644 index 0000000000..7038775f35 --- /dev/null +++ b/res/drawable-v26/ic_launcher_home.xml @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/res/drawable/ic_launcher_home.xml b/res/drawable/ic_launcher_home.xml new file mode 100644 index 0000000000..a6f2519954 --- /dev/null +++ b/res/drawable/ic_launcher_home.xml @@ -0,0 +1,18 @@ + + + diff --git a/res/mipmap-hdpi/ic_launcher_home_foreground.png b/res/mipmap-hdpi/ic_launcher_home_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..d068d92361a06550fb1bcdf36fbc4bf56242d54e GIT binary patch literal 236 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~M1W6-E06|){rmU-|Ns9C14G(O z28NkujJG~Lkd;*dlwd3g@(X5gcy=QV$Z7I)aSW-r_4dL>z6Jx1mc(q=`~Q1QL!@ST zvx^@#{d2kXq4bSSI^01QuQhjd%Q~fAzm?V=urg{pU$2PM(daz_S{a5;E6(U}afk}8 z47;BZ=_^mIV0)GdMiEkp|)RiyD=97dKdZ~+#mp}YjODMbT4y&m-1Kwk zs;o4_{A;D|dvy4tqi=NS2y8yS;Y@!)q~)2mO5QNB!)BWM?kz8p3ozsHewR|Vqvi99 zJ*y)3gs%Oy>dfZZyT9F>U0J$W<9V9(*;6@h?yX8czb!Fslh0HA_L)b`((b3|JEXd} dxa==vU$tP>xMf?fas literal 0 HcmV?d00001 diff --git a/res/mipmap-xhdpi/ic_launcher_home_foreground.png b/res/mipmap-xhdpi/ic_launcher_home_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..7a9daf5bfe7a5fcfdf7e772dfe5300373d287389 GIT binary patch literal 357 zcmeAS@N?(olHy`uVBq!ia0vp^H$a$$8Aw+18QcR>5&=FTu89Re7Q_Di`~Uy{e};h} zZ6*W5%rnMYpU#(h6>z%lIY|YAUQU0NY;fac#C+D~xgEa81XjO0n2>r&b=sb6 z9=7aeTkoCh&8CO9Et$&ReD&Bp@72Fdh=keOM~z{;U~;(nkWH%}MGkcwMx?>J^PJ213eWT|Rc;>$1K&40mb z)44_F8kUX<;wKhe&*wh3KyqtSr{BZ9OS$TH%ZtY70L?=J5*a(!tx@rsq7nGW-XlgG z%u3qVSr{VMeadY6%!wL-i(EQ&7Yn`WGRin}=CJ!y1(1Nyb8jE_r%U&I6I*xF1E_b= zk(t8PZmOdC)4=LKtMExq-Bg_xCZq~9x$x4FV=MN^)tgwAot)SQH8NPGtmo9mcg9=Z zoWJfTe5MCzrm9zt<#~t?uJ7bNI^lK%s3qdvm-8H)=NY)XoC+**TXC#j^Ff{zEVRl>T U{kpq~Z7)c|)78&qol`;+0B9eraR2}S literal 0 HcmV?d00001 diff --git a/res/values/colors.xml b/res/values/colors.xml index 68f0092951..83a44d7b9a 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -40,4 +40,5 @@ #FFF #E0E0E0 @color/notification_color_beneath + #E0E0E0 diff --git a/src/com/android/launcher3/graphics/DrawableFactory.java b/src/com/android/launcher3/graphics/DrawableFactory.java index 8b207bb0cd..60bbce4066 100644 --- a/src/com/android/launcher3/graphics/DrawableFactory.java +++ b/src/com/android/launcher3/graphics/DrawableFactory.java @@ -85,10 +85,10 @@ public class DrawableFactory { if (Utilities.isAtLeastO()) { try { // Try to load the path from Mask Icon - Drawable maskIcon = context.getDrawable(R.drawable.mask_drawable_wrapper); - maskIcon.setBounds(0, 0, + Drawable icon = context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper); + icon.setBounds(0, 0, PreloadIconDrawable.PATH_SIZE, PreloadIconDrawable.PATH_SIZE); - return (Path) maskIcon.getClass().getMethod("getIconMask").invoke(maskIcon); + return (Path) icon.getClass().getMethod("getIconMask").invoke(icon); } catch (Exception e) { Log.e(TAG, "Error loading mask icon", e); } diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java index 1a50dfe14a..439205b46c 100644 --- a/src/com/android/launcher3/graphics/LauncherIcons.java +++ b/src/com/android/launcher3/graphics/LauncherIcons.java @@ -40,7 +40,6 @@ 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 com.android.launcher3.model.PackageItemInfo; import com.android.launcher3.shortcuts.DeepShortcutManager; import com.android.launcher3.shortcuts.ShortcutInfoCompat; @@ -166,7 +165,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 = wrapToMaskableIconDrawable(context, icon); + icon = wrapToAdaptiveIconDrawable(context, icon); synchronized (sCanvas) { final int iconBitmapSize = LauncherAppState.getIDP(context).iconBitmapSize; @@ -223,24 +222,24 @@ public class LauncherIcons { } /** - * If the platform is running O but the app is not providing MaskableIconDrawable, then + * If the platform is running O but the app is not providing AdaptiveIconDrawable, then * shrink the legacy icon and set it as foreground. Use color drawable as background to - * create MaskableIconDrawable. + * create AdaptiveIconDrawable. */ - static Drawable wrapToMaskableIconDrawable(Context context, Drawable drawable) { + static Drawable wrapToAdaptiveIconDrawable(Context context, Drawable drawable) { if (!(FeatureFlags.LEGACY_ICON_TREATMENT && Utilities.isAtLeastO())) { return drawable; } try { - Class clazz = Class.forName("android.graphics.drawable.MaskableIconDrawable"); + Class clazz = Class.forName("android.graphics.drawable.AdaptiveIconDrawable"); if (!clazz.isAssignableFrom(drawable.getClass())) { - Drawable maskWrapper = - context.getDrawable(R.drawable.mask_drawable_wrapper).mutate(); - ((FixedScaleDrawable) clazz.getMethod("getForeground").invoke(maskWrapper)) + Drawable iconWrapper = + context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate(); + ((FixedScaleDrawable) clazz.getMethod("getForeground").invoke(iconWrapper)) .setDrawable(drawable); - return maskWrapper; + return iconWrapper; } } catch (Exception e) { return drawable;