summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFyodor Kupolov <fkupolov@google.com>2014-12-29 13:40:27 -0800
committerFyodor Kupolov <fkupolov@google.com>2015-01-08 11:21:26 -0800
commitdbbd4fca442dc507cd478f26c5dbd5a94085c4e3 (patch)
tree66301714609cf6b6cc5e11feb42f39a75903ece5
parentc2fb78627fa6c715b06a731edf36a4efcf294592 (diff)
downloadpackages_apps_Settings-dbbd4fca442dc507cd478f26c5dbd5a94085c4e3.tar.gz
packages_apps_Settings-dbbd4fca442dc507cd478f26c5dbd5a94085c4e3.tar.bz2
packages_apps_Settings-dbbd4fca442dc507cd478f26c5dbd5a94085c4e3.zip
Show confirmation when turning on "Phone calls/sms"
Added confirmation dialog, when turning on "Phone calls and sms" setting for secondary users and guests. Bug:15761405 Change-Id: I39b2181f0b5460db9a964c6883f053a6c6336622
-rw-r--r--res/values/strings.xml10
-rw-r--r--src/com/android/settings/Utils.java37
-rw-r--r--src/com/android/settings/accounts/AccountSettings.java3
-rw-r--r--src/com/android/settings/users/RestrictedProfileSettings.java5
-rw-r--r--src/com/android/settings/users/UserDetailsSettings.java49
-rw-r--r--src/com/android/settings/users/UserDialogs.java99
-rw-r--r--src/com/android/settings/users/UserSettings.java2
7 files changed, 139 insertions, 66 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2e1477a0d..6010e219d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5315,19 +5315,19 @@
<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 &amp; 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 &amp; 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>
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 6517ffe1f..a3dfddb3f 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -846,43 +846,6 @@ public final class Utils {
|| 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.
diff --git a/src/com/android/settings/accounts/AccountSettings.java b/src/com/android/settings/accounts/AccountSettings.java
index ffcb3b8d2..017eb86e0 100644
--- a/src/com/android/settings/accounts/AccountSettings.java
+++ b/src/com/android/settings/accounts/AccountSettings.java
@@ -49,6 +49,7 @@ import android.preference.PreferenceScreen;
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;
@@ -203,7 +204,7 @@ public class AccountSettings extends SettingsPreferenceFragment
}
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) {
diff --git a/src/com/android/settings/users/RestrictedProfileSettings.java b/src/com/android/settings/users/RestrictedProfileSettings.java
index c0e8cb764..82090d454 100644
--- a/src/com/android/settings/users/RestrictedProfileSettings.java
+++ b/src/com/android/settings/users/RestrictedProfileSettings.java
@@ -22,7 +22,6 @@ import android.content.Intent;
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;
@@ -31,8 +30,6 @@ import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.Utils;
-import java.util.List;
-
public class RestrictedProfileSettings extends AppRestrictionsFragment
implements EditUserInfoController.OnContentChangedCallback {
@@ -129,7 +126,7 @@ public class RestrictedProfileSettings extends AppRestrictionsFragment
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();
diff --git a/src/com/android/settings/users/UserDetailsSettings.java b/src/com/android/settings/users/UserDetailsSettings.java
index 366b628ac..d738dd639 100644
--- a/src/com/android/settings/users/UserDetailsSettings.java
+++ b/src/com/android/settings/users/UserDetailsSettings.java
@@ -28,7 +28,6 @@ import android.preference.SwitchPreference;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.Utils;
import java.util.List;
@@ -55,7 +54,7 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
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;
@@ -117,10 +116,18 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
@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);
@@ -135,14 +142,11 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
}
}
} 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
@@ -150,20 +154,29 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
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() {
diff --git a/src/com/android/settings/users/UserDialogs.java b/src/com/android/settings/users/UserDialogs.java
new file mode 100644
index 000000000..2d92464ac
--- /dev/null
+++ b/src/com/android/settings/users/UserDialogs.java
@@ -0,0 +1,99 @@
+/*
+ * 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();
+ }
+}
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 4ee5cf49a..dbd04810d 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -502,7 +502,7 @@ public class UserSettings extends SettingsPreferenceFragment
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();