summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml2
-rw-r--r--res/values/strings.xml5
-rw-r--r--src/com/android/settings/accounts/AddAccountSettings.java72
3 files changed, 72 insertions, 7 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 466e941..2405c6c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1377,7 +1377,7 @@
</activity>
<activity android:name="com.android.settings.accounts.AddAccountSettings"
- android:theme="@android:style/Theme.Translucent.NoTitleBar"
+ android:theme="@android:style/Theme.Holo.Panel"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/header_add_an_account"
android:taskAffinity="com.android.settings"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index fb1de52..fb7ff14 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3744,7 +3744,10 @@
<string name="background_data_dialog_message">Disabling background data extends battery life and lowers data use. Some apps may still use the background data connection.</string>
<!-- Title for a checkbox that enables data synchronization in the account and sync screen [CHAR LIMIT=35] -->
<string name="sync_automatically">Auto-sync app data</string>
-
+ <!-- Account creation warning in multi-user tablets [CHAR LIMIT=none] -->
+ <string name="add_account_shared_system_warning" product="tablet">Reminder: As with any shared computer, there is some risk that other users may find a way to access your data on this tablet.</string>
+ <!-- Account creation warning in multi-user phones[CHAR LIMIT=none] -->
+ <string name="add_account_shared_system_warning" product="default">Reminder: As with any shared computer, there is some risk that other users may find a way to access your data on this phone.</string>
<!-- Sync status messages on Accounts & Synchronization settings --><skip />
<!-- Sync status shown when sync is enabled [CHAR LIMIT=25] -->
<string name="sync_enabled">Sync is ON</string>
diff --git a/src/com/android/settings/accounts/AddAccountSettings.java b/src/com/android/settings/accounts/AddAccountSettings.java
index 382481e..c5f2a9b 100644
--- a/src/com/android/settings/accounts/AddAccountSettings.java
+++ b/src/com/android/settings/accounts/AddAccountSettings.java
@@ -22,16 +22,25 @@ import android.accounts.AccountManagerFuture;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
import android.app.PendingIntent;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
+import com.android.settings.Utils;
+import com.android.settings.R;
+
import java.io.IOException;
/**
* Entry point Actiivty for account setup. Works as follows
- *
+ * 0) If it is a multi-user system with multiple users, it shows a warning dialog first.
+ * If the user accepts this warning, it moves on to step 1.
* 1) When the other Activities launch this Activity, it launches {@link ChooseAccountActivity}
* without showing anything.
* 2) After receiving an account type from ChooseAccountActivity, this Activity launches the
@@ -56,6 +65,7 @@ public class AddAccountSettings extends Activity {
* application.
*/
private static final String KEY_CALLER_IDENTITY = "pendingIntent";
+ private static final String KEY_SHOWED_WARNING = "showedWarning";
private static final String TAG = "AccountSettings";
@@ -63,6 +73,8 @@ public class AddAccountSettings extends Activity {
private static final int CHOOSE_ACCOUNT_REQUEST = 1;
+ private static final int DLG_MULTIUSER_WARNING = 1;
+
private PendingIntent mPendingIntent;
private AccountManagerCallback<Bundle> mCallback = new AccountManagerCallback<Bundle>() {
@@ -90,21 +102,57 @@ public class AddAccountSettings extends Activity {
};
private boolean mAddAccountCalled = false;
+ private boolean mShowedMultiuserWarning;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
+ mShowedMultiuserWarning = savedInstanceState.getBoolean(KEY_SHOWED_WARNING);
mAddAccountCalled = savedInstanceState.getBoolean(KEY_ADD_CALLED);
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "restored");
}
- if (mAddAccountCalled) {
- // We already called add account - maybe the callback was lost.
- finish();
- return;
+ if (!Utils.hasMultipleUsers(this)) {
+ mShowedMultiuserWarning = true;
}
+
+ // Show the multiuser warning dialog first. If that was already shown and accepted,
+ // then show the account type chooser.
+ if (!mShowedMultiuserWarning) {
+ showMultiuserWarning();
+ } else {
+ if (mAddAccountCalled) {
+ // We already called add account - maybe the callback was lost.
+ finish();
+ return;
+ }
+ showChooseAccount();
+ }
+ }
+
+ private void showMultiuserWarning() {
+ showDialog(DLG_MULTIUSER_WARNING);
+ }
+
+ public Dialog onCreateDialog(int dlgId) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(R.string.add_account_shared_system_warning);
+ builder.setPositiveButton(android.R.string.ok, mDialogClickListener);
+ builder.setNegativeButton(android.R.string.cancel, mDialogClickListener);
+ builder.setOnDismissListener(new OnDismissListener() {
+ public void onDismiss(DialogInterface di) {
+ if (!mShowedMultiuserWarning) {
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+ }
+ });
+ return builder.create();
+ }
+
+ private void showChooseAccount() {
final String[] authorities =
getIntent().getStringArrayExtra(AccountPreferenceBase.AUTHORITIES_FILTER_KEY);
final String[] accountTypes =
@@ -137,6 +185,7 @@ public class AddAccountSettings extends Activity {
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(KEY_ADD_CALLED, mAddAccountCalled);
+ outState.putBoolean(KEY_SHOWED_WARNING, mShowedMultiuserWarning);
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "saved");
}
@@ -154,4 +203,17 @@ public class AddAccountSettings extends Activity {
null /* handler */);
mAddAccountCalled = true;
}
+
+ private OnClickListener mDialogClickListener = new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == Dialog.BUTTON_POSITIVE) {
+ mShowedMultiuserWarning = true;
+ showChooseAccount();
+ } else if (which == Dialog.BUTTON_NEGATIVE) {
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+ }
+ };
}