Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 491c34e7 authored by Himanshu Gupta's avatar Himanshu Gupta
Browse files

Clone profile badge resolution in settings.

Adds the mechanism to allow iconLoader library resolve badges for
clone profile alongside work profile.

Bug: 266177840
Test: Manually flashing and checking settings.
Change-Id: I8c5814d165a440574d3728cb552d48af07901a86
parent fcc74c31
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -575,9 +575,15 @@ public class Utils {


    /** Get the corresponding adaptive icon drawable. */
    /** Get the corresponding adaptive icon drawable. */
    public static Drawable getBadgedIcon(Context context, Drawable icon, UserHandle user) {
    public static Drawable getBadgedIcon(Context context, Drawable icon, UserHandle user) {
        UserManager um = context.getSystemService(UserManager.class);
        boolean isClone = um.getProfiles(user.getIdentifier()).stream()
                .anyMatch(profile ->
                        profile.isCloneProfile() && profile.id == user.getIdentifier());
        try (IconFactory iconFactory = IconFactory.obtain(context)) {
        try (IconFactory iconFactory = IconFactory.obtain(context)) {
            return iconFactory
            return iconFactory
                    .createBadgedIconBitmap(icon, new IconOptions().setUser(user))
                    .createBadgedIconBitmap(
                            icon,
                            new IconOptions().setUser(user).setIsCloneProfile(isClone))
                    .newIcon(context);
                    .newIcon(context);
        }
        }
    }
    }