Update the usage of getDefaultUserIcon

getDefaultUserIcon now takes resources as parameter for the sake of
resource overlaying.

BUG=69355037
Test: Factory reset and go to settings -> User, observe the new color.

Change-Id: I504acf00c4616c342d2b8e99b061e4043b34c378
This commit is contained in:
Tony Mak
2017-11-23 16:58:20 +08:00
parent a40f6a2a45
commit 0ba8f51605

View File

@@ -923,7 +923,7 @@ public class UserSettings extends SettingsPreferenceFragment
for (int userId : values[0]) { for (int userId : values[0]) {
Bitmap bitmap = mUserManager.getUserIcon(userId); Bitmap bitmap = mUserManager.getUserIcon(userId);
if (bitmap == null) { if (bitmap == null) {
bitmap = getDefaultUserIconAsBitmap(userId); bitmap = getDefaultUserIconAsBitmap(getContext().getResources(), userId);
} }
mUserIcons.append(userId, bitmap); mUserIcons.append(userId, bitmap);
} }
@@ -934,7 +934,8 @@ public class UserSettings extends SettingsPreferenceFragment
private Drawable getEncircledDefaultIcon() { private Drawable getEncircledDefaultIcon() {
if (mDefaultIconDrawable == null) { if (mDefaultIconDrawable == null) {
mDefaultIconDrawable = encircle(getDefaultUserIconAsBitmap(UserHandle.USER_NULL)); mDefaultIconDrawable = encircle(
getDefaultUserIconAsBitmap(getContext().getResources(), UserHandle.USER_NULL));
} }
return mDefaultIconDrawable; return mDefaultIconDrawable;
} }
@@ -1038,14 +1039,16 @@ public class UserSettings extends SettingsPreferenceFragment
* Returns a default user icon (as a {@link Bitmap}) for the given user. * Returns a default user icon (as a {@link Bitmap}) for the given user.
* *
* Note that for guest users, you should pass in {@code UserHandle.USER_NULL}. * Note that for guest users, you should pass in {@code UserHandle.USER_NULL}.
* @param resources resources object to fetch the user icon.
* @param userId the user id or {@code UserHandle.USER_NULL} for a non-user specific icon * @param userId the user id or {@code UserHandle.USER_NULL} for a non-user specific icon
*/ */
private static Bitmap getDefaultUserIconAsBitmap(int userId) { private static Bitmap getDefaultUserIconAsBitmap(Resources resources, int userId) {
Bitmap bitmap = null; Bitmap bitmap = null;
// Try finding the corresponding bitmap in the dark bitmap cache // Try finding the corresponding bitmap in the dark bitmap cache
bitmap = sDarkDefaultUserBitmapCache.get(userId); bitmap = sDarkDefaultUserBitmapCache.get(userId);
if (bitmap == null) { if (bitmap == null) {
bitmap = UserIcons.convertToBitmap(UserIcons.getDefaultUserIcon(userId, false)); bitmap = UserIcons.convertToBitmap(
UserIcons.getDefaultUserIcon(resources, userId, false));
// Save it to cache // Save it to cache
sDarkDefaultUserBitmapCache.put(userId, bitmap); sDarkDefaultUserBitmapCache.put(userId, bitmap);
} }
@@ -1064,7 +1067,7 @@ public class UserSettings extends SettingsPreferenceFragment
return false; return false;
} }
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
Bitmap bitmap = getDefaultUserIconAsBitmap(userId); Bitmap bitmap = getDefaultUserIconAsBitmap(context.getResources(), userId);
um.setUserIcon(userId, bitmap); um.setUserIcon(userId, bitmap);
return true; return true;