Automated import from //branches/master/...@141107,141107
diff --git a/res/drawable-finger/ic_contact_list_picture.png b/res/drawable-finger/ic_contact_list_picture.png
new file mode 100644
index 0000000..f8aa4ba
--- /dev/null
+++ b/res/drawable-finger/ic_contact_list_picture.png
Binary files differ
diff --git a/res/drawable-finger/ic_contact_list_picture_2.png b/res/drawable-finger/ic_contact_list_picture_2.png
new file mode 100644
index 0000000..771ffb2
--- /dev/null
+++ b/res/drawable-finger/ic_contact_list_picture_2.png
Binary files differ
diff --git a/res/drawable-finger/ic_contact_list_picture_3.png b/res/drawable-finger/ic_contact_list_picture_3.png
new file mode 100644
index 0000000..92c1213
--- /dev/null
+++ b/res/drawable-finger/ic_contact_list_picture_3.png
Binary files differ
diff --git a/res/layout-finger/list_separator.xml b/res/layout-finger/list_separator.xml
index 5d93d36..0c21541 100644
--- a/res/layout-finger/list_separator.xml
+++ b/res/layout-finger/list_separator.xml
@@ -16,12 +16,5 @@
<!-- Layout used for list separators. -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:background="@android:drawable/dark_header"
- android:textColor="?android:attr/textColorSecondary"
- android:textStyle="bold"
- android:textSize="14sp"
- android:paddingLeft="8dip"
+ style="?android:attr/listSeparatorTextViewStyle"
/>
diff --git a/src/com/android/contacts/ContactsListActivity.java b/src/com/android/contacts/ContactsListActivity.java
index c504f0f..1491040 100644
--- a/src/com/android/contacts/ContactsListActivity.java
+++ b/src/com/android/contacts/ContactsListActivity.java
@@ -16,6 +16,8 @@
package com.android.contacts;
+import static com.android.contacts.ShowOrCreateActivity.QUERY_KIND_EMAIL_OR_IM;
+
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ListActivity;
@@ -32,6 +34,7 @@
import android.content.SharedPreferences;
import android.database.CharArrayBuffer;
import android.database.Cursor;
+import android.database.CursorWrapper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
@@ -70,8 +73,6 @@
import android.widget.SectionIndexer;
import android.widget.TextView;
-import static com.android.contacts.ShowOrCreateActivity.QUERY_KIND_EMAIL_OR_IM;
-
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -1414,6 +1415,7 @@
private CharSequence[] mLocalizedLabels;
private boolean mDisplayPhotos = false;
private SparseArray<SoftReference<Bitmap>> mBitmapCache = null;
+ private int mFrequentSeparatorPos = ListView.INVALID_POSITION;
public ContactItemListAdapter(Context context) {
super(context, R.layout.contacts_list_item, null, false);
@@ -1486,6 +1488,45 @@
}
@Override
+ public int getItemViewType(int position) {
+ if (position == mFrequentSeparatorPos) {
+ // We don't want the separator view to be recycled.
+ return IGNORE_ITEM_VIEW_TYPE;
+ }
+ return super.getItemViewType(position);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (!mDataValid) {
+ throw new IllegalStateException(
+ "this should only be called when the cursor is valid");
+ }
+
+ // Handle the separator specially
+ if (position == mFrequentSeparatorPos) {
+ LayoutInflater inflater =
+ (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ TextView view = (TextView) inflater.inflate(R.layout.list_separator, parent, false);
+ view.setText(R.string.favoritesFrquentSeparator);
+ return view;
+ }
+
+ if (!mCursor.moveToPosition(getRealPosition(position))) {
+ throw new IllegalStateException("couldn't move cursor to position " + position);
+ }
+
+ View v;
+ if (convertView == null) {
+ v = newView(mContext, mCursor, parent);
+ } else {
+ v = convertView;
+ }
+ bindView(v, mContext, mCursor);
+ return v;
+ }
+
+ @Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final View view = super.newView(context, cursor, parent);
@@ -1549,27 +1590,18 @@
// Set the proper icon (star or presence or nothing)
ImageView presenceView = cache.presenceView;
- if (mMode != MODE_STREQUENT) {
- if ((mMode & MODE_MASK_NO_PRESENCE) == 0) {
- int serverStatus;
- if (!cursor.isNull(SERVER_STATUS_COLUMN_INDEX)) {
- serverStatus = cursor.getInt(SERVER_STATUS_COLUMN_INDEX);
- presenceView.setImageResource(
- Presence.getPresenceIconResourceId(serverStatus));
- presenceView.setVisibility(View.VISIBLE);
- } else {
- presenceView.setVisibility(View.GONE);
- }
- } else {
- presenceView.setVisibility(View.GONE);
- }
- } else {
- if (cursor.getInt(STARRED_COLUMN_INDEX) != 0) {
- presenceView.setImageResource(R.drawable.star_on);
+ if ((mMode & MODE_MASK_NO_PRESENCE) == 0) {
+ int serverStatus;
+ if (!cursor.isNull(SERVER_STATUS_COLUMN_INDEX)) {
+ serverStatus = cursor.getInt(SERVER_STATUS_COLUMN_INDEX);
+ presenceView.setImageResource(
+ Presence.getPresenceIconResourceId(serverStatus));
presenceView.setVisibility(View.VISIBLE);
} else {
presenceView.setVisibility(View.GONE);
}
+ } else {
+ presenceView.setVisibility(View.GONE);
}
// Set the photo, if requested
@@ -1602,13 +1634,29 @@
if (photo != null) {
cache.photoView.setImageBitmap(photo);
} else {
- cache.photoView.setImageResource(R.drawable.ic_contact_picture);
+ cache.photoView.setImageResource(R.drawable.ic_contact_list_picture);
}
}
}
@Override
public void changeCursor(Cursor cursor) {
+ // Get the split between starred and frequent items, if the mode is strequent
+ mFrequentSeparatorPos = ListView.INVALID_POSITION;
+ if (cursor != null && cursor.getCount() > 0 && mMode == MODE_STREQUENT) {
+ cursor.move(-1);
+ for (int i = 0; cursor.moveToNext(); i++) {
+ int starred = cursor.getInt(STARRED_COLUMN_INDEX);
+ if (starred == 0) {
+ if (i > 0) {
+ // Only add the separator when there are starred items present
+ mFrequentSeparatorPos = i;
+ }
+ break;
+ }
+ }
+ }
+
super.changeCursor(cursor);
// Update the indexer for the fast scroll widget
@@ -1656,7 +1704,7 @@
return mIndexer.getSections();
}
}
-
+
public int getPositionForSection(int sectionIndex) {
if (mMode == MODE_STREQUENT) {
return 0;
@@ -1673,13 +1721,56 @@
return mIndexer.getPositionForSection(sectionIndex);
}
-
+
public int getSectionForPosition(int position) {
// Note: JapaneseContactListIndexer depends on the fact
// this method always returns 0. If you change this,
// please care it too.
return 0;
- }
+ }
+
+ @Override
+ public boolean areAllItemsEnabled() {
+ return mMode != MODE_STREQUENT;
+ }
+
+ @Override
+ public boolean isEnabled(int position) {
+ return position != mFrequentSeparatorPos;
+ }
+
+ @Override
+ public int getCount() {
+ if (mFrequentSeparatorPos != ListView.INVALID_POSITION) {
+ return super.getCount() + 1;
+ } else {
+ return super.getCount();
+ }
+ }
+
+ private int getRealPosition(int pos) {
+ if (mFrequentSeparatorPos == ListView.INVALID_POSITION) {
+ // No separator, identity map
+ return pos;
+ } else if (pos <= mFrequentSeparatorPos) {
+ // Before or at the separator, identity map
+ return pos;
+ } else {
+ // After the separator, remove 1 from the pos to get the real underlying pos
+ return pos - 1;
+ }
+
+ }
+
+ @Override
+ public Object getItem(int pos) {
+ return super.getItem(getRealPosition(pos));
+ }
+
+ @Override
+ public long getItemId(int pos) {
+ return super.getItemId(getRealPosition(pos));
+ }
}
}