Search email and search phone test intents
Bring back support for ACTION_SEARCH_EMAIL and ACTION_SEARCH_PHONE
in the AllIntentsActivity test. It was removed in
Iad3c19262b22fb2345bbff42707e1a4d186c0a62.
Since the code has changed a lot, we no longer have a search activity to
allow search over just emails or just phone numbers. Hence, just
have the People app handle the intent and redirect to a search
with the provided query.
This works aside from this separate bug of the query not
showing up (bug 5790409).
Bug: 5224058
Change-Id: I2cfedbf74a1d59ee3c56d98aec2090302d420c9a
diff --git a/src/com/android/contacts/list/ContactsIntentResolver.java b/src/com/android/contacts/list/ContactsIntentResolver.java
index 0584f5e..9199766 100644
--- a/src/com/android/contacts/list/ContactsIntentResolver.java
+++ b/src/com/android/contacts/list/ContactsIntentResolver.java
@@ -34,6 +34,7 @@
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Intents;
+import android.provider.ContactsContract.Intents.Insert;
import android.provider.ContactsContract.Intents.UI;
import android.text.TextUtils;
import android.util.Log;
@@ -125,14 +126,22 @@
} else if (Intent.ACTION_INSERT_OR_EDIT.equals(action)) {
request.setActionCode(ContactsRequest.ACTION_INSERT_OR_EDIT_CONTACT);
} else if (Intent.ACTION_SEARCH.equals(action)) {
+ String query = intent.getStringExtra(SearchManager.QUERY);
// See if the suggestion was clicked with a search action key (call button)
if ("call".equals(intent.getStringExtra(SearchManager.ACTION_MSG))) {
- String query = intent.getStringExtra(SearchManager.QUERY);
if (!TextUtils.isEmpty(query)) {
request.setRedirectIntent(ContactsUtils.getCallIntent(query));
}
} else {
- request.setQueryString(intent.getStringExtra(SearchManager.QUERY));
+ // If the {@link SearchManager.QUERY} is empty, then check if a phone number
+ // or email is specified, in that priority.
+ if (TextUtils.isEmpty(query)) {
+ query = intent.getStringExtra(Insert.PHONE);
+ }
+ if (TextUtils.isEmpty(query)) {
+ query = intent.getStringExtra(Insert.EMAIL);
+ }
+ request.setQueryString(query);
request.setSearchMode(true);
}
} else if (Intent.ACTION_VIEW.equals(action)) {
diff --git a/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java b/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
index 555b339..0d9383f 100644
--- a/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
+++ b/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
@@ -290,11 +290,15 @@
break;
}
case ACTION_SEARCH_EMAIL: {
- Toast.makeText(this, "Unsupported", Toast.LENGTH_SHORT).show();
+ Intent intent = new Intent(Intent.ACTION_SEARCH);
+ intent.putExtra(Insert.EMAIL, "a");
+ startSearchResultActivity(intent);
break;
}
case ACTION_SEARCH_PHONE: {
- Toast.makeText(this, "Unsupported", Toast.LENGTH_SHORT).show();
+ Intent intent = new Intent(Intent.ACTION_SEARCH);
+ intent.putExtra(Insert.PHONE, "800");
+ startSearchResultActivity(intent);
break;
}
case SEARCH_SUGGESTION_CLICKED_CALL_BUTTON: {