commit | 72542b6058424b9055f747a2a0d94e9a9b927a9f | [log] [tgz] |
---|---|---|
author | Brandon Dayauon <brdayauon@google.com> | Tue Jan 16 09:27:53 2024 -0800 |
committer | Brandon Dayauon <brdayauon@google.com> | Wed Jan 31 15:54:30 2024 -0800 |
tree | 6fe4a4c0e42d1cc5ac8d85a8bccbf944495769b4 | |
parent | 99cfd0905ba3bf8b3437af829fad53a929ed5112 [diff] |
Add Utility method in userCache to get badgeDrawables - In userCache, create a utility method to get badgeDrawables via userHandle. As of this moment, this is used in Toast. Bug: 312898415 Test: Manual photos: before 0-state: https://drive.google.com/file/d/15OUcd8i1IoUU0BgMlZj-8e0YWsmtzY4E/view?usp=sharing after 0-state: https://drive.google.com/file/d/15SH19xvdLzQt1QbHY2oAxPAFVXPZDchF/view?usp=sharing before textHeader: https://drive.google.com/file/d/15OLpN2SNF9QNWMrs0Aos5fS-l39Op-wo/view?usp=sharing after textHeader: https://drive.google.com/file/d/15PIi-K6FfdCtPwWg2GEP9SUE5ow2YXJ5/view?usp=sharing Flags: None Change-Id: Ia6f89e634cc0af47cae91add6ea62d3af452c441
diff --git a/src/com/android/launcher3/pm/UserCache.java b/src/com/android/launcher3/pm/UserCache.java index 8708d5a..032de31 100644 --- a/src/com/android/launcher3/pm/UserCache.java +++ b/src/com/android/launcher3/pm/UserCache.java
@@ -28,9 +28,13 @@ import androidx.annotation.AnyThread; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.annotation.WorkerThread; +import com.android.launcher3.icons.BitmapInfo; +import com.android.launcher3.icons.UserBadgeDrawable; +import com.android.launcher3.util.FlagOp; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.SafeCloseable; import com.android.launcher3.util.SimpleBroadcastReceiver; @@ -166,4 +170,14 @@ public List<UserHandle> getUserProfiles() { return List.copyOf(mUserToSerialMap.keySet()); } + + /** + * Get a non-themed {@link UserBadgeDrawable} based on the provided {@link UserHandle}. + */ + @Nullable + public static UserBadgeDrawable getBadgeDrawable(Context context, UserHandle userHandle) { + return (UserBadgeDrawable) BitmapInfo.LOW_RES_INFO.withFlags(UserCache.getInstance(context) + .getUserInfo(userHandle).applyBitmapInfoFlags(FlagOp.NO_OP)) + .getBadgeDrawable(context, false /* isThemed */); + } }