summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mike LeBeau <mlebeau@android.com> 2009-05-12 15:30:37 -0700
committer Mike LeBeau <mlebeau@android.com> 2009-05-12 15:30:37 -0700
commita59d7b0f2f9af672d48041b29e147fdce1218c08 (patch)
treef9c7d977beb6bfbcebff9b1c7703d8883d028b1d
parentb059d90691e3ecd2d9843b537e9a08db983586e7 (diff)
Make pressing the search button within an app that does not support
search bring up global search. This still respects the case where an app has chosen to disable search entirely by overriding onSearchRequested() to return false. I do not believe any changes to the SearchManager documentation (http://developer.android.com/reference/android/app/SearchManager.html#HowSearchIsInvoked) are necessary, because this documentation already indicates that pressing the search button within an app that does nothing special with regard to search can bring up global search.
-rw-r--r--core/java/android/app/SearchDialog.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index a1748434a5e7..3e12fe61d8e8 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -309,11 +309,23 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
+ appSearchData + ", " + globalSearch + ")");
}
+ // Try to get the searchable info for the provided component (or for global search,
+ // if globalSearch == true).
mSearchable = SearchManager.getSearchableInfo(componentName, globalSearch);
- if (mSearchable == null) {
- // unfortunately, we can't log here. it would be logspam every time the user
- // clicks the "search" key on a non-search app
- return false;
+
+ // If we got back nothing, and it wasn't a request for global search, then try again
+ // for global search, as we'll try to launch that in lieu of any component-specific search.
+ if (!globalSearch && mSearchable == null) {
+ globalSearch = true;
+ mSearchable = SearchManager.getSearchableInfo(componentName, globalSearch);
+
+ // If we still get back null (i.e., there's not even a searchable info available
+ // for global search), then really give up.
+ if (mSearchable == null) {
+ // Unfortunately, we can't log here. it would be logspam every time the user
+ // clicks the "search" key on a non-search app.
+ return false;
+ }
}
mLaunchComponent = componentName;