Multiuser settings revamp - followup to address comments
Bug: 15761405 Change-Id: I9c03432a2f2651a931486ce65fb3b5af37608be0
This commit is contained in:
@@ -18,12 +18,14 @@ package com.android.settings;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.Dialog;
|
||||
import android.app.Fragment;
|
||||
import android.app.IActivityManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -61,6 +63,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TabWidget;
|
||||
|
||||
import com.android.settings.R.string;
|
||||
import com.android.settings.dashboard.DashboardCategory;
|
||||
import com.android.settings.dashboard.DashboardTile;
|
||||
|
||||
@@ -636,4 +639,35 @@ public final class Utils {
|
||||
// Default to current profile
|
||||
return new UserHandle(currentUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a dialog to confirm with the user if it's ok to remove the user
|
||||
* and delete all the data.
|
||||
*
|
||||
* @param context a Context object
|
||||
* @param removingUserId The userId of the user to remove
|
||||
* @param onConfirmListener Callback object for positive action
|
||||
* @return the created Dialog
|
||||
*/
|
||||
public static Dialog createRemoveConfirmationDialog(Context context, int removingUserId,
|
||||
DialogInterface.OnClickListener onConfirmListener) {
|
||||
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
UserInfo userInfo = um.getUserInfo(removingUserId);
|
||||
Dialog dlg = new AlertDialog.Builder(context)
|
||||
.setTitle(UserHandle.myUserId() == removingUserId
|
||||
? R.string.user_confirm_remove_self_title
|
||||
: (userInfo.isRestricted()
|
||||
? R.string.user_profile_confirm_remove_title
|
||||
: R.string.user_confirm_remove_title))
|
||||
.setMessage(UserHandle.myUserId() == removingUserId
|
||||
? R.string.user_confirm_remove_self_message
|
||||
: (userInfo.isRestricted()
|
||||
? R.string.user_profile_confirm_remove_message
|
||||
: R.string.user_confirm_remove_message))
|
||||
.setPositiveButton(R.string.user_delete_button,
|
||||
onConfirmListener)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
return dlg;
|
||||
}
|
||||
}
|
||||
|
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.users;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
public class RemoveUserUtil {
|
||||
|
||||
static Dialog createConfirmationDialog(Context context, int removingUserId,
|
||||
DialogInterface.OnClickListener onConfirmListener) {
|
||||
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
final UserInfo userInfo = um.getUserInfo(removingUserId);
|
||||
Dialog dlg = new AlertDialog.Builder(context)
|
||||
.setTitle(UserHandle.myUserId() == removingUserId
|
||||
? R.string.user_confirm_remove_self_title
|
||||
: (userInfo.isRestricted()
|
||||
? R.string.user_profile_confirm_remove_title
|
||||
: R.string.user_confirm_remove_title))
|
||||
.setMessage(UserHandle.myUserId() == removingUserId
|
||||
? R.string.user_confirm_remove_self_message
|
||||
: (userInfo.isRestricted()
|
||||
? R.string.user_profile_confirm_remove_message
|
||||
: R.string.user_confirm_remove_message))
|
||||
.setPositiveButton(R.string.user_delete_button,
|
||||
onConfirmListener)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
return dlg;
|
||||
}
|
||||
}
|
@@ -101,7 +101,7 @@ public class RestrictedProfileSettings extends AppRestrictionsFragment {
|
||||
mHeaderView.setOnClickListener(this);
|
||||
mUserIconView = (ImageView) mHeaderView.findViewById(android.R.id.icon);
|
||||
mUserNameView = (TextView) mHeaderView.findViewById(android.R.id.title);
|
||||
//getListView().setFastScrollEnabled(true);
|
||||
getListView().setFastScrollEnabled(true);
|
||||
}
|
||||
// This is going to bind the preferences.
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
@@ -34,6 +34,7 @@ import com.android.settings.Utils;
|
||||
* Settings screen for configuring a specific user. It can contain user restrictions
|
||||
* and deletion controls. It is shown when you tap on the settings icon in the
|
||||
* user management (UserSettings) screen.
|
||||
*
|
||||
* Arguments to this fragment must include the userId of the user (in EXTRA_USER_ID) for whom
|
||||
* to display controls, or should contain the EXTRA_USER_GUEST = true.
|
||||
*/
|
||||
@@ -130,7 +131,7 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
|
||||
if (context == null) return null;
|
||||
switch (dialogId) {
|
||||
case DIALOG_CONFIRM_REMOVE: {
|
||||
Dialog dlg = RemoveUserUtil.createConfirmationDialog(getActivity(), mUserInfo.id,
|
||||
Dialog dlg = Utils.createRemoveConfirmationDialog(getActivity(), mUserInfo.id,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
removeUser();
|
||||
|
@@ -211,10 +211,8 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
mAddUser.setOnPreferenceClickListener(this);
|
||||
DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
|
||||
Context.DEVICE_POLICY_SERVICE);
|
||||
// No restricted profiles for tablets with a device owner, or
|
||||
// phones.
|
||||
if (dpm.getDeviceOwner() != null
|
||||
|| Utils.isVoiceCapable(context)) {
|
||||
// No restricted profiles for tablets with a device owner, or phones.
|
||||
if (dpm.getDeviceOwner() != null || Utils.isVoiceCapable(context)) {
|
||||
mCanAddRestrictedProfile = false;
|
||||
mAddUser.setTitle(R.string.user_add_user_menu);
|
||||
}
|
||||
@@ -431,7 +429,11 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
extras.putInt(UserDetailsSettings.EXTRA_USER_ID, userId);
|
||||
((SettingsActivity) getActivity()).startPreferencePanel(
|
||||
UserDetailsSettings.class.getName(),
|
||||
extras, -1, info.name, null, 0);
|
||||
extras,
|
||||
-1, /* No title res id */
|
||||
info.name, /* title */
|
||||
null, /* resultTo */
|
||||
0 /* resultRequestCode */);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,7 +460,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
switch (dialogId) {
|
||||
case DIALOG_CONFIRM_REMOVE: {
|
||||
Dialog dlg =
|
||||
RemoveUserUtil.createConfirmationDialog(getActivity(), mRemovingUserId,
|
||||
Utils.createRemoveConfirmationDialog(getActivity(), mRemovingUserId,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
removeUserNow();
|
||||
@@ -665,8 +667,6 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
pref = new UserPreference(context, null, user.id,
|
||||
showSettings ? this : null,
|
||||
showDelete ? this : null);
|
||||
//mIsOwner && user.isRestricted() ? this : null,
|
||||
//mIsOwner ? this : null);
|
||||
pref.setOnPreferenceClickListener(this);
|
||||
pref.setKey("id=" + user.id);
|
||||
mUserListCategory.addPreference(pref);
|
||||
|
Reference in New Issue
Block a user