Make total contacts header more like a separator.
diff --git a/res/layout-finger/total_contacts.xml b/res/layout-finger/total_contacts.xml
index 1221ef3..ab15ce1 100644
--- a/res/layout-finger/total_contacts.xml
+++ b/res/layout-finger/total_contacts.xml
@@ -24,6 +24,5 @@
android:textStyle="normal"
android:background="@drawable/section_dark"
android:paddingLeft="7dp"
- android:gravity="left|center_vertical"
- android:visibility="gone"
+ android:gravity="center|center_vertical"
/>
\ No newline at end of file
diff --git a/src/com/android/contacts/ContactsListActivity.java b/src/com/android/contacts/ContactsListActivity.java
index 6d2ea57..1b7dd07 100644
--- a/src/com/android/contacts/ContactsListActivity.java
+++ b/src/com/android/contacts/ContactsListActivity.java
@@ -566,14 +566,9 @@
list.setTextFilterEnabled(true);
}
- final LayoutInflater inflater = getLayoutInflater();
- if ((mMode & MODE_MASK_SHOW_NUMBER_OF_CONTACTS) != 0) {
- View totalContacts = inflater.inflate(R.layout.total_contacts, list, false);
- list.addHeaderView(totalContacts);
- }
-
if ((mMode & MODE_MASK_CREATE_NEW) != 0) {
// Add the header for creating a new contact
+ final LayoutInflater inflater = getLayoutInflater();
View header = inflater.inflate(R.layout.create_new_contact, list, false);
list.addHeaderView(header);
}
@@ -585,11 +580,6 @@
setListAdapter(mAdapter);
getListView().setOnScrollListener(mAdapter);
- if ((mMode & MODE_MASK_SHOW_NUMBER_OF_CONTACTS) != 0) {
- TextView totalContacts = (TextView) findViewById(R.id.totalContactsText);
- totalContacts.setVisibility(View.VISIBLE);
- }
-
// We manually save/restore the listview state
list.setSaveEnabled(false);
@@ -1094,13 +1084,6 @@
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(mList.getWindowToken(), 0);
- if ((mMode & MODE_MASK_SHOW_NUMBER_OF_CONTACTS) != 0) {
- if (position == 0) {
- return;
- }
- position--;
- }
-
if (mMode == MODE_INSERT_OR_EDIT_CONTACT) {
Intent intent;
if (position == 0) {
@@ -2071,6 +2054,9 @@
@Override
public int getItemViewType(int position) {
+ if (position == 0 && (mMode & MODE_MASK_SHOW_NUMBER_OF_CONTACTS) != 0) {
+ return IGNORE_ITEM_VIEW_TYPE;
+ }
if (getSeparatorId(position) != 0) {
// We don't want the separator view to be recycled.
return IGNORE_ITEM_VIEW_TYPE;
@@ -2085,6 +2071,17 @@
"this should only be called when the cursor is valid");
}
+ // handle the total contacts item
+ if (position == 0 && (mMode & MODE_MASK_SHOW_NUMBER_OF_CONTACTS) != 0) {
+ final LayoutInflater inflater = getLayoutInflater();
+ TextView totalContacts = (TextView) inflater.inflate(R.layout.total_contacts,
+ parent, false);
+ int stringId = mDisplayOnlyPhones ? R.string.listTotalPhoneContacts
+ : R.string.listTotalAllContacts;
+ totalContacts.setText(getString(stringId, getCount()));
+ return totalContacts;
+ }
+
// Handle the separator specially
int separatorId = getSeparatorId(position);
if (separatorId != 0) {
@@ -2380,12 +2377,6 @@
}
super.changeCursor(cursor);
- if ((mMode & MODE_MASK_SHOW_NUMBER_OF_CONTACTS) != 0) {
- TextView totalContacts = (TextView) findViewById(R.id.totalContactsText);
- int stringId = mDisplayOnlyPhones
- ? R.string.listTotalPhoneContacts : R.string.listTotalAllContacts;
- totalContacts.setText(getString(stringId, cursorCount));
- }
// Update the indexer for the fast scroll widget
updateIndexer(cursor);
}
@@ -2497,6 +2488,12 @@
@Override
public boolean isEnabled(int position) {
+ if ((mMode & MODE_MASK_SHOW_NUMBER_OF_CONTACTS) != 0) {
+ if (position == 0) {
+ return false;
+ }
+ position--;
+ }
if (mSuggestionsCursorCount > 0) {
return position != 0 && position != mSuggestionsCursorCount + 1;
}
@@ -2519,6 +2516,9 @@
}
private int getRealPosition(int pos) {
+ if ((mMode & MODE_MASK_SHOW_NUMBER_OF_CONTACTS) != 0) {
+ pos--;
+ }
if (mSuggestionsCursorCount != 0) {
// When showing suggestions, we have 2 additional list items: the "Suggestions"
// and "All contacts" separators.