Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96fb8b5e authored by Wenyi Wang's avatar Wenyi Wang
Browse files

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
parent 5f3c81ed
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import com.android.contacts.common.model.AccountTypeManager;
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 @@ public abstract class MultiSelectContactsListFragment<T extends MultiSelectEntry

        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 @@ public abstract class MultiSelectContactsListFragment<T extends MultiSelectEntry
        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 @@ public abstract class MultiSelectContactsListFragment<T extends MultiSelectEntry
        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();