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

Commit f86d3754 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix user color overlay is not applied"

parents 8dc233b5 213955e5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2462,7 +2462,8 @@ public class ApplicationPackageManager extends PackageManager {
        if (itemInfo.showUserIcon != UserHandle.USER_NULL) {
            Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon);
            if (bitmap == null) {
                return UserIcons.getDefaultUserIcon(itemInfo.showUserIcon, /* light= */ false);
                return UserIcons.getDefaultUserIcon(
                        mContext.getResources(), itemInfo.showUserIcon, /* light= */ false);
            }
            return new BitmapDrawable(bitmap);
        }
+5 −3
Original line number Diff line number Diff line
@@ -61,17 +61,19 @@ public class UserIcons {
     * Returns a default user icon for the given user.
     *
     * Note that for guest users, you should pass in {@code UserHandle.USER_NULL}.
     *
     * @param resources resources object to fetch user icon / color.
     * @param userId the user id or {@code UserHandle.USER_NULL} for a non-user specific icon
     * @param light whether we want a light icon (suitable for a dark background)
     */
    public static Drawable getDefaultUserIcon(int userId, boolean light) {
    public static Drawable getDefaultUserIcon(Resources resources, int userId, boolean light) {
        int colorResId = light ? R.color.user_icon_default_white : R.color.user_icon_default_gray;
        if (userId != UserHandle.USER_NULL) {
            // Return colored icon instead
            colorResId = USER_ICON_COLORS[userId % USER_ICON_COLORS.length];
        }
        Drawable icon = Resources.getSystem().getDrawable(R.drawable.ic_account_circle, null).mutate();
        icon.setColorFilter(Resources.getSystem().getColor(colorResId, null), Mode.SRC_IN);
        Drawable icon = resources.getDrawable(R.drawable.ic_account_circle, null).mutate();
        icon.setColorFilter(resources.getColor(colorResId, null), Mode.SRC_IN);
        icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
        return icon;
    }
+2 −1
Original line number Diff line number Diff line
@@ -105,7 +105,8 @@ public class Utils {
            }
        }
        return new UserIconDrawable(iconSize).setIconDrawable(
                UserIcons.getDefaultUserIcon(user.id, /* light= */ false)).bake();
                UserIcons.getDefaultUserIcon(context.getResources(), user.id, /* light= */ false))
                .bake();
    }

    /** Formats a double from 0.0..100.0 with an option to round **/
+2 −1
Original line number Diff line number Diff line
@@ -64,7 +64,8 @@ public class UserAdapter implements SpinnerAdapter, ListAdapter {
                if (um.getUserIcon(userId) != null) {
                    icon = new BitmapDrawable(context.getResources(), um.getUserIcon(userId));
                } else {
                    icon = UserIcons.getDefaultUserIcon(userId, /* light= */ false);
                    icon = UserIcons.getDefaultUserIcon(
                            context.getResources(), userId, /* light= */ false);
                }
            }
            this.mIcon = encircle(context, icon);
+3 −1
Original line number Diff line number Diff line
@@ -154,7 +154,9 @@ public class UserInfoControllerImpl implements UserInfoController {
                    avatar = new UserIconDrawable(avatarSize)
                            .setIcon(rawAvatar).setBadgeIfManagedUser(mContext, userId).bake();
                } else {
                    avatar = UserIcons.getDefaultUserIcon(isGuest? UserHandle.USER_NULL : userId,
                    avatar = UserIcons.getDefaultUserIcon(
                            context.getResources(),
                            isGuest? UserHandle.USER_NULL : userId,
                            lightIcon);
                }

Loading