diff options
| author | Fred Quintana <fredq@google.com> | 2011-09-28 11:45:52 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-09-28 11:45:52 -0700 |
| commit | 272101b308c7eb0a4639bed0106830a8d6b0f2a1 (patch) | |
| tree | 3e110af78249c4c748a54fb3829eac706c68072b /core/java | |
| parent | 0e8fb15da2bd0912aa74ba6709dfe3d5b7c84fde (diff) | |
| parent | 9bbdd0bf5006512a000b0d3e6bd6ee2998a2e48b (diff) | |
| download | frameworks_base-272101b308c7eb0a4639bed0106830a8d6b0f2a1.zip frameworks_base-272101b308c7eb0a4639bed0106830a8d6b0f2a1.tar.gz frameworks_base-272101b308c7eb0a4639bed0106830a8d6b0f2a1.tar.bz2 | |
Merge "Fix a bug in the account chooser where relaunching an in-progress flow results in a blank screen." into ics-factoryrom
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/accounts/ChooseAccountTypeActivity.java | 54 | ||||
| -rw-r--r-- | core/java/android/accounts/ChooseTypeAndAccountActivity.java | 47 |
2 files changed, 56 insertions, 45 deletions
diff --git a/core/java/android/accounts/ChooseAccountTypeActivity.java b/core/java/android/accounts/ChooseAccountTypeActivity.java index 5239e8c..448b2c0 100644 --- a/core/java/android/accounts/ChooseAccountTypeActivity.java +++ b/core/java/android/accounts/ChooseAccountTypeActivity.java @@ -33,7 +33,6 @@ import android.widget.ListView; import android.widget.TextView; import com.android.internal.R; -import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -43,7 +42,7 @@ import java.util.Set; /** * @hide */ -public class ChooseAccountTypeActivity extends Activity implements AccountManagerCallback<Bundle> { +public class ChooseAccountTypeActivity extends Activity { private static final String TAG = "AccountManager"; private HashMap<String, AuthInfo> mTypeToAuthenticatorInfo = new HashMap<String, AuthInfo>(); @@ -52,7 +51,6 @@ public class ChooseAccountTypeActivity extends Activity implements AccountManage @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.choose_account_type); // Read the validAccountTypes, if present, and add them to the setOfAllowableAccountTypes Set<String> setOfAllowableAccountTypes = null; @@ -90,10 +88,11 @@ public class ChooseAccountTypeActivity extends Activity implements AccountManage } if (mAuthenticatorInfosToDisplay.size() == 1) { - runAddAccountForAuthenticator(mAuthenticatorInfosToDisplay.get(0)); + setResultAndFinish(mAuthenticatorInfosToDisplay.get(0).desc.type); return; } + setContentView(R.layout.choose_account_type); // Setup the list ListView list = (ListView) findViewById(android.R.id.list); // Use an existing ListAdapter that will map an array of strings to TextViews @@ -103,11 +102,20 @@ public class ChooseAccountTypeActivity extends Activity implements AccountManage list.setTextFilterEnabled(false); list.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { - runAddAccountForAuthenticator(mAuthenticatorInfosToDisplay.get(position)); + setResultAndFinish(mAuthenticatorInfosToDisplay.get(position).desc.type); } }); } + private void setResultAndFinish(final String type) { + Bundle bundle = new Bundle(); + bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, type); + setResult(Activity.RESULT_OK, new Intent().putExtras(bundle)); + Log.d(TAG, "ChooseAccountTypeActivity.setResultAndFinish: " + + "selected account type " + type); + finish(); + } + private void buildTypeToAuthDescriptionMap() { for(AuthenticatorDescription desc : AccountManager.get(this).getAuthenticatorTypes()) { String name = null; @@ -136,42 +144,6 @@ public class ChooseAccountTypeActivity extends Activity implements AccountManage } } - protected void runAddAccountForAuthenticator(AuthInfo authInfo) { - Log.d(TAG, "selected account type " + authInfo.name); - final Bundle options = getIntent().getBundleExtra( - ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE); - final String[] requiredFeatures = getIntent().getStringArrayExtra( - ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY); - final String authTokenType = getIntent().getStringExtra( - ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING); - AccountManager.get(this).addAccount(authInfo.desc.type, authTokenType, requiredFeatures, - options, this, this, null /* Handler */); - } - - public void run(final AccountManagerFuture<Bundle> accountManagerFuture) { - try { - Bundle accountManagerResult = accountManagerFuture.getResult(); - Bundle bundle = new Bundle(); - bundle.putString(AccountManager.KEY_ACCOUNT_NAME, - accountManagerResult.getString(AccountManager.KEY_ACCOUNT_NAME)); - bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, - accountManagerResult.getString(AccountManager.KEY_ACCOUNT_TYPE)); - setResult(Activity.RESULT_OK, new Intent().putExtras(bundle)); - finish(); - return; - } catch (OperationCanceledException e) { - setResult(Activity.RESULT_CANCELED); - finish(); - return; - } catch (IOException e) { - } catch (AuthenticatorException e) { - } - Bundle bundle = new Bundle(); - bundle.putString(AccountManager.KEY_ERROR_MESSAGE, "error communicating with server"); - setResult(Activity.RESULT_OK, new Intent().putExtras(bundle)); - finish(); - } - private static class AuthInfo { final AuthenticatorDescription desc; final String name; diff --git a/core/java/android/accounts/ChooseTypeAndAccountActivity.java b/core/java/android/accounts/ChooseTypeAndAccountActivity.java index 852c4dd..8cc2002 100644 --- a/core/java/android/accounts/ChooseTypeAndAccountActivity.java +++ b/core/java/android/accounts/ChooseTypeAndAccountActivity.java @@ -36,6 +36,7 @@ import android.widget.ListView; import android.widget.TextView; import com.android.internal.R; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -44,7 +45,8 @@ import java.util.Set; /** * @hide */ -public class ChooseTypeAndAccountActivity extends Activity { +public class ChooseTypeAndAccountActivity extends Activity + implements AccountManagerCallback<Bundle> { private static final String TAG = "AccountManager"; /** @@ -211,10 +213,9 @@ public class ChooseTypeAndAccountActivity extends Activity { protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { if (resultCode == RESULT_OK && data != null) { - String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); String accountType = data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE); - if (accountName != null && accountType != null) { - setResultAndFinish(accountName, accountType); + if (accountType != null) { + runAddAccountForAuthenticator(accountType); return; } } @@ -223,6 +224,43 @@ public class ChooseTypeAndAccountActivity extends Activity { finish(); } + protected void runAddAccountForAuthenticator(String type) { + Log.d(TAG, "selected account type " + type); + final Bundle options = getIntent().getBundleExtra( + ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE); + final String[] requiredFeatures = getIntent().getStringArrayExtra( + ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY); + final String authTokenType = getIntent().getStringExtra( + ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING); + AccountManager.get(this).addAccount(type, authTokenType, requiredFeatures, + options, this, this, null /* Handler */); + } + + public void run(final AccountManagerFuture<Bundle> accountManagerFuture) { + try { + final Bundle accountManagerResult = accountManagerFuture.getResult(); + final String name = accountManagerResult.getString(AccountManager.KEY_ACCOUNT_NAME); + final String type = accountManagerResult.getString(AccountManager.KEY_ACCOUNT_TYPE); + if (name != null && type != null) { + final Bundle bundle = new Bundle(); + bundle.putString(AccountManager.KEY_ACCOUNT_NAME, name); + bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, type); + setResult(Activity.RESULT_OK, new Intent().putExtras(bundle)); + finish(); + return; + } + } catch (OperationCanceledException e) { + setResult(Activity.RESULT_CANCELED); + finish(); + return; + } catch (IOException e) { + } catch (AuthenticatorException e) { + } + Bundle bundle = new Bundle(); + bundle.putString(AccountManager.KEY_ERROR_MESSAGE, "error communicating with server"); + setResult(Activity.RESULT_OK, new Intent().putExtras(bundle)); + finish(); + } private Drawable getDrawableForType( final HashMap<String, AuthenticatorDescription> typeToAuthDescription, @@ -266,6 +304,7 @@ public class ChooseTypeAndAccountActivity extends Activity { private void startChooseAccountTypeActivity() { final Intent intent = new Intent(this, ChooseAccountTypeActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY, getIntent().getStringArrayExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY)); intent.putExtra(EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE, |
