Merge "Change application launcher icons to adaptive icons b/35429795" into ub-launcher3-dorval

This commit is contained in:
Hyunyoung Song
2017-03-03 21:16:37 +00:00
committed by Android (Google) Code Review
12 changed files with 57 additions and 18 deletions
+1 -1
View File
@@ -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"
+3 -3
View File
@@ -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"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -147,7 +147,7 @@
<activity
android:name="com.android.launcher3.testing.ToggleWeightWatcher"
android:label="Show Mem"
android:icon="@mipmap/ic_launcher_home">
android:icon="@drawable/ic_launcher_home">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -14,9 +14,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<maskable-icon xmlns:android="http://schemas.android.com/apk/res/android">
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:color="#FFE0E0E0"/>
<foreground>
<com.android.launcher3.graphics.FixedScaleDrawable />
</foreground>
</maskable-icon>
</adaptive-icon>
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/icon_background" />
<foreground>
<bitmap android:src="@mipmap/ic_launcher_home_foreground"/>
</foreground>
</adaptive-icon>
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/ic_launcher_home" />
Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 B

+1
View File
@@ -40,4 +40,5 @@
<color name="notification_background_color">#FFF</color>
<color name="notification_color_beneath">#E0E0E0</color> <!-- Gray 300 -->
<color name="divider_color">@color/notification_color_beneath</color>
<color name="icon_background">#E0E0E0</color> <!-- Gray 300 -->
</resources>
@@ -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);
}
@@ -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;
@@ -233,11 +232,11 @@ 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;
}
@@ -245,12 +244,12 @@ public class LauncherIcons {
try {
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;