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