Fit-and-finish. Redoing the title for contact search results.
Bug: 2534618
Change-Id: If00dd28dfcdc5596e6b6cb8a5690f5c0382200de
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c33c3e7..27590c0 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -224,14 +224,6 @@
<data android:mimeType="vnd.android.cursor.item/postal-address" android:host="contacts" />
</intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.SEARCH" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
-
- <meta-data android:name="android.app.searchable"
- android:resource="@xml/searchable"
- />
</activity>
<!-- An activity for joining contacts -->
@@ -257,6 +249,21 @@
</intent-filter>
</activity>
+ <!-- The contacts search/filter UI -->
+ <activity android:name="SearchResultsActivity"
+ android:theme="@style/TallTitleBarTheme"
+ android:label="@string/contactsList"
+ >
+ <intent-filter>
+ <action android:name="android.intent.action.SEARCH" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+
+ <meta-data android:name="android.app.searchable"
+ android:resource="@xml/searchable"
+ />
+ </activity>
+
<!-- Used to select display and sync groups -->
<activity android:name=".ui.ContactsPreferencesActivity" android:label="@string/displayGroups" />
diff --git a/res/layout-finger/contacts_list_search_results.xml b/res/layout-finger/contacts_list_search_results.xml
new file mode 100644
index 0000000..244ca80
--- /dev/null
+++ b/res/layout-finger/contacts_list_search_results.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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:id="@+id/pinned_header_list_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:background="@*android:drawable/title_bar_medium"
+ android:paddingLeft="10dip"
+ android:paddingRight="10dip"
+ android:gravity="center_vertical"
+ >
+
+ <TextView
+ android:id="@+id/search_results_for"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/titleJoinContactDataWith"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:shadowColor="#BB000000"
+ android:shadowRadius="2.75"
+ />
+
+ <TextView
+ android:id="@+id/search_results_found"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="-2dip"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ />
+
+ </LinearLayout>
+
+ <view
+ class="com.android.contacts.PinnedHeaderListView"
+ android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:fastScrollEnabled="true"
+ />
+
+ <include layout="@layout/contacts_list_empty"/>
+
+</LinearLayout>
diff --git a/res/layout-ja-finger/edit_phonetic_name.xml b/res/layout-ja-finger/edit_phonetic_name.xml
deleted file mode 100644
index 012f85f..0000000
--- a/res/layout-ja-finger/edit_phonetic_name.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 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.
--->
-
-<!-- "Phonetic name" field on the Edit contact screen, for
- Japanese-language locales (i.e. the "furigana" or "yomi" field.) -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="?android:attr/listPreferredItemHeight"
- android:orientation="horizontal"
- android:padding="0dip"
- android:gravity="center_vertical"
- android:baselineAligned="false"
- >
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:paddingLeft="4dip"
- android:gravity="left|center_vertical"
- android:text="@string/label_phonetic_name"
- android:textAppearance="?android:attr/textAppearanceMedium"
- />
- <EditText android:id="@+id/phonetic_name"
- android:layout_width="0dip"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:layout_marginLeft="8dip"
- android:layout_marginRight="4dip"
- android:gravity="center_vertical"
- android:inputType="textPersonName|textCapWords"
- android:hint="@string/ghostData_phonetic_name"
- android:nextFocusDown="@id/data"
- />
-</LinearLayout>
diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml
index 2b6ba9a..05627d5 100644
--- a/res/values-en-rGB/strings.xml
+++ b/res/values-en-rGB/strings.xml
@@ -30,5 +30,5 @@
<string name="display_options_view_given_name_first">First name first</string>
<!-- An allowable value for the "view names as" contact display option -->
- <string name="display_options_view_family_name_first">Surname name first</string>
+ <string name="display_options_view_family_name_first">Surname first</string>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a2193c2..706b459 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1128,4 +1128,10 @@
<!-- Button shown in the contacts app if the background process updating contacts fails because of memory shortage -->
<string name="upgrade_out_of_memory_retry">Retry upgrade</string>
+
+ <!-- Title shown in the search result activity of contacts app -->
+ <string name="search_results_for">Search results for: <xliff:g id="query">%s</xliff:g></string>
+
+ <!-- Title shown in the search result activity of contacts app while searching -->
+ <string name="search_results_searching">Searching...</string>
</resources>
diff --git a/src/com/android/contacts/ContactsListActivity.java b/src/com/android/contacts/ContactsListActivity.java
index ad6589e..122e97b 100644
--- a/src/com/android/contacts/ContactsListActivity.java
+++ b/src/com/android/contacts/ContactsListActivity.java
@@ -88,6 +88,7 @@
import android.provider.ContactsContract.Intents.UI;
import android.telephony.TelephonyManager;
import android.text.Editable;
+import android.text.Html;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
@@ -447,6 +448,7 @@
private int mProviderStatus = ProviderStatus.STATUS_NORMAL;
private boolean mSearchMode;
+ private boolean mSearchResultsMode;
private boolean mShowNumberOfContacts;
private boolean mShowSearchSnippets;
@@ -713,6 +715,7 @@
mShowSearchSnippets = true;
mInitialFilter = getIntent().getStringExtra(SearchManager.QUERY);
}
+ mSearchResultsMode = true;
} else if (ACTION_SEARCH_INTERNAL.equals(action)) {
String originalAction = null;
Bundle extras = intent.getExtras();
@@ -735,6 +738,7 @@
mShowSearchSnippets = true;
mInitialFilter = getIntent().getStringExtra(SearchManager.QUERY);
}
+ mSearchResultsMode = true;
// Since this is the filter activity it receives all intents
// dispatched from the SearchManager for security reasons
// so we need to re-dispatch from here to the intended target.
@@ -797,7 +801,8 @@
mMode = MODE_DEFAULT;
}
- if ((mMode & MODE_MASK_SHOW_NUMBER_OF_CONTACTS) != 0 || mSearchMode) {
+ if (((mMode & MODE_MASK_SHOW_NUMBER_OF_CONTACTS) != 0 || mSearchMode)
+ && !mSearchResultsMode) {
mShowNumberOfContacts = true;
}
@@ -811,6 +816,11 @@
mJoinModeShowAllContacts = true;
} else if (mSearchMode) {
setContentView(R.layout.contacts_search_content);
+ } else if (mSearchResultsMode) {
+ setContentView(R.layout.contacts_list_search_results);
+ TextView titleText = (TextView)findViewById(R.id.search_results_for);
+ titleText.setText(Html.fromHtml(getString(R.string.search_results_for,
+ "<b>" + mInitialFilter + "</b>")));
} else {
setContentView(R.layout.contacts_list_content);
}
@@ -1297,7 +1307,7 @@
return;
}
- Intent intent = new Intent(this, ContactsListActivity.class);
+ Intent intent = new Intent(this, SearchResultsActivity.class);
Intent originalIntent = getIntent();
Bundle originalExtras = originalIntent.getExtras();
if (originalExtras != null) {
@@ -2349,6 +2359,11 @@
// Set the proper empty string
setEmptyText();
+ if (mSearchResultsMode) {
+ TextView foundContactsText = (TextView)findViewById(R.id.search_results_found);
+ foundContactsText.setText(R.string.search_results_searching);
+ }
+
mAdapter.setLoading(true);
// Cancel any pending queries
@@ -2648,6 +2663,16 @@
return null;
}
+ // TODO: fix PluralRules to handle zero correctly and use Resources.getQuantityText directly
+ protected String getQuantityText(int count, int zeroResourceId, int pluralResourceId) {
+ if (count == 0) {
+ return getString(zeroResourceId);
+ } else {
+ String format = getResources().getQuantityText(pluralResourceId, count).toString();
+ return String.format(format, count);
+ }
+ }
+
/**
* Signal an error to the user.
*/
@@ -2956,11 +2981,7 @@
String text;
int count = getRealCount();
- if (mMode == MODE_QUERY || mMode == MODE_QUERY_PICK || mMode == MODE_QUERY_PICK_PHONE
- || mMode == MODE_QUERY_PICK_TO_EDIT) {
- text = getQuantityText(count, R.string.listFoundAllContactsZero,
- R.plurals.listFoundAllContacts);
- } else if (mSearchMode && !TextUtils.isEmpty(getTextFilter())) {
+ if (mSearchMode && !TextUtils.isEmpty(getTextFilter())) {
text = getQuantityText(count, R.string.listFoundAllContactsZero,
R.plurals.searchFoundContacts);
} else {
@@ -2976,16 +2997,6 @@
return view;
}
- // TODO: fix PluralRules to handle zero correctly and use Resources.getQuantityText directly
- private String getQuantityText(int count, int zeroResourceId, int pluralResourceId) {
- if (count == 0) {
- return getString(zeroResourceId);
- } else {
- String format = getResources().getQuantityText(pluralResourceId, count).toString();
- return String.format(format, count);
- }
- }
-
private boolean isShowAllContactsItemPosition(int position) {
return mMode == MODE_JOIN_CONTACT && mJoinModeShowAllContacts
&& mSuggestionsCursorCount != 0 && position == mSuggestionsCursorCount + 2;
@@ -3319,6 +3330,13 @@
}
}
+ if (cursor != null && mSearchResultsMode) {
+ TextView foundContactsText = (TextView)findViewById(R.id.search_results_found);
+ String text = getQuantityText(cursor.getCount(), R.string.listFoundAllContactsZero,
+ R.plurals.listFoundAllContacts);
+ foundContactsText.setText(text);
+ }
+
super.changeCursor(cursor);
// Update the indexer for the fast scroll widget
updateIndexer(cursor);
diff --git a/src/com/android/contacts/SearchResultsActivity.java b/src/com/android/contacts/SearchResultsActivity.java
new file mode 100644
index 0000000..09f0014
--- /dev/null
+++ b/src/com/android/contacts/SearchResultsActivity.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2007 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.
+ */
+package com.android.contacts;
+
+/**
+ * The activity that displays the list of contact search results. We need a separate
+ * class because it uses a different theme from {@link ContactsListActivity}.
+ */
+public class SearchResultsActivity extends ContactsListActivity {
+}