summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimranjit Singh Kohli <simranjit@google.com>2015-05-23 00:20:38 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-23 00:20:40 +0000
commitaefdaa5cbd2a68aa6c8e7d229b897237562cebcb (patch)
treeae4442cb6f429526885c4cabada0cc4b6036d2cb
parent8f51279d50fab3270e1c13dc65c4e38a3a735ef6 (diff)
parent734f8fb69d0c8af7b10bded718897a55ced49bf0 (diff)
downloadframeworks_base-aefdaa5cbd2a68aa6c8e7d229b897237562cebcb.zip
frameworks_base-aefdaa5cbd2a68aa6c8e7d229b897237562cebcb.tar.gz
frameworks_base-aefdaa5cbd2a68aa6c8e7d229b897237562cebcb.tar.bz2
Merge "[ChooseAccount/AccountManager.newChooseAccountIntent Bug Fixes]" into mnc-dev
-rw-r--r--core/java/android/accounts/AccountManager.java3
-rw-r--r--core/java/android/accounts/ChooseTypeAndAccountActivity.java55
2 files changed, 32 insertions, 26 deletions
diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java
index fd40d99..31e129b 100644
--- a/core/java/android/accounts/AccountManager.java
+++ b/core/java/android/accounts/AccountManager.java
@@ -2326,7 +2326,8 @@ public class AccountManager {
* shown. If not specified then this field will not limit the displayed accounts.
* @param allowableAccountTypes an optional string array of account types. These are used
* both to filter the shown accounts and to filter the list of account types that are shown
- * when adding an account.
+ * when adding an account. If not specified then this field will not limit the displayed
+ * account types when adding an account.
* @param alwaysPromptForAccount if set the account chooser screen is always shown, otherwise
* it is only shown when there is more than one account from which to choose
* @param descriptionOverrideText if non-null this string is used as the description in the
diff --git a/core/java/android/accounts/ChooseTypeAndAccountActivity.java b/core/java/android/accounts/ChooseTypeAndAccountActivity.java
index 82c2159..c06b462 100644
--- a/core/java/android/accounts/ChooseTypeAndAccountActivity.java
+++ b/core/java/android/accounts/ChooseTypeAndAccountActivity.java
@@ -132,7 +132,6 @@ public class ChooseTypeAndAccountActivity extends Activity
@Override
public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "ChooseTypeAndAccountActivity.onCreate(savedInstanceState="
+ savedInstanceState + ")");
@@ -192,7 +191,6 @@ public class ChooseTypeAndAccountActivity extends Activity
mAlwaysPromptForAccount = intent.getBooleanExtra(EXTRA_ALWAYS_PROMPT_FOR_ACCOUNT, false);
mDescriptionOverride = intent.getStringExtra(EXTRA_DESCRIPTION_TEXT_OVERRIDE);
- // Need to do this once here to request the window feature. Can't do it in onResume
mAccounts = getAcceptableAccountChoices(AccountManager.get(this));
if (mAccounts.isEmpty()
&& mDisallowAddAccounts) {
@@ -200,17 +198,11 @@ public class ChooseTypeAndAccountActivity extends Activity
setContentView(R.layout.app_not_authorized);
mDontShowPicker = true;
}
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- if (mDontShowPicker) return;
- final AccountManager accountManager = AccountManager.get(this);
-
- mAccounts = getAcceptableAccountChoices(accountManager);
+ if (mDontShowPicker) {
+ super.onCreate(savedInstanceState);
+ return;
+ }
// In cases where the activity does not need to show an account picker, cut the chase
// and return the result directly. Eg:
@@ -220,6 +212,7 @@ public class ChooseTypeAndAccountActivity extends Activity
// If there are no relevant accounts and only one relevant account type go directly to
// add account. Otherwise let the user choose.
if (mAccounts.isEmpty()) {
+ setNonLabelThemeAndCallSuperCreate(savedInstanceState);
if (mSetOfRelevantAccountTypes.size() == 1) {
runAddAccountForAuthenticator(mSetOfRelevantAccountTypes.iterator().next());
} else {
@@ -231,6 +224,7 @@ public class ChooseTypeAndAccountActivity extends Activity
// if there is only one allowable account return it
if (!mAlwaysPromptForAccount && mAccounts.size() == 1) {
Account account = mAccounts.get(0);
+ super.onCreate(savedInstanceState);
setResultAndFinish(account.name, account.type);
return;
}
@@ -240,8 +234,7 @@ public class ChooseTypeAndAccountActivity extends Activity
mSelectedItemIndex = getItemIndexToSelect(
mAccounts, mSelectedAccountName, mSelectedAddNewAccount);
- // Cannot set content view until we know that mPendingRequest is not null, otherwise
- // would cause screen flicker.
+ super.onCreate(savedInstanceState);
setContentView(R.layout.choose_type_and_account);
overrideDescriptionIfSupplied(mDescriptionOverride);
populateUIAccountList(listItems);
@@ -409,6 +402,17 @@ public class ChooseTypeAndAccountActivity extends Activity
finish();
}
+ /**
+ * The default activity theme shows label at the top. Set a theme which does
+ * not show label, which effectively makes the activity invisible. Note that
+ * no content is being set. If something gets set, using this theme may be
+ * useless.
+ */
+ private void setNonLabelThemeAndCallSuperCreate(Bundle savedInstanceState) {
+ setTheme(R.style.Theme_Material_Light_Dialog_NoActionBar);
+ super.onCreate(savedInstanceState);
+ }
+
private void onAccountSelected(Account account) {
Log.d(TAG, "selected account " + account);
setResultAndFinish(account.name, account.type);
@@ -489,8 +493,7 @@ public class ChooseTypeAndAccountActivity extends Activity
mCallingUid);
ArrayList<Account> accountsToPopulate = new ArrayList<Account>(accounts.length);
for (Account account : accounts) {
- if (mSetOfAllowableAccounts != null
- && !mSetOfAllowableAccounts.contains(account)) {
+ if (mSetOfAllowableAccounts != null && !mSetOfAllowableAccounts.contains(account)) {
continue;
}
if (mSetOfRelevantAccountTypes != null
@@ -503,7 +506,7 @@ public class ChooseTypeAndAccountActivity extends Activity
}
/**
- * Return a set of account types speficied by the intent as well as supported by the
+ * Return a set of account types specified by the intent as well as supported by the
* AccountManager.
*/
private Set<String> getReleventAccountTypes(final Intent intent) {
@@ -512,14 +515,16 @@ public class ChooseTypeAndAccountActivity extends Activity
Set<String> setOfRelevantAccountTypes = null;
final String[] allowedAccountTypes =
intent.getStringArrayExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY);
- if (allowedAccountTypes != null) {
- setOfRelevantAccountTypes = Sets.newHashSet(allowedAccountTypes);
- AuthenticatorDescription[] descs = AccountManager.get(this).getAuthenticatorTypes();
- Set<String> supportedAccountTypes = new HashSet<String>(descs.length);
- for (AuthenticatorDescription desc : descs) {
- supportedAccountTypes.add(desc.type);
- }
- setOfRelevantAccountTypes.retainAll(supportedAccountTypes);
+ AuthenticatorDescription[] descs = AccountManager.get(this).getAuthenticatorTypes();
+ Set<String> supportedAccountTypes = new HashSet<String>(descs.length);
+ for (AuthenticatorDescription desc : descs) {
+ supportedAccountTypes.add(desc.type);
+ }
+ if (allowedAccountTypes != null) {
+ setOfRelevantAccountTypes = Sets.newHashSet(allowedAccountTypes);
+ setOfRelevantAccountTypes.retainAll(supportedAccountTypes);
+ } else {
+ setOfRelevantAccountTypes = supportedAccountTypes;
}
return setOfRelevantAccountTypes;
}