Fix the Ephemeral guest mode UI bugs

- Update the user-icon size to 40dp to align with add-icon size
- Remove the guestInfo preference and add the infoText as the summary for the guestExit preference and fix UserSettingsTest

Bug: 231592331
Test: Manual test, atest SettingsRoboTests
Change-Id: I2591bc19a7b2381d1842f0b28ab8fa19c15c19b8
(cherry picked from commit 9cf1d188a2)
This commit is contained in:
Avinash Vadlamudi
2022-05-24 07:11:32 +00:00
parent 539565473e
commit d23aba7042
5 changed files with 16 additions and 47 deletions

View File

@@ -130,7 +130,6 @@ public class UserSettings extends SettingsPreferenceFragment
private static final String KEY_GUEST_CATEGORY = "guest_category";
private static final String KEY_GUEST_RESET = "guest_reset";
private static final String KEY_GUEST_EXIT = "guest_exit";
private static final String KEY_GUEST_INFO = "guest_info";
private static final String KEY_REMOVE_GUEST_ON_EXIT = "remove_guest_on_exit";
private static final String KEY_GUEST_USER_CATEGORY = "guest_user_category";
@@ -189,8 +188,6 @@ public class UserSettings extends SettingsPreferenceFragment
@VisibleForTesting
Preference mGuestExitPreference;
@VisibleForTesting
Preference mGuestInfoPreference;
@VisibleForTesting
UserPreference mMePreference;
@VisibleForTesting
RestrictedPreference mAddGuest;
@@ -356,8 +353,6 @@ public class UserSettings extends SettingsPreferenceFragment
mGuestExitPreference = findPreference(KEY_GUEST_EXIT);
mGuestExitPreference.setOnPreferenceClickListener(this);
mGuestInfoPreference = findPreference(KEY_GUEST_INFO);
mGuestUserCategory = findPreference(KEY_GUEST_USER_CATEGORY);
mAddGuest = findPreference(KEY_ADD_GUEST);
@@ -1345,7 +1340,6 @@ public class UserSettings extends SettingsPreferenceFragment
mGuestCategory.setVisible(false);
mGuestResetPreference.setVisible(false);
mGuestExitPreference.setVisible(false);
mGuestInfoPreference.setVisible(false);
if (!isCurrentUserGuest()) {
return;
}
@@ -1353,25 +1347,24 @@ public class UserSettings extends SettingsPreferenceFragment
mGuestExitPreference.setVisible(true);
if (isEnableGuestModeUxChanges()) {
mGuestResetPreference.setVisible(true);
mGuestInfoPreference.setVisible(true);
boolean isGuestFirstLogin = Settings.Secure.getIntForUser(
getContext().getContentResolver(),
SETTING_GUEST_HAS_LOGGED_IN,
0,
UserHandle.myUserId()) <= 1;
String guestInfoText;
String guestExitSummary;
if (mUserCaps.mIsEphemeral) {
guestInfoText = getContext().getString(
guestExitSummary = getContext().getString(
R.string.guest_notification_ephemeral);
} else if (isGuestFirstLogin) {
guestInfoText = getContext().getString(
guestExitSummary = getContext().getString(
R.string.guest_notification_non_ephemeral);
} else {
guestInfoText = getContext().getString(
guestExitSummary = getContext().getString(
R.string.guest_notification_non_ephemeral_non_first_login);
}
mGuestInfoPreference.setSummary(guestInfoText);
mGuestExitPreference.setSummary(guestExitSummary);
} else {
mGuestExitPreference.setIcon(getEncircledDefaultIcon());
mGuestExitPreference.setTitle(
@@ -1408,7 +1401,12 @@ public class UserSettings extends SettingsPreferenceFragment
pref.setEnabled(canOpenUserDetails);
pref.setSelectable(true);
if (isEnableGuestModeUxChanges()) {
pref.setIcon(getContext().getDrawable(R.drawable.ic_account_circle));
Drawable icon = getContext().getDrawable(R.drawable.ic_account_circle_outline);
icon.setTint(
getColorAttrDefaultColor(getContext(), android.R.attr.colorControlNormal));
pref.setIcon(encircle(
UserIcons.convertToBitmapAtUserIconSize(
getContext().getResources(), icon)));
} else {
pref.setIcon(getEncircledDefaultIcon());
}
@@ -1645,8 +1643,10 @@ public class UserSettings extends SettingsPreferenceFragment
}
private Drawable encircle(Bitmap icon) {
Drawable circled = CircleFramedDrawable.getInstance(getActivity(), icon);
return circled;
return new CircleFramedDrawable(
icon,
getActivity().getResources().getDimensionPixelSize(
R.dimen.multiple_users_user_icon_size));
}
@Override