am 272101b3: Merge "Fix a bug in the account chooser where relaunching an in-progress flow results in a blank screen." into ics-factoryrom
* commit '272101b308c7eb0a4639bed0106830a8d6b0f2a1': Fix a bug in the account chooser where relaunching an in-progress flow results in a blank screen.
This commit is contained in:
@@ -33,7 +33,6 @@ import android.widget.ListView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -43,7 +42,7 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public class ChooseAccountTypeActivity extends Activity implements AccountManagerCallback<Bundle> {
|
public class ChooseAccountTypeActivity extends Activity {
|
||||||
private static final String TAG = "AccountManager";
|
private static final String TAG = "AccountManager";
|
||||||
|
|
||||||
private HashMap<String, AuthInfo> mTypeToAuthenticatorInfo = new HashMap<String, AuthInfo>();
|
private HashMap<String, AuthInfo> mTypeToAuthenticatorInfo = new HashMap<String, AuthInfo>();
|
||||||
@@ -52,7 +51,6 @@ public class ChooseAccountTypeActivity extends Activity implements AccountManage
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.choose_account_type);
|
|
||||||
|
|
||||||
// Read the validAccountTypes, if present, and add them to the setOfAllowableAccountTypes
|
// Read the validAccountTypes, if present, and add them to the setOfAllowableAccountTypes
|
||||||
Set<String> setOfAllowableAccountTypes = null;
|
Set<String> setOfAllowableAccountTypes = null;
|
||||||
@@ -90,10 +88,11 @@ public class ChooseAccountTypeActivity extends Activity implements AccountManage
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mAuthenticatorInfosToDisplay.size() == 1) {
|
if (mAuthenticatorInfosToDisplay.size() == 1) {
|
||||||
runAddAccountForAuthenticator(mAuthenticatorInfosToDisplay.get(0));
|
setResultAndFinish(mAuthenticatorInfosToDisplay.get(0).desc.type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setContentView(R.layout.choose_account_type);
|
||||||
// Setup the list
|
// Setup the list
|
||||||
ListView list = (ListView) findViewById(android.R.id.list);
|
ListView list = (ListView) findViewById(android.R.id.list);
|
||||||
// Use an existing ListAdapter that will map an array of strings to TextViews
|
// 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.setTextFilterEnabled(false);
|
||||||
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
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() {
|
private void buildTypeToAuthDescriptionMap() {
|
||||||
for(AuthenticatorDescription desc : AccountManager.get(this).getAuthenticatorTypes()) {
|
for(AuthenticatorDescription desc : AccountManager.get(this).getAuthenticatorTypes()) {
|
||||||
String name = null;
|
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 {
|
private static class AuthInfo {
|
||||||
final AuthenticatorDescription desc;
|
final AuthenticatorDescription desc;
|
||||||
final String name;
|
final String name;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import android.widget.ListView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -44,7 +45,8 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public class ChooseTypeAndAccountActivity extends Activity {
|
public class ChooseTypeAndAccountActivity extends Activity
|
||||||
|
implements AccountManagerCallback<Bundle> {
|
||||||
private static final String TAG = "AccountManager";
|
private static final String TAG = "AccountManager";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,10 +213,9 @@ public class ChooseTypeAndAccountActivity extends Activity {
|
|||||||
protected void onActivityResult(final int requestCode, final int resultCode,
|
protected void onActivityResult(final int requestCode, final int resultCode,
|
||||||
final Intent data) {
|
final Intent data) {
|
||||||
if (resultCode == RESULT_OK && data != null) {
|
if (resultCode == RESULT_OK && data != null) {
|
||||||
String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
|
|
||||||
String accountType = data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE);
|
String accountType = data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE);
|
||||||
if (accountName != null && accountType != null) {
|
if (accountType != null) {
|
||||||
setResultAndFinish(accountName, accountType);
|
runAddAccountForAuthenticator(accountType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,6 +224,43 @@ public class ChooseTypeAndAccountActivity extends Activity {
|
|||||||
finish();
|
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(
|
private Drawable getDrawableForType(
|
||||||
final HashMap<String, AuthenticatorDescription> typeToAuthDescription,
|
final HashMap<String, AuthenticatorDescription> typeToAuthDescription,
|
||||||
@@ -266,6 +304,7 @@ public class ChooseTypeAndAccountActivity extends Activity {
|
|||||||
|
|
||||||
private void startChooseAccountTypeActivity() {
|
private void startChooseAccountTypeActivity() {
|
||||||
final Intent intent = new Intent(this, ChooseAccountTypeActivity.class);
|
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,
|
intent.putExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY,
|
||||||
getIntent().getStringArrayExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY));
|
getIntent().getStringArrayExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY));
|
||||||
intent.putExtra(EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE,
|
intent.putExtra(EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE,
|
||||||
|
|||||||
Reference in New Issue
Block a user