在通訊錄中新增聯絡人統計功能
阿新 • • 發佈:2019-01-08
- packages/apps/Contacts/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
--- a/alps/packages/apps/Contacts/src/com/android/contacts/list/DefaultContactBrowseListFragment.java +++ b/alps/packages/apps/Contacts/src/com/android/contacts/list/DefaultContactBrowseListFragment.java @@ -71,6 +71,7 @@ public class DefaultContactBrowseListFragment extends ContactBrowseListFragment private TextView mProfileTitle; private View mSearchProgress; private TextView mSearchProgressText; + private TextView headerTextView; private class FilterHeaderClickListener implements OnClickListener { @Override @@ -146,6 +147,7 @@ public class DefaultContactBrowseListFragment extends ContactBrowseListFragment mAccountFilterHeader = getView().findViewById(R.id.account_filter_header_container); mAccountFilterHeader.setOnClickListener(mFilterHeaderClickListener); + headerTextView = (TextView) mAccountFilterHeader.findViewById(R.id.account_filter_header); // Create an entry for public account and show it from now ExtensionManager.getInstance().getRcsExtension() .createPublicAccountEntryView(getListView()); @@ -211,6 +213,7 @@ public class DefaultContactBrowseListFragment extends ContactBrowseListFragment } else { mAccountFilterHeader.setVisibility(View.GONE); } + getContactCount(); } @Override @@ -242,6 +245,7 @@ public class DefaultContactBrowseListFragment extends ContactBrowseListFragment } showEmptyUserProfile(false); } + getContactCount(); } @Override @@ -322,6 +326,12 @@ public class DefaultContactBrowseListFragment extends ContactBrowseListFragment if (mUserProfileExists) { count -= PROFILE_NUM; } + if(headerTextView != null && AccountFilterUtil.mText != null){ + String contacts = AccountFilterUtil.mText + " (" + String.valueOf(count) + " CONTACTS)"; + headerTextView.setText(contacts); + } return count; } }
- packages/apps/ContactsCommon/src/com/android/contacts/common/util/AccountFilterUtil.java
--- a/alps/packages/apps/ContactsCommon/src/com/android/contacts/common/util/AccountFilterUtil.java +++ b/alps/packages/apps/ContactsCommon/src/com/android/contacts/common/util/AccountFilterUtil.java @@ -46,6 +46,7 @@ import java.util.List; */ public class AccountFilterUtil { private static final String TAG = AccountFilterUtil.class.getSimpleName(); + public static String mText; /** * Find TextView with the id "account_filter_header" and set correct text for the account @@ -102,10 +103,13 @@ public class AccountFilterUtil { // The previous lines are provided and maintained by Mediatek inc. if (forPhone) { if (filter.filterType == ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS) { - if (showTitleForAllAccounts) { + //if (showTitleForAllAccounts) { + mText = context.getString(R.string.list_filter_phones); headerTextView.setText(R.string.list_filter_phones); textWasSet = true; - } + //} } else if (filter.filterType == ContactListFilter.FILTER_TYPE_ACCOUNT) { // The following lines are provided and maintained by Mediatek Inc. // Description: for SIM name display @@ -116,11 +120,16 @@ public class AccountFilterUtil { displayName = context.getResources() .getString(R.string.local_phone_account); } - headerTextView.setText(context.getString( - R.string.listAllContactsInAccount, displayName)); + //headerTextView.setText(context.getString( + // R.string.listAllContactsInAccount, displayName)); + mText = context.getString(R.string.listAllContactsInAccount, displayName) + ""; + headerTextView.setText(mText); // The previous lines are provided and maintained by Mediatek inc. textWasSet = true; } else if (filter.filterType == ContactListFilter.FILTER_TYPE_CUSTOM) { + mText = context.getString(R.string.listCustomView); headerTextView.setText(R.string.listCustomView); textWasSet = true; } else { @@ -128,10 +137,13 @@ public class AccountFilterUtil { } } else { if (filter.filterType == ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS) { - if (showTitleForAllAccounts) { + //if (showTitleForAllAccounts) { + mText = context.getString(R.string.list_filter_all_accounts); headerTextView.setText(R.string.list_filter_all_accounts); textWasSet = true; - } + //} } else if (filter.filterType == ContactListFilter.FILTER_TYPE_ACCOUNT) { // The following lines are provided and maintained by Mediatek Inc. // Description: for SIM name display @@ -142,14 +154,20 @@ public class AccountFilterUtil { displayName = context.getResources() .getString(R.string.local_phone_account); } - headerTextView.setText(context.getString( - R.string.listAllContactsInAccount, displayName)); + //headerTextView.setText(context.getString( + // R.string.listAllContactsInAccount, displayName)); + mText = context.getString(R.string.listAllContactsInAccount, displayName) + ""; + headerTextView.setText(mText); // The previous lines are provided and maintained by Mediatek inc. textWasSet = true; } else if (filter.filterType == ContactListFilter.FILTER_TYPE_CUSTOM) { + mText = context.getString(R.string.listCustomView); headerTextView.setText(R.string.listCustomView); textWasSet = true; } else if (filter.filterType == ContactListFilter.FILTER_TYPE_SINGLE_CONTACT) { + mText = context.getString(R.string.listSingleContact); headerTextView.setText(R.string.listSingleContact); textWasSet = true; } else {