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

Commit 8b14ffb8 authored by João Victor Mendes Freire's avatar João Victor Mendes Freire
Browse files

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
parent b59b276b
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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;