Show account name in label view if account is group writable
Bug: 32116555
Test: manual - verify account name shows up in labels of
an Exchange account and Google account.
Change-Id: I17fb2ce8538984660b439a4667261b19367fc3c4
diff --git a/src/com/android/contacts/list/MultiSelectContactsListFragment.java b/src/com/android/contacts/list/MultiSelectContactsListFragment.java
index 41fd11e..10e9370 100644
--- a/src/com/android/contacts/list/MultiSelectContactsListFragment.java
+++ b/src/com/android/contacts/list/MultiSelectContactsListFragment.java
@@ -45,6 +45,7 @@
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.model.account.GoogleAccountType;
+import com.android.contacts.group.GroupMembersFragment;
import java.util.ArrayList;
import java.util.List;
@@ -375,10 +376,14 @@
bindListHeaderCommon(listView, accountFilterContainer);
- // Set text of count of contacts and account name (if it's a Google account)
+ final AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(context);
+ final AccountType accountType = accountTypeManager.getAccountType(
+ accountWithDataSet.type, accountWithDataSet.dataSet);
+
+ // Set text of count of contacts and account name
final TextView accountFilterHeader = (TextView) accountFilterContainer.findViewById(
R.id.account_filter_header);
- final String headerText = GoogleAccountType.ACCOUNT_TYPE.equals(accountWithDataSet.type)
+ final String headerText = shouldShowAccountName(accountType)
? String.format(context.getResources().getQuantityString(
R.plurals.contacts_count_with_account, memberCount),
memberCount, accountWithDataSet.name)
@@ -388,9 +393,6 @@
accountFilterHeader.setAllCaps(false);
// Set icon of the account
- final AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(context);
- final AccountType accountType = accountTypeManager.getAccountType(
- accountWithDataSet.type, accountWithDataSet.dataSet);
final Drawable icon = accountType != null ? accountType.getDisplayIcon(context) : null;
final ImageView accountFilterHeaderIcon = (ImageView) accountFilterContainer
.findViewById(R.id.account_filter_icon);
@@ -427,6 +429,11 @@
accountFilterHeaderIcon.setImageDrawable(icon);
}
+ private boolean shouldShowAccountName(AccountType accountType) {
+ return (accountType.isGroupMembershipEditable() && this instanceof GroupMembersFragment)
+ || GoogleAccountType.ACCOUNT_TYPE.equals(accountType.accountType);
+ }
+
private void setMargins(View v, int l, int r) {
if (v.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) v.getLayoutParams();