public AccountTypeManager getAccountTypeManager(Context context) { if (mAccountTypeManager == null) { mAccountTypeManager = AccountTypeManager.getInstance(context); } return mAccountTypeManager; }
public DisplayAdapter(Context context) { mContext = context; mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mAccountTypes = AccountTypeManager.getInstance(context); }
public FilterListAdapter( Context context, List<ContactListFilter> filters, ContactListFilter current) { mLayoutInflater = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); mFilters = filters; mCurrentFilter = current; mAccountTypes = AccountTypeManager.getInstance(context); }
public static boolean areGroupWritableAccountsAvailable(Context context) { final List<AccountWithDataSet> accounts = AccountTypeManager.getInstance(context).getGroupWritableAccounts(); return !accounts.isEmpty(); }
/** * @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; }
/** * @param currentAccount the Account currently selected by the user, which should come * first in the list. Can be null. */ public AccountsListAdapter(Context context, AccountListFilter accountListFilter, AccountWithDataSet currentAccount) { mContext = context; mAccountTypes = AccountTypeManager.getInstance(context); mAccounts = getAccounts(accountListFilter); if (currentAccount != null && !mAccounts.isEmpty() && !mAccounts.get(0).equals(currentAccount) && mAccounts.remove(currentAccount)) { mAccounts.add(0, currentAccount); } mInflater = LayoutInflater.from(context); }
/** * @return true if the Account for the current filter exists. */ private boolean filterAccountExists() { final AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(mContext); final AccountWithDataSet filterAccount = new AccountWithDataSet( mFilter.accountName, mFilter.accountType, mFilter.dataSet); return accountTypeManager.contains(filterAccount, false); } }
/** * If any permissions the Contacts app needs are missing, open an Activity * to prompt the user for these permissions. Moreover, finish the current activity. * * This is designed to be called inside {@link android.app.Activity#onCreate} */ protected static boolean startPermissionActivity(Activity activity, String[] requiredPermissions, Class<?> newActivityClass) { if (!hasPermissions(activity, requiredPermissions)) { final Intent intent = new Intent(activity, newActivityClass); activity.getIntent().putExtra(STARTED_PERMISSIONS_ACTIVITY, true); intent.putExtra(PREVIOUS_ACTIVITY_INTENT, activity.getIntent()); activity.startActivity(intent); activity.finish(); return true; } // Account type initialization must be delayed until the Contacts permission group // has been granted (since GET_ACCOUNTS) falls under that groups. Previously it // was initialized in ContactApplication which would cause problems as // AccountManager.getAccounts would return an empty array. See b/22690336 AccountTypeManager.getInstance(activity); return false; }
final AccountTypeManager accountTypes = AccountTypeManager.getInstance(this); final List<AccountWithDataSet> accountList = accountTypes.getAccounts(true); if (accountList.size() == 0) {
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); } }
/** * Sets the "invitable" account types to {@link Contact#mInvitableAccountTypes}. */ private void loadInvitableAccountTypes(Contact contactData) { final ImmutableList.Builder<AccountType> resultListBuilder = new ImmutableList.Builder<AccountType>(); if (!contactData.isUserProfile()) { Map<AccountTypeWithDataSet, AccountType> invitables = AccountTypeManager.getInstance(getContext()).getUsableInvitableAccountTypes(); if (!invitables.isEmpty()) { final Map<AccountTypeWithDataSet, AccountType> resultMap = Maps.newHashMap(invitables); // Remove the ones that already have a raw contact in the current contact for (RawContact rawContact : contactData.getRawContacts()) { final AccountTypeWithDataSet type = AccountTypeWithDataSet.get( rawContact.getAccountTypeString(), rawContact.getDataSet()); resultMap.remove(type); } resultListBuilder.addAll(resultMap.values()); } } // Set to mInvitableAccountTypes contactData.setInvitableAccountTypes(resultListBuilder.build()); }
mRecord = msg.getRecords()[0]; final AccountTypeManager accountTypes = AccountTypeManager.getInstance(this); final List<AccountWithDataSet> accountList = accountTypes.getAccounts(true); if (accountList.size() == 0) {
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.OnClickListener onClickListener, DialogInterface.OnCancelListener onCancelListener) { final AccountTypeManager accountTypes = AccountTypeManager.getInstance(context); final List<AccountWithDataSet> writableAccountList = accountTypes.getAccounts(true);
final AccountTypeManager accountTypes = AccountTypeManager.getInstance(getActivity()); final List<AccountWithDataSet> accountList = accountTypes.getAccounts(true); final int size = accountList.size();
mAccount = new AccountWithDataSet(accountName, accountType, dataSet); } else { final AccountTypeManager accountTypes = AccountTypeManager.getInstance(this); final List<AccountWithDataSet> accountList = accountTypes.getAccounts(true); if (accountList.size() == 0) {
/** * Return the AccountType that this raw-contact belongs to. */ public AccountType getRawContactAccountType(Context context) { ContentValues entityValues = getValues().getCompleteValues(); String type = entityValues.getAsString(RawContacts.ACCOUNT_TYPE); String dataSet = entityValues.getAsString(RawContacts.DATA_SET); return AccountTypeManager.getInstance(context).getAccountType(type, dataSet); }
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")); } }
@Override public AccountSet loadInBackground() { Context context = getContext(); final AccountTypeManager accountTypes = AccountTypeManager.getInstance(context); final ContentResolver resolver = context.getContentResolver();