<string name="user_exit_guest_dialog_remove">Remove</string>
<!-- Title of preference to enable calling[CHAR LIMIT=40] -->
- <string name="user_enable_calling">Allow phone calls</string>
+ <string name="user_enable_calling">Turn on phone calls</string>
<!-- Title of preference to enable calling and SMS [CHAR LIMIT=45] -->
- <string name="user_enable_calling_sms">Allow phone calls and SMS</string>
+ <string name="user_enable_calling_sms">Turn on phone calls & SMS</string>
<!-- Title of preference to remove the user [CHAR LIMIT=35] -->
<string name="user_remove_user">Remove user</string>
<!-- Title for confirmation of turning on calls [CHAR LIMIT=40] -->
- <string name="user_enable_calling_confirm_title">Allow phone calls?</string>
+ <string name="user_enable_calling_confirm_title">Turn on phone calls?</string>
<!-- Message for confirmation of turning on calls [CHAR LIMIT=none] -->
<string name="user_enable_calling_confirm_message">Call history will be shared with this user.</string>
<!-- Title for confirmation of turning on calls and SMS [CHAR LIMIT=45] -->
- <string name="user_enable_calling_sms_confirm_title">Allow phone calls and SMS?</string>
+ <string name="user_enable_calling_and_sms_confirm_title">Turn on phone calls & SMS?</string>
<!-- Message for confirmation of turning on calls and SMS [CHAR LIMIT=none] -->
- <string name="user_enable_calling_sms_confirm_message">Call and SMS history will be shared with this user.</string>
+ <string name="user_enable_calling_and_sms_confirm_message">Call and SMS history will be shared with this user.</string>
<!-- Application Restrictions screen title [CHAR LIMIT=45] -->
<string name="application_restrictions">Allow apps and content</string>
|| um.getUserProfiles().contains(otherUser);
}
- /**
- * 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);
- int titleResId;
- int messageResId;
- if (UserHandle.myUserId() == removingUserId) {
- titleResId = R.string.user_confirm_remove_self_title;
- messageResId = R.string.user_confirm_remove_self_message;
- } else if (userInfo.isRestricted()) {
- titleResId = R.string.user_profile_confirm_remove_title;
- messageResId = R.string.user_profile_confirm_remove_message;
- } else if (userInfo.isManagedProfile()) {
- titleResId = R.string.work_profile_confirm_remove_title;
- messageResId = R.string.work_profile_confirm_remove_message;
- } else {
- titleResId = R.string.user_confirm_remove_title;
- messageResId = R.string.user_confirm_remove_message;
- }
- Dialog dlg = new AlertDialog.Builder(context)
- .setTitle(titleResId)
- .setMessage(messageResId)
- .setPositiveButton(R.string.user_delete_button,
- onConfirmListener)
- .setNegativeButton(android.R.string.cancel, null)
- .create();
- return dlg;
- }
/**
* Returns whether or not this device is able to be OEM unlocked.
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
+import com.android.settings.users.UserDialogs;
import java.util.ArrayList;
import java.util.Collections;
}
if (preference == profileData.removeWorkProfilePreference) {
final int userId = profileData.userInfo.id;
- Utils.createRemoveConfirmationDialog(getActivity(), userId,
+ UserDialogs.createRemoveDialog(getActivity(), userId,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
import android.content.pm.UserInfo;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.os.UserHandle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import com.android.settings.R;
import com.android.settings.Utils;
-import java.util.List;
-
public class RestrictedProfileSettings extends AppRestrictionsFragment
implements EditUserInfoController.OnContentChangedCallback {
this, mUser);
} else if (dialogId == DIALOG_CONFIRM_REMOVE) {
Dialog dlg =
- Utils.createRemoveConfirmationDialog(getActivity(), mUser.getIdentifier(),
+ UserDialogs.createRemoveDialog(getActivity(), mUser.getIdentifier(),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
removeUser();
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.Utils;
import java.util.List;
private static final int DIALOG_CONFIRM_REMOVE = 1;
private static final int DIALOG_CONFIRM_ENABLE_CALLING = 2;
- private static final int DIALOG_CONFIRM_ENABLE_CALLING_SMS = 3;
+ private static final int DIALOG_CONFIRM_ENABLE_CALLING_AND_SMS = 3;
private UserManager mUserManager;
private SwitchPreference mPhonePref;
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (Boolean.TRUE.equals(newValue)) {
+ showDialog(mGuestUser? DIALOG_CONFIRM_ENABLE_CALLING : DIALOG_CONFIRM_ENABLE_CALLING_AND_SMS);
+ return false;
+ }
+ enableCallsAndSms(false);
+ return true;
+ }
+
+ void enableCallsAndSms(boolean enabled) {
+ mPhonePref.setChecked(enabled);
if (mGuestUser) {
- // TODO: Show confirmation dialog: b/15761405
- mDefaultGuestRestrictions.putBoolean(UserManager.DISALLOW_OUTGOING_CALLS,
- !((Boolean) newValue));
+ mDefaultGuestRestrictions.putBoolean(UserManager.DISALLOW_OUTGOING_CALLS, !enabled);
// SMS is always disabled for guest
mDefaultGuestRestrictions.putBoolean(UserManager.DISALLOW_SMS, true);
mUserManager.setDefaultGuestRestrictions(mDefaultGuestRestrictions);
}
}
} else {
- // TODO: Show confirmation dialog: b/15761405
UserHandle userHandle = new UserHandle(mUserInfo.id);
- mUserManager.setUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS,
- !((Boolean) newValue), userHandle);
- mUserManager.setUserRestriction(UserManager.DISALLOW_SMS,
- !((Boolean) newValue), userHandle);
+ mUserManager.setUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, !enabled,
+ userHandle);
+ mUserManager.setUserRestriction(UserManager.DISALLOW_SMS, !enabled, userHandle);
}
- return true;
}
@Override
Context context = getActivity();
if (context == null) return null;
switch (dialogId) {
- case DIALOG_CONFIRM_REMOVE: {
- Dialog dlg = Utils.createRemoveConfirmationDialog(getActivity(), mUserInfo.id,
+ case DIALOG_CONFIRM_REMOVE:
+ return UserDialogs.createRemoveDialog(getActivity(), mUserInfo.id,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
removeUser();
}
});
- return dlg;
- }
case DIALOG_CONFIRM_ENABLE_CALLING:
- case DIALOG_CONFIRM_ENABLE_CALLING_SMS:
- // TODO: b/15761405
+ return UserDialogs.createEnablePhoneCallsDialog(getActivity(),
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ enableCallsAndSms(true);
+ }
+ });
+ case DIALOG_CONFIRM_ENABLE_CALLING_AND_SMS:
+ return UserDialogs.createEnablePhoneCallsAndSmsDialog(getActivity(),
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ enableCallsAndSms(true);
+ }
+ });
}
- return null;
+ throw new IllegalArgumentException("Unsupported dialogId " + dialogId);
}
void removeUser() {
--- /dev/null
+/*
+ * 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;
+
+/**
+ * Helper class for displaying dialogs related to user settings.
+ */
+public final class UserDialogs {
+
+ /**
+ * 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 createRemoveDialog(Context context, int removingUserId,
+ DialogInterface.OnClickListener onConfirmListener) {
+ UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ UserInfo userInfo = um.getUserInfo(removingUserId);
+ int titleResId;
+ int messageResId;
+ if (UserHandle.myUserId() == removingUserId) {
+ titleResId = R.string.user_confirm_remove_self_title;
+ messageResId = R.string.user_confirm_remove_self_message;
+ } else if (userInfo.isRestricted()) {
+ titleResId = R.string.user_profile_confirm_remove_title;
+ messageResId = R.string.user_profile_confirm_remove_message;
+ } else if (userInfo.isManagedProfile()) {
+ titleResId = R.string.work_profile_confirm_remove_title;
+ messageResId = R.string.work_profile_confirm_remove_message;
+ } else {
+ titleResId = R.string.user_confirm_remove_title;
+ messageResId = R.string.user_confirm_remove_message;
+ }
+ return new AlertDialog.Builder(context)
+ .setTitle(titleResId)
+ .setMessage(messageResId)
+ .setPositiveButton(R.string.user_delete_button, onConfirmListener)
+ .setNegativeButton(android.R.string.cancel, null)
+ .create();
+ }
+
+ /**
+ * Creates a dialog to confirm that the user is ok to enable phone calls and SMS.
+ *
+ * @param onConfirmListener Callback object for positive action
+ */
+ public static Dialog createEnablePhoneCallsAndSmsDialog(Context context,
+ DialogInterface.OnClickListener onConfirmListener) {
+ return new AlertDialog.Builder(context)
+ .setTitle(R.string.user_enable_calling_and_sms_confirm_title)
+ .setMessage(R.string.user_enable_calling_and_sms_confirm_message)
+ .setPositiveButton(R.string.okay, onConfirmListener)
+ .setNegativeButton(android.R.string.cancel, null)
+ .create();
+ }
+
+ /**
+ * Creates a dialog to confirm that the user is ok to enable phone calls (no SMS).
+ *
+ * @param onConfirmListener Callback object for positive action
+ */
+ public static Dialog createEnablePhoneCallsDialog(Context context,
+ DialogInterface.OnClickListener onConfirmListener) {
+ return new AlertDialog.Builder(context)
+ .setTitle(R.string.user_enable_calling_confirm_title)
+ .setMessage(R.string.user_enable_calling_confirm_message)
+ .setPositiveButton(R.string.okay, onConfirmListener)
+ .setNegativeButton(android.R.string.cancel, null)
+ .create();
+ }
+}
switch (dialogId) {
case DIALOG_CONFIRM_REMOVE: {
Dialog dlg =
- Utils.createRemoveConfirmationDialog(getActivity(), mRemovingUserId,
+ UserDialogs.createRemoveDialog(getActivity(), mRemovingUserId,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
removeUserNow();