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

Commit 0c6763a1 authored by Adrian Roos's avatar Adrian Roos
Browse files

Show confirmation dialog when adding user from QS

Bug: 17392352
Change-Id: I522b0427dbb594d5e8ce33e928dfdc896dc961c7
parent 2dbf3eac
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -798,6 +798,12 @@
    <!-- Notification when resuming an existing guest session: Action that continues with the current session [CHAR LIMIT=35] -->
    <string name="guest_wipe_session_dontwipe">Yes, continue</string>

    <!-- Title for add user confirmation dialog [CHAR LIMIT=30] -->
    <string name="user_add_user_title" msgid="2108112641783146007">Add new user?</string>

    <!-- Message for add user confirmation dialog - short version. [CHAR LIMIT=none] -->
    <string name="user_add_user_message_short" msgid="1511354412249044381">When you add a new user, that person needs to set up their space.\n\nAny user can update apps for all other users. </string>


    <!-- Zen mode condition: time duration in minutes. [CHAR LIMIT=NONE] -->
    <plurals name="zen_mode_duration_minutes">
+37 −2
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ public class UserSwitcherController {

    private ArrayList<UserRecord> mUsers = new ArrayList<>();
    private Dialog mExitGuestDialog;
    private Dialog mAddUserDialog;
    private int mLastNonGuestUser = UserHandle.USER_OWNER;
    private boolean mSimpleUserSwitcher;
    private boolean mAddUsersWhenLocked;
@@ -228,8 +229,8 @@ public class UserSwitcherController {
            // No guest user. Create one.
            id = mUserManager.createGuest(mContext, mContext.getString(R.string.guest_nickname)).id;
        } else if (record.isAddUser) {
            id = mUserManager.createUser(
                    mContext.getString(R.string.user_new_user_name), 0 /* flags */).id;
            showAddUserDialog();
            return;
        } else {
            id = record.info.id;
        }
@@ -260,6 +261,14 @@ public class UserSwitcherController {
        mExitGuestDialog.show();
    }

    private void showAddUserDialog() {
        if (mAddUserDialog != null && mAddUserDialog.isShowing()) {
            mAddUserDialog.cancel();
        }
        mAddUserDialog = new AddUserDialog(mContext);
        mAddUserDialog.show();
    }

    private void exitGuest(int id) {
        int newId = UserHandle.USER_OWNER;
        if (mLastNonGuestUser != UserHandle.USER_OWNER) {
@@ -534,4 +543,30 @@ public class UserSwitcherController {
            }
        }
    }

    private final class AddUserDialog extends SystemUIDialog implements
            DialogInterface.OnClickListener {

        public AddUserDialog(Context context) {
            super(context);
            setTitle(R.string.user_add_user_title);
            setMessage(context.getString(R.string.user_add_user_message_short));
            setButton(DialogInterface.BUTTON_NEGATIVE,
                    context.getString(android.R.string.cancel), this);
            setButton(DialogInterface.BUTTON_POSITIVE,
                    context.getString(android.R.string.ok), this);
        }

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == BUTTON_NEGATIVE) {
                cancel();
            } else {
                dismiss();
                int id = mUserManager.createUser(
                        mContext.getString(R.string.user_new_user_name), 0 /* flags */).id;
                switchToUserId(id);
            }
        }
    }
}