am c60d7426: Merge "Show confirmation dialog when adding user from QS" into lmp-dev
* commit 'c60d74266933b7799f0ce7b3f0a75c2b7c0ed0e0': Show confirmation dialog when adding user from QS
This commit is contained in:
@@ -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">
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user