private List<AccountWithDataSet> getAccounts(AccountListFilter accountListFilter) { if (accountListFilter == AccountListFilter.ACCOUNTS_GROUP_WRITABLE) { return new ArrayList<AccountWithDataSet>(mAccountTypes.getGroupWritableAccounts()); } return new ArrayList<AccountWithDataSet>(mAccountTypes.getAccounts( accountListFilter == AccountListFilter.ACCOUNTS_CONTACT_WRITABLE)); }
/** * @param contactWritableOnly if true, it only returns ones that support writing contacts. * @return true when this instance contains the given account. */ public boolean contains(AccountWithDataSet account, boolean contactWritableOnly) { for (AccountWithDataSet account_2 : getAccounts(false)) { if (account.equals(account_2)) { return true; } } return false; } }
/** * @return google accounts with "com.google" account type and null data set. */ private List<Account> getFocusGoogleAccounts() { List<Account> focusGoogleAccounts = new ArrayList<Account>(); final AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(mContext); List<AccountWithDataSet> accounts = accountTypeManager.getAccounts(true); for (AccountWithDataSet account : accounts) { if (GoogleAccountType.ACCOUNT_TYPE.equals(account.type) && account.dataSet == null) { focusGoogleAccounts.add(account.getAccountOrNull()); } } return focusGoogleAccounts; }
final List<AccountWithDataSet> accountList = accountTypes.getAccounts(true); if (accountList.size() == 0) { Log.w(LOG_TAG, "Account does not exist");
private void prepare() { mPreferences = new ContactsPreferences(getContext()); mAccountMap = new HashMap<>(); final AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(getContext()); List<AccountWithDataSet> accounts = accountTypeManager.getAccounts(true); for (AccountWithDataSet account : accounts) { mAccountMap.put(account.name, account); } final Set<String> accountNames = mAccountMap.keySet(); final String[] accountNamesArray = accountNames.toArray(new String[accountNames.size()]); setEntries(accountNamesArray); setEntryValues(accountNamesArray); final String defaultAccount = String.valueOf(mPreferences.getDefaultAccount()); if (accounts.size() == 1) { setValue(accounts.get(0).name); } else if (accountNames.contains(defaultAccount)) { setValue(defaultAccount); } else { setValue(null); } }
private static List<ContactListFilter> loadAccountFilters(Context context) { final ArrayList<ContactListFilter> result = Lists.newArrayList(); final ArrayList<ContactListFilter> accountFilters = Lists.newArrayList(); final AccountTypeManager accountTypes = AccountTypeManager.getInstance(context); List<AccountWithDataSet> accounts = accountTypes.getAccounts(false); for (AccountWithDataSet account : accounts) { AccountType accountType = accountTypes.getAccountType(account.type, account.dataSet); if (accountType.isExtension() && !account.hasData(context)) { // Hide extensions with no raw_contacts. continue; } Drawable icon = accountType != null ? accountType.getDisplayIcon(context) : null; accountFilters.add(ContactListFilter.createAccountFilter( account.type, account.name, account.dataSet, icon)); } // Always show "All", even when there's no accounts. (We may have local contacts) result.add(ContactListFilter.createFilterWithType( ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS)); final int count = accountFilters.size(); if (count >= 1) { // If we only have one account, don't show it as "account", instead show it as "all" if (count > 1) { result.addAll(accountFilters); } result.add(ContactListFilter.createFilterWithType( ContactListFilter.FILTER_TYPE_CUSTOM)); } return result; }
DialogInterface.OnCancelListener onCancelListener) { final AccountTypeManager accountTypes = AccountTypeManager.getInstance(context); final List<AccountWithDataSet> writableAccountList = accountTypes.getAccounts(true);
final List<AccountWithDataSet> accountList = accountTypes.getAccounts(true); if (accountList.size() == 0) { mAccount = null;
final List<AccountWithDataSet> accountList = accountTypes.getAccounts(true); final int size = accountList.size(); if (size > 1) {
} else { final AccountTypeManager accountTypes = AccountTypeManager.getInstance(this); final List<AccountWithDataSet> accountList = accountTypes.getAccounts(true); if (accountList.size() == 0) { mAccount = null;
private void removeUnsupportedPreferences() { // Disable sort order for CJK locales where it is not supported final Resources resources = getResources(); if (!resources.getBoolean(R.bool.config_sort_order_user_changeable)) { getPreferenceScreen().removePreference(findPreference("sortOrder")); } // Disable display order for CJK locales as well if (!resources.getBoolean(R.bool.config_display_order_user_changeable)) { getPreferenceScreen().removePreference(findPreference("displayOrder")); } // Remove the "Default account" setting if there aren't any writable accounts final AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(getContext()); final List<AccountWithDataSet> accounts = accountTypeManager.getAccounts( /* contactWritableOnly */ true); if (accounts.isEmpty()) { getPreferenceScreen().removePreference(findPreference("accounts")); } }
for (AccountWithDataSet account : accountTypes.getAccounts(false)) { final AccountType accountType = accountTypes.getAccountTypeForAccount(account); if (accountType.isExtension() && !account.hasData(context)) {