Loading res/drawable/ic_instant_app_badge.xml 0 → 100644 +43 −0 Original line number Diff line number Diff line <?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. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="@dimen/profile_badge_size" android:height="@dimen/profile_badge_size" android:viewportWidth="18" android:viewportHeight="18"> <path android:fillColor="@android:color/black" android:fillType="evenOdd" android:strokeWidth="1" android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" /> <path android:fillColor="@android:color/white" android:fillType="evenOdd" android:strokeWidth="1" android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" /> <path android:fillColor="@android:color/white" android:fillType="evenOdd" android:strokeWidth="1" android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" /> <path android:fillColor="@android:color/black" android:fillAlpha="0.87" android:fillType="evenOdd" android:strokeWidth="1" android:pathData="M 6 10.4123279 L 8.63934949 10.4123279 L 8.63934949 15.6 L 12.5577168 7.84517705 L 9.94547194 7.84517705 L 9.94547194 2 Z" /> </vector> No newline at end of file res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,9 @@ <!-- Name of a color extraction implementation class. --> <string name="color_extraction_impl_class" translatable="false"></string> <!-- Name of a subclass of com.android.launcher3.util.InstantAppResolver. Can be empty. --> <string name="instant_app_resolver_class" translatable="false"></string> <!-- Package name of the default wallpaper picker. --> <string name="wallpaper_picker_package" translatable="false"></string> Loading src/com/android/launcher3/IconCache.java +10 −7 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.graphics.LauncherIcons; import com.android.launcher3.model.PackageItemInfo; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.InstantAppResolver; import com.android.launcher3.util.Preconditions; import com.android.launcher3.util.Provider; import com.android.launcher3.util.SQLiteCacheHelper; Loading Loading @@ -94,6 +95,7 @@ public class IconCache { private final LauncherAppsCompat mLauncherApps; private final HashMap<ComponentKey, CacheEntry> mCache = new HashMap<>(INITIAL_ICON_CACHE_CAPACITY); private final InstantAppResolver mInstantAppResolver; private final int mIconDpi; @Thunk final IconDB mIconDb; Loading @@ -106,6 +108,7 @@ public class IconCache { mPackageManager = context.getPackageManager(); mUserManager = UserManagerCompat.getInstance(mContext); mLauncherApps = LauncherAppsCompat.getInstance(mContext); mInstantAppResolver = InstantAppResolver.newInstance(mContext); mIconDpi = inv.fillResIconDpi; mIconDb = new IconDB(context, inv.iconBitmapSize); Loading Loading @@ -478,12 +481,6 @@ public class IconCache { } private void applyCacheEntry(CacheEntry entry, ItemInfoWithIcon info) { if (info instanceof ShortcutInfo && ((ShortcutInfo) info).hasStatusFlag(ShortcutInfo.FLAG_SUPPORTS_WEB_UI) && (entry.icon == null || isDefaultIcon(entry.icon, info.user))) { // skip updating shortcut info if no icon and supports web ui return; } info.title = Utilities.trim(entry.title); info.contentDescription = entry.contentDescription; info.iconBitmap = entry.icon == null ? getDefaultIcon(info.user) : entry.icon; Loading Loading @@ -581,7 +578,6 @@ public class IconCache { // For icon caching, do not go through DB. Just update the in-memory entry. if (entry == null) { entry = new CacheEntry(); mCache.put(cacheKey, entry); } if (!TextUtils.isEmpty(title)) { entry.title = title; Loading @@ -589,6 +585,9 @@ public class IconCache { if (icon != null) { entry.icon = LauncherIcons.createIconBitmap(icon, mContext); } if (!TextUtils.isEmpty(title) && entry.icon != null) { mCache.put(cacheKey, entry); } } private static ComponentKey getPackageKey(String packageName, UserHandle user) { Loading Loading @@ -625,6 +624,10 @@ public class IconCache { // only keep the low resolution icon instead of the larger full-sized icon Bitmap icon = LauncherIcons.createBadgedIconBitmap( appInfo.loadIcon(mPackageManager), user, mContext, appInfo.targetSdkVersion); if (mInstantAppResolver.isInstantApp(appInfo)) { icon = LauncherIcons.badgeWithDrawable(icon, mContext.getDrawable(R.drawable.ic_instant_app_badge), mContext); } Bitmap lowResIcon = generateLowResIcon(icon); entry.title = appInfo.loadLabel(mPackageManager); entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user); Loading src/com/android/launcher3/model/CacheDataUpdatedTask.java +1 −1 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public class CacheDataUpdatedTask extends BaseModelUpdateTask { case OP_CACHE_UPDATE: return true; case OP_SESSION_UPDATE: return si.isPromise(); return si.hasPromiseIconUi(); default: return false; } Loading src/com/android/launcher3/model/PackageInstallStateChangedTask.java +15 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.launcher3.model; import android.content.ComponentName; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.os.Process; import com.android.launcher3.AllAppsList; import com.android.launcher3.AppInfo; Loading @@ -28,6 +31,7 @@ import com.android.launcher3.PromiseAppInfo; import com.android.launcher3.ShortcutInfo; import com.android.launcher3.compat.PackageInstallerCompat; import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo; import com.android.launcher3.util.InstantAppResolver; import java.util.ArrayList; import java.util.HashSet; Loading @@ -46,6 +50,17 @@ public class PackageInstallStateChangedTask extends BaseModelUpdateTask { @Override public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) { if (mInstallInfo.state == PackageInstallerCompat.STATUS_INSTALLED) { try { // For instant apps we do not get package-add. Use setting events to update // any pinned icons. ApplicationInfo ai = app.getContext() .getPackageManager().getApplicationInfo(mInstallInfo.packageName, 0); if (InstantAppResolver.newInstance(app.getContext()).isInstantApp(ai)) { app.getModel().onPackageAdded(ai.packageName, Process.myUserHandle()); } } catch (PackageManager.NameNotFoundException e) { // Ignore } // Ignore install success events as they are handled by Package add events. return; } Loading Loading
res/drawable/ic_instant_app_badge.xml 0 → 100644 +43 −0 Original line number Diff line number Diff line <?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. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="@dimen/profile_badge_size" android:height="@dimen/profile_badge_size" android:viewportWidth="18" android:viewportHeight="18"> <path android:fillColor="@android:color/black" android:fillType="evenOdd" android:strokeWidth="1" android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" /> <path android:fillColor="@android:color/white" android:fillType="evenOdd" android:strokeWidth="1" android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" /> <path android:fillColor="@android:color/white" android:fillType="evenOdd" android:strokeWidth="1" android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" /> <path android:fillColor="@android:color/black" android:fillAlpha="0.87" android:fillType="evenOdd" android:strokeWidth="1" android:pathData="M 6 10.4123279 L 8.63934949 10.4123279 L 8.63934949 15.6 L 12.5577168 7.84517705 L 9.94547194 7.84517705 L 9.94547194 2 Z" /> </vector> No newline at end of file
res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,9 @@ <!-- Name of a color extraction implementation class. --> <string name="color_extraction_impl_class" translatable="false"></string> <!-- Name of a subclass of com.android.launcher3.util.InstantAppResolver. Can be empty. --> <string name="instant_app_resolver_class" translatable="false"></string> <!-- Package name of the default wallpaper picker. --> <string name="wallpaper_picker_package" translatable="false"></string> Loading
src/com/android/launcher3/IconCache.java +10 −7 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.graphics.LauncherIcons; import com.android.launcher3.model.PackageItemInfo; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.InstantAppResolver; import com.android.launcher3.util.Preconditions; import com.android.launcher3.util.Provider; import com.android.launcher3.util.SQLiteCacheHelper; Loading Loading @@ -94,6 +95,7 @@ public class IconCache { private final LauncherAppsCompat mLauncherApps; private final HashMap<ComponentKey, CacheEntry> mCache = new HashMap<>(INITIAL_ICON_CACHE_CAPACITY); private final InstantAppResolver mInstantAppResolver; private final int mIconDpi; @Thunk final IconDB mIconDb; Loading @@ -106,6 +108,7 @@ public class IconCache { mPackageManager = context.getPackageManager(); mUserManager = UserManagerCompat.getInstance(mContext); mLauncherApps = LauncherAppsCompat.getInstance(mContext); mInstantAppResolver = InstantAppResolver.newInstance(mContext); mIconDpi = inv.fillResIconDpi; mIconDb = new IconDB(context, inv.iconBitmapSize); Loading Loading @@ -478,12 +481,6 @@ public class IconCache { } private void applyCacheEntry(CacheEntry entry, ItemInfoWithIcon info) { if (info instanceof ShortcutInfo && ((ShortcutInfo) info).hasStatusFlag(ShortcutInfo.FLAG_SUPPORTS_WEB_UI) && (entry.icon == null || isDefaultIcon(entry.icon, info.user))) { // skip updating shortcut info if no icon and supports web ui return; } info.title = Utilities.trim(entry.title); info.contentDescription = entry.contentDescription; info.iconBitmap = entry.icon == null ? getDefaultIcon(info.user) : entry.icon; Loading Loading @@ -581,7 +578,6 @@ public class IconCache { // For icon caching, do not go through DB. Just update the in-memory entry. if (entry == null) { entry = new CacheEntry(); mCache.put(cacheKey, entry); } if (!TextUtils.isEmpty(title)) { entry.title = title; Loading @@ -589,6 +585,9 @@ public class IconCache { if (icon != null) { entry.icon = LauncherIcons.createIconBitmap(icon, mContext); } if (!TextUtils.isEmpty(title) && entry.icon != null) { mCache.put(cacheKey, entry); } } private static ComponentKey getPackageKey(String packageName, UserHandle user) { Loading Loading @@ -625,6 +624,10 @@ public class IconCache { // only keep the low resolution icon instead of the larger full-sized icon Bitmap icon = LauncherIcons.createBadgedIconBitmap( appInfo.loadIcon(mPackageManager), user, mContext, appInfo.targetSdkVersion); if (mInstantAppResolver.isInstantApp(appInfo)) { icon = LauncherIcons.badgeWithDrawable(icon, mContext.getDrawable(R.drawable.ic_instant_app_badge), mContext); } Bitmap lowResIcon = generateLowResIcon(icon); entry.title = appInfo.loadLabel(mPackageManager); entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user); Loading
src/com/android/launcher3/model/CacheDataUpdatedTask.java +1 −1 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public class CacheDataUpdatedTask extends BaseModelUpdateTask { case OP_CACHE_UPDATE: return true; case OP_SESSION_UPDATE: return si.isPromise(); return si.hasPromiseIconUi(); default: return false; } Loading
src/com/android/launcher3/model/PackageInstallStateChangedTask.java +15 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.launcher3.model; import android.content.ComponentName; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.os.Process; import com.android.launcher3.AllAppsList; import com.android.launcher3.AppInfo; Loading @@ -28,6 +31,7 @@ import com.android.launcher3.PromiseAppInfo; import com.android.launcher3.ShortcutInfo; import com.android.launcher3.compat.PackageInstallerCompat; import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo; import com.android.launcher3.util.InstantAppResolver; import java.util.ArrayList; import java.util.HashSet; Loading @@ -46,6 +50,17 @@ public class PackageInstallStateChangedTask extends BaseModelUpdateTask { @Override public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) { if (mInstallInfo.state == PackageInstallerCompat.STATUS_INSTALLED) { try { // For instant apps we do not get package-add. Use setting events to update // any pinned icons. ApplicationInfo ai = app.getContext() .getPackageManager().getApplicationInfo(mInstallInfo.packageName, 0); if (InstantAppResolver.newInstance(app.getContext()).isInstantApp(ai)) { app.getModel().onPackageAdded(ai.packageName, Process.myUserHandle()); } } catch (PackageManager.NameNotFoundException e) { // Ignore } // Ignore install success events as they are handled by Package add events. return; } Loading