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

Commit d23aba70 authored by Avinash Vadlamudi's avatar Avinash Vadlamudi
Browse files

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 9cf1d188)
parent 53956547
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
<!--
  Copyright (C) 2022 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="48dp"
    android:height="48dp"
    android:viewportWidth="48"
    android:viewportHeight="48"
    android:tint="?android:attr/colorAccent">
  <path
      android:fillColor="#FF000000"
      android:pathData="M11.1,35.25Q14.25,33.05 17.35,31.875Q20.45,30.7 24,30.7Q27.55,30.7 30.675,31.875Q33.8,33.05 36.95,35.25Q39.15,32.55 40.075,29.8Q41,27.05 41,24Q41,16.75 36.125,11.875Q31.25,7 24,7Q16.75,7 11.875,11.875Q7,16.75 7,24Q7,27.05 7.95,29.8Q8.9,32.55 11.1,35.25ZM24,25.5Q21.1,25.5 19.125,23.525Q17.15,21.55 17.15,18.65Q17.15,15.75 19.125,13.775Q21.1,11.8 24,11.8Q26.9,11.8 28.875,13.775Q30.85,15.75 30.85,18.65Q30.85,21.55 28.875,23.525Q26.9,25.5 24,25.5ZM24,44Q19.9,44 16.25,42.425Q12.6,40.85 9.875,38.125Q7.15,35.4 5.575,31.75Q4,28.1 4,24Q4,19.85 5.575,16.225Q7.15,12.6 9.875,9.875Q12.6,7.15 16.25,5.575Q19.9,4 24,4Q28.15,4 31.775,5.575Q35.4,7.15 38.125,9.875Q40.85,12.6 42.425,16.225Q44,19.85 44,24Q44,28.1 42.425,31.75Q40.85,35.4 38.125,38.125Q35.4,40.85 31.775,42.425Q28.15,44 24,44ZM24,41Q26.75,41 29.375,40.2Q32,39.4 34.55,37.4Q32,35.6 29.35,34.65Q26.7,33.7 24,33.7Q21.3,33.7 18.65,34.65Q16,35.6 13.45,37.4Q16,39.4 18.625,40.2Q21.25,41 24,41ZM24,22.5Q25.7,22.5 26.775,21.425Q27.85,20.35 27.85,18.65Q27.85,16.95 26.775,15.875Q25.7,14.8 24,14.8Q22.3,14.8 21.225,15.875Q20.15,16.95 20.15,18.65Q20.15,20.35 21.225,21.425Q22.3,22.5 24,22.5ZM24,18.65Q24,18.65 24,18.65Q24,18.65 24,18.65Q24,18.65 24,18.65Q24,18.65 24,18.65Q24,18.65 24,18.65Q24,18.65 24,18.65Q24,18.65 24,18.65Q24,18.65 24,18.65ZM24,37.35Q24,37.35 24,37.35Q24,37.35 24,37.35Q24,37.35 24,37.35Q24,37.35 24,37.35Q24,37.35 24,37.35Q24,37.35 24,37.35Q24,37.35 24,37.35Q24,37.35 24,37.35Z"/>
</vector>
+1 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@
    <dimen name="avatar_margin_top">56dp</dimen>
    <dimen name="avatar_margin_end">24dp</dimen>
    <dimen name="multiple_users_avatar_size">20dp</dimen>
    <dimen name="multiple_users_user_icon_size">40dp</dimen>

    <!-- Homepage -->
    <dimen name="homepage_title_margin_bottom">8dp</dimen>
+0 −6
Original line number Diff line number Diff line
@@ -43,12 +43,6 @@
        android:icon="@drawable/ic_guest_reset"
        android:order="4"/>

    <Preference
        android:key="guest_info"
        android:icon="@drawable/ic_info"
        android:order="5"
        android:selectable="false"/>

    <PreferenceCategory
        android:key="user_list"
        android:title="@string/user_category_title"
+15 −15
Original line number Diff line number Diff line
@@ -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
+0 −1
Original line number Diff line number Diff line
@@ -185,7 +185,6 @@ public class UserSettingsTest {
        mFragment.mGuestCategory = mock(PreferenceCategory.class);
        mFragment.mGuestResetPreference = mock(Preference.class);
        mFragment.mGuestExitPreference = mock(Preference.class);
        mFragment.mGuestInfoPreference = mock(Preference.class);
    }

    @After