Merge change Ibb6bf6b8 into eclair
* changes:
Minor cosmetic cleanups.
diff --git a/res/layout-finger/contacts_list_show_all_item.xml b/res/layout-finger/contacts_list_show_all_item.xml
new file mode 100644
index 0000000..5937b9f
--- /dev/null
+++ b/res/layout-finger/contacts_list_show_all_item.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+>
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="?android:attr/listPreferredItemHeight"
+ android:gravity="center_vertical|left"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:text="@string/showAllContactsJoinItem"
+ android:paddingLeft="14dip"
+ />
+
+ <View android:id="@+id/list_divider"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:background="@*android:drawable/divider_horizontal_dark_opaque"
+ />
+</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index da7bb88..1ea5409 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -144,8 +144,11 @@
<!-- Info blurb on the Join Contact screen -->
<string name="blurbJoinContactDataWith">Select the contact you want to join with <xliff:g id="name">%s</xliff:g>.</string>
+ <!-- An item in the Join Contact activity that opens up the full contact A-Z list -->
+ <string name="showAllContactsJoinItem">Show all contacts</string>
+
<!-- List separator for the Join Contact list: Suggestions -->
- <string name="separatorJoinAggregateSuggestions">Suggestions</string>
+ <string name="separatorJoinAggregateSuggestions">Suggested contacts</string>
<!-- List separator for the Join Contact list: A-Z -->
<string name="separatorJoinAggregateAll">All contacts</string>
diff --git a/src/com/android/contacts/ContactsListActivity.java b/src/com/android/contacts/ContactsListActivity.java
index aa6654d..f164289 100644
--- a/src/com/android/contacts/ContactsListActivity.java
+++ b/src/com/android/contacts/ContactsListActivity.java
@@ -40,6 +40,7 @@
import android.content.res.Resources;
import android.database.CharArrayBuffer;
import android.database.Cursor;
+import android.database.MatrixCursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
@@ -359,9 +360,21 @@
private static final String CLAUSE_ONLY_VISIBLE = Contacts.IN_VISIBLE_GROUP + "=1";
private static final String CLAUSE_ONLY_PHONES = Contacts.HAS_PHONE_NUMBER + "=1";
+ /**
+ * In the {@link #MODE_JOIN} determines whether we display a list item with the label
+ * "Show all contacts" or actually show all contacts
+ */
+ private boolean mJoinModeShowAllContacts;
+
+ /**
+ * The ID of the special item described above.
+ */
+ private static final long JOIN_MODE_SHOW_ALL_CONTACTS_ID = -2;
+
// Uri matcher for contact id
private static final int CONTACTS_ID = 1001;
private static final UriMatcher sContactsIdMatcher;
+
static {
sContactsIdMatcher = new UriMatcher(UriMatcher.NO_MATCH);
sContactsIdMatcher.addURI(ContactsContract.AUTHORITY, "contacts/#", CONTACTS_ID);
@@ -566,7 +579,7 @@
String blurb = getString(R.string.blurbJoinContactDataWith, contactName);
blurbView.setText(blurb);
-
+ mJoinModeShowAllContacts = true;
} else {
setContentView(R.layout.contacts_list_content);
}
@@ -1132,7 +1145,12 @@
final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivityForResult(intent, SUBACTIVITY_VIEW_CONTACT);
} else if (mMode == MODE_JOIN_CONTACT) {
- returnPickerResult(null, null, uri, id);
+ if (id == JOIN_MODE_SHOW_ALL_CONTACTS_ID) {
+ mJoinModeShowAllContacts = false;
+ startQuery();
+ } else {
+ returnPickerResult(null, null, uri, id);
+ }
} else if (mMode == MODE_QUERY_PICK_TO_VIEW) {
// Started with query that should launch to view contact
final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
@@ -1701,6 +1719,7 @@
Cursor cursor = resolver.query(getJoinSuggestionsUri(filter), projection, null,
null, null);
mAdapter.setSuggestionsCursor(cursor);
+ mJoinModeShowAllContacts = false;
return resolver.query(getContactFilterUri(filter), projection,
Contacts._ID + " != " + mQueryAggregateId + " AND " + CLAUSE_ONLY_VISIBLE,
null, getSortOrder(projection));
@@ -1709,6 +1728,15 @@
throw new UnsupportedOperationException("filtering not allowed in mode " + mMode);
}
+ private Cursor getShowAllContactsLabelCursor(String[] projection) {
+ MatrixCursor matrixCursor = new MatrixCursor(projection);
+ Object[] row = new Object[projection.length];
+ // The only columns we care about is the id
+ row[SUMMARY_ID_COLUMN_INDEX] = JOIN_MODE_SHOW_ALL_CONTACTS_ID;
+ matrixCursor.addRow(row);
+ return matrixCursor;
+ }
+
/**
* Calls the currently selected list item.
* @return true if the call was initiated, false otherwise
@@ -1838,15 +1866,21 @@
if (cursor.getCount() > 0) {
activity.mAdapter.setSuggestionsCursor(cursor);
} else {
+ cursor.close();
activity.mAdapter.setSuggestionsCursor(null);
}
- startQuery(QUERY_TOKEN, null, activity.getContactFilterUri(activity.mQuery),
- CONTACTS_SUMMARY_PROJECTION,
- Contacts._ID + " != " + activity.mQueryAggregateId
- + " AND " + CLAUSE_ONLY_VISIBLE, null,
- getSortOrder(CONTACTS_SUMMARY_PROJECTION));
- return;
+ if (activity.mAdapter.mSuggestionsCursorCount == 0
+ || !activity.mJoinModeShowAllContacts) {
+ startQuery(QUERY_TOKEN, null, activity.getContactFilterUri(activity.mQuery),
+ CONTACTS_SUMMARY_PROJECTION,
+ Contacts._ID + " != " + activity.mQueryAggregateId
+ + " AND " + CLAUSE_ONLY_VISIBLE, null,
+ getSortOrder(CONTACTS_SUMMARY_PROJECTION));
+ return;
+ }
+
+ cursor = activity.getShowAllContactsLabelCursor(CONTACTS_SUMMARY_PROJECTION);
}
activity.mAdapter.setLoading(false);
@@ -2077,6 +2111,9 @@
if (position == 0 && (mMode & MODE_MASK_SHOW_NUMBER_OF_CONTACTS) != 0) {
return IGNORE_ITEM_VIEW_TYPE;
}
+ if (isShowAllContactsItemPosition(position)) {
+ return IGNORE_ITEM_VIEW_TYPE;
+ }
if (getSeparatorId(position) != 0) {
// We don't want the separator view to be recycled.
return IGNORE_ITEM_VIEW_TYPE;
@@ -2102,6 +2139,12 @@
return totalContacts;
}
+ if (isShowAllContactsItemPosition(position)) {
+ LayoutInflater inflater =
+ (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ return inflater.inflate(R.layout.contacts_list_show_all_item, parent, false);
+ }
+
// Handle the separator specially
int separatorId = getSeparatorId(position);
if (separatorId != 0) {
@@ -2138,6 +2181,11 @@
return v;
}
+ private boolean isShowAllContactsItemPosition(int position) {
+ return mMode == MODE_JOIN_CONTACT && mJoinModeShowAllContacts
+ && mSuggestionsCursorCount != 0 && position == mSuggestionsCursorCount + 2;
+ }
+
private int getSeparatorId(int position) {
int separatorId = 0;
if (position == mFrequentSeparatorPos) {