public final AccountType getAccountTypeForAccount(AccountWithDataSet account) { if (account != null) { return getAccountType(account.getAccountTypeWithDataSet()); } return getAccountType(null, null); }
public final AccountType getAccountType(String accountType, String dataSet) { return getAccountType(AccountTypeWithDataSet.get(accountType, dataSet)); }
@Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { if (convertView == null) { convertView = mInflater.inflate( R.layout.custom_contact_list_filter_account, parent, false); } final TextView text1 = (TextView)convertView.findViewById(android.R.id.text1); final TextView text2 = (TextView)convertView.findViewById(android.R.id.text2); final AccountDisplay account = (AccountDisplay)this.getGroup(groupPosition); final AccountType accountType = mAccountTypes.getAccountType( account.mType, account.mDataSet); text1.setText(account.mName); text1.setVisibility(account.mName == null ? View.GONE : View.VISIBLE); text2.setText(accountType.getDisplayLabel(mContext)); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { final View resultView = convertView != null ? convertView : mInflater.inflate(mCustomLayout > 0 ? mCustomLayout : R.layout.account_selector_list_item, parent, false); final TextView text1 = (TextView) resultView.findViewById(android.R.id.text1); final TextView text2 = (TextView) resultView.findViewById(android.R.id.text2); final ImageView icon = (ImageView) resultView.findViewById(android.R.id.icon); final AccountWithDataSet account = mAccounts.get(position); final AccountType accountType = mAccountTypes.getAccountType(account.type, account.dataSet); text1.setText(accountType.getDisplayLabel(mContext)); // For email addresses, we don't want to truncate at end, which might cut off the domain // name. text2.setText(account.name); text2.setEllipsize(TruncateAt.MIDDLE); icon.setImageDrawable(accountType.getDisplayIcon(mContext)); return resultView; }
public AccountType getAccountType(AccountTypeManager manager) { return manager.getAccountType(getAccountType(), getDataSet()); }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = dialogInflater.inflate( R.layout.account_selector_list_item_condensed, parent, false); } final TextView text1 = (TextView) convertView.findViewById(android.R.id.text1); final TextView text2 = (TextView) convertView.findViewById(android.R.id.text2); final ImageView icon = (ImageView) convertView.findViewById(android.R.id.icon); final AccountWithDataSet account = this.getItem(position); final AccountType accountType = accountTypes.getAccountType( account.type, account.dataSet); final Context context = getContext(); text1.setText(accountType.getDisplayLabel(context)); text2.setText(account.name); icon.setImageDrawable(accountType.getDisplayIcon(getContext())); return convertView; } };
public AccountType getAccountType(Context context) { return getAccountTypeManager(context).getAccountType(getAccountTypeString(), getDataSet()); }
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; }
/** * Processing to trim any empty {@link ValuesDelta} and {@link RawContactDelta} * from the given {@link RawContactDeltaList}, assuming the given {@link AccountTypeManager} * dictates the structure for various fields. This method ignores rows not * described by the {@link AccountType}. */ public static void trimEmpty(RawContactDeltaList set, AccountTypeManager accountTypes) { for (RawContactDelta state : set) { ValuesDelta values = state.getValues(); final String accountType = values.getAsString(RawContacts.ACCOUNT_TYPE); final String dataSet = values.getAsString(RawContacts.DATA_SET); final AccountType type = accountTypes.getAccountType(accountType, dataSet); trimEmpty(state, type); } }
/** * 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); }
accountTypes.getAccountType(mFilter.accountType, mFilter.dataSet); mAccountUserName.setText(mFilter.accountName); mAccountType.setText(accountType.getDisplayLabel(getContext()));
public static boolean hasChanges(RawContactDeltaList set, AccountTypeManager accountTypes, Set<String> excludedMimeTypes) { if (set.isMarkedForSplitting() || set.isMarkedForJoining()) { return true; } for (RawContactDelta state : set) { ValuesDelta values = state.getValues(); final String accountType = values.getAsString(RawContacts.ACCOUNT_TYPE); final String dataSet = values.getAsString(RawContacts.DATA_SET); final AccountType type = accountTypes.getAccountType(accountType, dataSet); if (hasChanges(state, type, excludedMimeTypes)) { return true; } } return false; }