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

Commit 43412bcc authored by Oli Lan's avatar Oli Lan
Browse files

Increase default user icon size.

This increases the size of the default user icon to the size specified
by the system (190dp), using the new method added in ag/16847427.

Bug: 218838295
Test: visual inspection
Test: make RunSettingsRoboTests -j40 ROBOTEST_FILTER="com.android.settings.users.UserSettingsTest"
Change-Id: I3d88fbd1e148f0f63c796a272cd5771f4447812d
parent 6e652765
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ public class UserAdapter implements SpinnerAdapter, ListAdapter {
        }

        private static Drawable encircle(Context context, Drawable icon) {
            return new UserIconDrawable(UserIconDrawable.getSizeForList(context))
            return new UserIconDrawable(UserIconDrawable.getDefaultSize(context))
                    .setIconDrawable(icon).bake();
        }
    }
+6 −3
Original line number Diff line number Diff line
@@ -737,7 +737,8 @@ public class UserSettings extends SettingsPreferenceFragment
                    if (newUserIcon != userIcon) {
                        ThreadUtils.postOnBackgroundThread(() ->
                                mUserManager.setUserIcon(user.id,
                                        UserIcons.convertToBitmap(newUserIcon)));
                                        UserIcons.convertToBitmapAtUserIconSize(
                                                activity.getResources(), newUserIcon)));
                        mMePreference.setIcon(newUserIcon);
                    }

@@ -891,7 +892,9 @@ public class UserSettings extends SettingsPreferenceFragment
                if (newUserIcon == null) {
                    newUserIcon = UserIcons.getDefaultUserIcon(getResources(), user.id, false);
                }
                mUserManager.setUserIcon(user.id, UserIcons.convertToBitmap(newUserIcon));
                mUserManager.setUserIcon(
                        user.id, UserIcons.convertToBitmapAtUserIconSize(
                                getResources(), newUserIcon));

                if (mUserType == USER_TYPE_USER) {
                    mHandler.sendEmptyMessage(MESSAGE_UPDATE_LIST);
@@ -1315,7 +1318,7 @@ public class UserSettings extends SettingsPreferenceFragment
        // Try finding the corresponding bitmap in the dark bitmap cache
        bitmap = sDarkDefaultUserBitmapCache.get(userId);
        if (bitmap == null) {
            bitmap = UserIcons.convertToBitmap(
            bitmap = UserIcons.convertToBitmapAtUserIconSize(resources,
                    UserIcons.getDefaultUserIcon(resources, userId, false));
            // Save it to cache
            sDarkDefaultUserBitmapCache.put(userId, bitmap);
+23 −0
Original line number Diff line number Diff line
@@ -193,6 +193,29 @@ public class UserSettingsTest {
        assertThat(UserSettings.assignDefaultPhoto(null, ACTIVE_USER_ID)).isFalse();
    }

    @Test
    public void testAssignDefaultPhoto_hasDefaultUserIconSize() {
        doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
        int size = 100;
        try {
            SettingsShadowResources.overrideResource(
                    com.android.internal.R.dimen.user_icon_size,
                    size);
            assertThat(UserSettings.assignDefaultPhoto(mContext, ACTIVE_USER_ID)).isTrue();

            int pxSize = mContext.getResources()
                    .getDimensionPixelSize(com.android.internal.R.dimen.user_icon_size);

            ArgumentCaptor<Bitmap> captor = ArgumentCaptor.forClass(Bitmap.class);
            verify(mUserManager).setUserIcon(eq(ACTIVE_USER_ID), captor.capture());
            Bitmap bitmap = captor.getValue();
            assertThat(bitmap.getWidth()).isEqualTo(pxSize);
            assertThat(bitmap.getHeight()).isEqualTo(pxSize);
        } finally {
            SettingsShadowResources.reset();
        }
    }

    @Test
    public void testExitGuest_ShouldLogAction() {
        mUserCapabilities.mIsGuest = true;