am 35bbbc6c
: Merge "Launch account addition activity from Settings instead of from AccountManager" into jb-mr1-dev
* commit '35bbbc6ca40c93c4174f426be295ea912aad82e0': Launch account addition activity from Settings instead of from AccountManager
This commit is contained in:
@@ -67,18 +67,31 @@ public class AddAccountSettings extends Activity {
|
||||
static final String EXTRA_HAS_MULTIPLE_USERS = "hasMultipleUsers";
|
||||
|
||||
private static final int CHOOSE_ACCOUNT_REQUEST = 1;
|
||||
private static final int ADD_ACCOUNT_REQUEST = 2;
|
||||
|
||||
private PendingIntent mPendingIntent;
|
||||
|
||||
private AccountManagerCallback<Bundle> mCallback = new AccountManagerCallback<Bundle>() {
|
||||
public void run(AccountManagerFuture<Bundle> future) {
|
||||
boolean done = true;
|
||||
try {
|
||||
Bundle bundle = future.getResult();
|
||||
bundle.keySet();
|
||||
//bundle.keySet();
|
||||
Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT);
|
||||
if (intent != null) {
|
||||
done = false;
|
||||
Bundle addAccountOptions = new Bundle();
|
||||
addAccountOptions.putParcelable(KEY_CALLER_IDENTITY, mPendingIntent);
|
||||
addAccountOptions.putBoolean(EXTRA_HAS_MULTIPLE_USERS,
|
||||
Utils.hasMultipleUsers(AddAccountSettings.this));
|
||||
intent.putExtras(addAccountOptions);
|
||||
startActivityForResult(intent, ADD_ACCOUNT_REQUEST);
|
||||
} else {
|
||||
setResult(RESULT_OK);
|
||||
|
||||
if (mPendingIntent != null) {
|
||||
mPendingIntent.cancel();
|
||||
mPendingIntent = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "account added: " + bundle);
|
||||
@@ -89,9 +102,11 @@ public class AddAccountSettings extends Activity {
|
||||
} catch (AuthenticatorException e) {
|
||||
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "addAccount failed: " + e);
|
||||
} finally {
|
||||
if (done) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private boolean mAddAccountCalled = false;
|
||||
@@ -136,6 +151,14 @@ public class AddAccountSettings extends Activity {
|
||||
// Go to account setup screen. finish() is called inside mCallback.
|
||||
addAccount(data.getStringExtra(EXTRA_SELECTED_ACCOUNT));
|
||||
break;
|
||||
case ADD_ACCOUNT_REQUEST:
|
||||
setResult(resultCode);
|
||||
if (mPendingIntent != null) {
|
||||
mPendingIntent.cancel();
|
||||
mPendingIntent = null;
|
||||
}
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +178,7 @@ public class AddAccountSettings extends Activity {
|
||||
null, /* authTokenType */
|
||||
null, /* requiredFeatures */
|
||||
addAccountOptions,
|
||||
this,
|
||||
null,
|
||||
mCallback,
|
||||
null /* handler */);
|
||||
mAddAccountCalled = true;
|
||||
|
Reference in New Issue
Block a user