summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2017-03-03 11:14:05 -0800
committerHyunyoung Song <hyunyoungs@google.com>2017-03-03 12:48:05 -0800
commit837eb1f47d868e22358ba7c12a4771882965be27 (patch)
tree4c192ee31bb8cc6541c46fdc8565d9c1d16d8307
parent9407d4ab57a0c3500647f1f5f9a9a44b51d222b4 (diff)
downloadandroid_packages_apps_Trebuchet-837eb1f47d868e22358ba7c12a4771882965be27.tar.gz
android_packages_apps_Trebuchet-837eb1f47d868e22358ba7c12a4771882965be27.tar.bz2
android_packages_apps_Trebuchet-837eb1f47d868e22358ba7c12a4771882965be27.zip
Change application launcher icons to adaptive icons
b/35429795 Change-Id: I4fa2fb167040c2470c403a293d1a172c276b2f81
-rw-r--r--AndroidManifest-common.xml2
-rw-r--r--AndroidManifest.xml6
-rw-r--r--res/drawable-v26/adaptive_icon_drawable_wrapper.xml (renamed from res/drawable-v26/mask_drawable_wrapper.xml)4
-rw-r--r--res/drawable-v26/ic_launcher_home.xml21
-rw-r--r--res/drawable/ic_launcher_home.xml18
-rw-r--r--res/mipmap-hdpi/ic_launcher_home_foreground.pngbin0 -> 236 bytes
-rw-r--r--res/mipmap-mdpi/ic_launcher_home_foreground.pngbin0 -> 339 bytes
-rw-r--r--res/mipmap-xhdpi/ic_launcher_home_foreground.pngbin0 -> 357 bytes
-rw-r--r--res/mipmap-xxhdpi/ic_launcher_home_foreground.pngbin0 -> 485 bytes
-rw-r--r--res/values/colors.xml1
-rw-r--r--src/com/android/launcher3/graphics/DrawableFactory.java6
-rw-r--r--src/com/android/launcher3/graphics/LauncherIcons.java19
12 files changed, 58 insertions, 19 deletions
diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml
index 86ae73e6e..da1679f7f 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 3b721ab57..bcb522b21 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"
>
<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" />
diff --git a/res/drawable-v26/mask_drawable_wrapper.xml b/res/drawable-v26/adaptive_icon_drawable_wrapper.xml
index 36efd0f95..7ad8e2c64 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.
-->
-<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>
diff --git a/res/drawable-v26/ic_launcher_home.xml b/res/drawable-v26/ic_launcher_home.xml
new file mode 100644
index 000000000..7038775f3
--- /dev/null
+++ b/res/drawable-v26/ic_launcher_home.xml
@@ -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>
diff --git a/res/drawable/ic_launcher_home.xml b/res/drawable/ic_launcher_home.xml
new file mode 100644
index 000000000..a6f251995
--- /dev/null
+++ b/res/drawable/ic_launcher_home.xml
@@ -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" />
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 000000000..d068d9236
--- /dev/null
+++ b/res/mipmap-hdpi/ic_launcher_home_foreground.png
Binary files differ
diff --git a/res/mipmap-mdpi/ic_launcher_home_foreground.png b/res/mipmap-mdpi/ic_launcher_home_foreground.png
new file mode 100644
index 000000000..0ed9f4d81
--- /dev/null
+++ b/res/mipmap-mdpi/ic_launcher_home_foreground.png
Binary files differ
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 000000000..7a9daf5bf
--- /dev/null
+++ b/res/mipmap-xhdpi/ic_launcher_home_foreground.png
Binary files differ
diff --git a/res/mipmap-xxhdpi/ic_launcher_home_foreground.png b/res/mipmap-xxhdpi/ic_launcher_home_foreground.png
new file mode 100644
index 000000000..03b493e4a
--- /dev/null
+++ b/res/mipmap-xxhdpi/ic_launcher_home_foreground.png
Binary files differ
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 68f009295..83a44d7b9 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -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>
diff --git a/src/com/android/launcher3/graphics/DrawableFactory.java b/src/com/android/launcher3/graphics/DrawableFactory.java
index 8b207bb0c..60bbce406 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 1a50dfe14..439205b46 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;