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

Commit ee231520 authored by Anna Bauza's avatar Anna Bauza
Browse files

Fix "Remove Guest" option shows "Reset Guest" dialog

If the guest user was not auto created, removing the user from settings message was wrongly worded. Small refactor to reuse the same wording in different modules has been done.

Bug: 225314166
Test: manual
Change-Id: Ia1871efc6aeeb2d3604c2fc4fd98a2a3a500953b
parent 51316c13
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -209,8 +209,13 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
                            }
                        });
            case DIALOG_CONFIRM_RESET_GUEST:
                if (mGuestUserAutoCreated) {
                    return UserDialogs.createResetGuestDialog(getActivity(),
                        (dialog, which) -> resetGuest());
                } else {
                    return UserDialogs.createRemoveGuestDialog(getActivity(),
                        (dialog, which) -> resetGuest());
                }
        }
        throw new IllegalArgumentException("Unsupported dialogId " + dialogId);
    }
+21 −0
Original line number Diff line number Diff line
@@ -196,4 +196,25 @@ public final class UserDialogs {
                .setNegativeButton(android.R.string.cancel, null)
                .create();
    }


    /**
     * Creates a dialog to confirm with the user if it's ok to remove the guest user, which will
     * delete all the guest user's data.
     *
     * @param context a Context object
     * @param onConfirmListener Callback object for positive action
     * @return the created Dialog
     */
    public static Dialog createRemoveGuestDialog(Context context,
            DialogInterface.OnClickListener onConfirmListener) {
        return new AlertDialog.Builder(context)
                .setTitle(com.android.settingslib.R.string.guest_remove_guest_dialog_title)
                .setMessage(R.string.user_exit_guest_confirm_message)
                .setPositiveButton(
                        com.android.settingslib.R.string.guest_remove_guest_confirm_button,
                        onConfirmListener)
                .setNegativeButton(android.R.string.cancel, null)
                .create();
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -737,8 +737,13 @@ public class UserSettings extends SettingsPreferenceFragment
                return buildAddUserDialog(USER_TYPE_RESTRICTED_PROFILE);
            }
            case DIALOG_CONFIRM_RESET_GUEST: {
                if (mGuestUserAutoCreated) {
                    return UserDialogs.createResetGuestDialog(getActivity(),
                        (dialog, which) -> resetGuest());
                } else {
                    return UserDialogs.createRemoveGuestDialog(getActivity(),
                        (dialog, which) -> resetGuest());
                }
            }
            default:
                return null;