Support for LIST_STARRED Intent
In the new navigation model this will switch
from the currently selected contact filter to
the "Starred" filter.
Change-Id: Ieab404e4b847970cb4823d52e8b53d838a75c7dc
diff --git a/src/com/android/contacts/activities/ContactBrowserActivity.java b/src/com/android/contacts/activities/ContactBrowserActivity.java
index 2deb549..b7afc1b 100644
--- a/src/com/android/contacts/activities/ContactBrowserActivity.java
+++ b/src/com/android/contacts/activities/ContactBrowserActivity.java
@@ -237,9 +237,28 @@
private void configureListFragment(boolean fromRequest) {
boolean searchMode = mSearchMode;
if (fromRequest) {
- if (mRequest.getDisplayWithPhoneNumbersOnly()) {
- mContactListFilterController.setContactListFilter(new ContactListFilter(
- ContactListFilter.FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY), false);
+ ContactListFilter filter = null;
+ int actionCode = mRequest.getActionCode();
+ switch (actionCode) {
+ case ContactsRequest.ACTION_ALL_CONTACTS:
+ filter = new ContactListFilter(ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS);
+ break;
+ case ContactsRequest.ACTION_CONTACTS_WITH_PHONES:
+ filter = new ContactListFilter(
+ ContactListFilter.FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY);
+ break;
+
+ // TODO: handle FREQUENT and STREQUENT according to the spec
+ case ContactsRequest.ACTION_FREQUENT:
+ case ContactsRequest.ACTION_STREQUENT:
+ // For now they are treated the same as STARRED
+ case ContactsRequest.ACTION_STARRED:
+ filter = new ContactListFilter(ContactListFilter.FILTER_TYPE_STARRED);
+ break;
+ }
+
+ if (filter != null) {
+ mContactListFilterController.setContactListFilter(filter, false);
searchMode = false;
} else if (mRequest.getActionCode() == ContactsRequest.ACTION_ALL_CONTACTS) {
mContactListFilterController.setContactListFilter(new ContactListFilter(
@@ -248,16 +267,6 @@
} else {
if (mHasActionBar) {
searchMode = mActionBarAdapter.isSearchMode();
- } else {
-// TODO: reenable FREQUENT, STARRED and STREQUENT
-// int actionCode = mRequest.getActionCode();
-// if (actionCode == ContactsRequest.ACTION_FREQUENT ||
-// actionCode == ContactsRequest.ACTION_STARRED ||
-// actionCode == ContactsRequest.ACTION_STREQUENT) {
-// mode = ContactBrowserMode.MODE_FAVORITES;
-// } else {
-// mode = ContactBrowserMode.MODE_CONTACTS;
-// }
}
}
diff --git a/src/com/android/contacts/list/ContactsIntentResolver.java b/src/com/android/contacts/list/ContactsIntentResolver.java
index 2386cc6..3b34cb5 100644
--- a/src/com/android/contacts/list/ContactsIntentResolver.java
+++ b/src/com/android/contacts/list/ContactsIntentResolver.java
@@ -63,8 +63,7 @@
} else if (UI.LIST_ALL_CONTACTS_ACTION.equals(action)) {
request.setActionCode(ContactsRequest.ACTION_ALL_CONTACTS);
} else if (UI.LIST_CONTACTS_WITH_PHONES_ACTION.equals(action)) {
- request.setActionCode(ContactsRequest.ACTION_DEFAULT);
- request.setDisplayWithPhoneNumbersOnly(true);
+ request.setActionCode(ContactsRequest.ACTION_CONTACTS_WITH_PHONES);
} else if (UI.LIST_STARRED_ACTION.equals(action)) {
request.setActionCode(ContactsRequest.ACTION_STARRED);
} else if (UI.LIST_FREQUENT_ACTION.equals(action)) {
diff --git a/src/com/android/contacts/list/ContactsRequest.java b/src/com/android/contacts/list/ContactsRequest.java
index 21e66ac..aefa451 100644
--- a/src/com/android/contacts/list/ContactsRequest.java
+++ b/src/com/android/contacts/list/ContactsRequest.java
@@ -32,6 +32,9 @@
/** Show all contacts */
public static final int ACTION_ALL_CONTACTS = 15;
+ /** Show all contacts with phone numbers */
+ public static final int ACTION_CONTACTS_WITH_PHONES = 17;
+
/** Show contents of a specific group */
public static final int ACTION_GROUP = 20;
@@ -77,7 +80,6 @@
private CharSequence mTitle;
private boolean mSearchMode;
private String mQueryString;
- private boolean mDisplayOnlyWithPhones;
private String mGroupName;
private boolean mLegacyCompatibilityMode;
private boolean mDirectorySearchEnabled = true;
@@ -93,7 +95,6 @@
mTitle = request.mTitle;
mSearchMode = request.mSearchMode;
mQueryString = request.mQueryString;
- mDisplayOnlyWithPhones = request.mDisplayOnlyWithPhones;
mGroupName = request.mGroupName;
mLegacyCompatibilityMode = request.mLegacyCompatibilityMode;
mDirectorySearchEnabled = request.mDirectorySearchEnabled;
@@ -115,7 +116,6 @@
request.mTitle = source.readCharSequence();
request.mSearchMode = source.readInt() != 0;
request.mQueryString = source.readString();
- request.mDisplayOnlyWithPhones = source.readInt() != 0;
request.mGroupName = source.readString();
request.mLegacyCompatibilityMode = source.readInt() != 0;
request.mDirectorySearchEnabled = source.readInt() != 0;
@@ -131,7 +131,6 @@
dest.writeCharSequence(mTitle);
dest.writeInt(mSearchMode ? 1 : 0);
dest.writeString(mQueryString);
- dest.writeInt(mDisplayOnlyWithPhones ? 1 : 0);
dest.writeString(mGroupName);
dest.writeInt(mLegacyCompatibilityMode ? 1 : 0);
dest.writeInt(mDirectorySearchEnabled ? 1 : 0);
@@ -174,14 +173,6 @@
mActionCode = actionCode;
}
- public boolean getDisplayWithPhoneNumbersOnly() {
- return mDisplayOnlyWithPhones;
- }
-
- public void setDisplayWithPhoneNumbersOnly(boolean option) {
- mDisplayOnlyWithPhones = option;
- }
-
public boolean isSearchMode() {
return mSearchMode;
}