diff options
author | Tracy Zhou <tracyzhou@google.com> | 2020-05-02 14:26:24 -0700 |
---|---|---|
committer | Tracy Zhou <tracyzhou@google.com> | 2020-05-02 20:39:07 -0700 |
commit | 7d58e08fc49bbb6c4aafa8f2da5981ad61fc3b58 (patch) | |
tree | d1baebc9747858eb7bd6f33b43b286f7f3e5d0aa /packages/SettingsLib/src/com/android/settingslib/Utils.java | |
parent | bc381f5493dab864fd462c985b1d6765b5f254b5 (diff) |
Use adaptive icon in Settings
Fixed the usage of icons in the following pages
- apps info page (https://screenshot.googleplex.com/RLyDQ1PcO7X)
- accounts page (https://screenshot.googleplex.com/VjY87JxrKqZ)
Bug: 130916962
Test: Manual
Change-Id: I3720fab1ce56505c85a175a8f4c550f6f465f507
Diffstat (limited to 'packages/SettingsLib/src/com/android/settingslib/Utils.java')
-rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/Utils.java | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/Utils.java b/packages/SettingsLib/src/com/android/settingslib/Utils.java index eb02a1c8b880..a43412e116c8 100644 --- a/packages/SettingsLib/src/com/android/settingslib/Utils.java +++ b/packages/SettingsLib/src/com/android/settingslib/Utils.java @@ -29,8 +29,6 @@ import android.telephony.AccessNetworkConstants; import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; -import androidx.annotation.NonNull; - import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.UserIcons; import com.android.launcher3.icons.IconFactory; @@ -457,19 +455,21 @@ public class Utils { return state; } - /** - * Get the {@link Drawable} that represents the app icon - */ - public static @NonNull Drawable getBadgedIcon( - @NonNull Context context, @NonNull ApplicationInfo appInfo) { - final UserHandle user = UserHandle.getUserHandleForUid(appInfo.uid); + /** Get the corresponding adaptive icon drawable. */ + public static Drawable getBadgedIcon(Context context, Drawable icon, UserHandle user) { try (IconFactory iconFactory = IconFactory.obtain(context)) { - final Bitmap iconBmp = iconFactory.createBadgedIconBitmap( - appInfo.loadUnbadgedIcon(context.getPackageManager()), user, false).icon; + final Bitmap iconBmp = iconFactory.createBadgedIconBitmap(icon, user, + true /* shrinkNonAdaptiveIcons */).icon; return new BitmapDrawable(context.getResources(), iconBmp); } } + /** Get the {@link Drawable} that represents the app icon */ + public static Drawable getBadgedIcon(Context context, ApplicationInfo appInfo) { + return getBadgedIcon(context, appInfo.loadUnbadgedIcon(context.getPackageManager()), + UserHandle.getUserHandleForUid(appInfo.uid)); + } + private static boolean isNotInIwlan(ServiceState serviceState) { final NetworkRegistrationInfo networkRegWlan = serviceState.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, |