Fix user avatar not being set on rotation
This commit fixes the issue where the user avatar was not being colored (using only the gray one) when the device was rotated. Additionally, it fixes a race condition issue of the avatar color sometimes being different than the selected one. Bug: 261035066 Test: manually tested && atest UserSettingsComponentTest Change-Id: I739fa8fd5d8717b602d7ba561d9c728ce622ff10
This commit is contained in:
@@ -1021,6 +1021,8 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
@VisibleForTesting
|
||||
void createUser(final int userType, String userName) {
|
||||
Context context = getContext();
|
||||
Resources resources = getResources();
|
||||
final Drawable selectedUserIcon = mPendingUserIcon;
|
||||
Future<?> unusedCreateUserFuture = ThreadUtils.postOnBackgroundThread(() -> {
|
||||
UserInfo user;
|
||||
|
||||
@@ -1043,13 +1045,13 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
Future<?> unusedSettingIconFuture = ThreadUtils.postOnBackgroundThread(() -> {
|
||||
Drawable newUserIcon = mPendingUserIcon;
|
||||
Drawable newUserIcon = selectedUserIcon;
|
||||
if (newUserIcon == null) {
|
||||
newUserIcon = UserIcons.getDefaultUserIcon(getResources(), user.id, false);
|
||||
newUserIcon = UserIcons.getDefaultUserIcon(resources, user.id, false);
|
||||
}
|
||||
mUserManager.setUserIcon(
|
||||
user.id, UserIcons.convertToBitmapAtUserIconSize(
|
||||
getResources(), newUserIcon));
|
||||
resources, newUserIcon));
|
||||
});
|
||||
|
||||
mPendingUserIcon = null;
|
||||
|
Reference in New Issue
Block a user