diff options
author | krosaen <krosaen@android.com> | 2009-08-17 08:56:48 -0700 |
---|---|---|
committer | Karl Rosaen <krosaen@android.com> | 2009-08-18 08:56:03 -0700 |
commit | d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6 (patch) | |
tree | 6e075767b94546c6f0d6629587dd9a0204cef72e /core/java/android/server | |
parent | 1a8c1599de630ae4199b71cb3eca75d7db9c40d6 (diff) | |
download | frameworks_base-d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6.zip frameworks_base-d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6.tar.gz frameworks_base-d2d6014f715f12f6263f61ba3eeb6f8cba6d0fa6.tar.bz2 |
NEW API for SearchManager and Activity to 'triggerSearch'.
This is pretty much the same thing as startSearch, except it also launches the
query. We enforce that this can only be done for the package of the app that is
associated with the search mananger (e.g you can't trigger a contacts search
from anywhere).
Diffstat (limited to 'core/java/android/server')
-rw-r--r-- | core/java/android/server/search/SearchDialogWrapper.java | 17 | ||||
-rw-r--r-- | core/java/android/server/search/SearchManagerService.java | 26 |
2 files changed, 38 insertions, 5 deletions
diff --git a/core/java/android/server/search/SearchDialogWrapper.java b/core/java/android/server/search/SearchDialogWrapper.java index 49718cb..9ee64af 100644 --- a/core/java/android/server/search/SearchDialogWrapper.java +++ b/core/java/android/server/search/SearchDialogWrapper.java @@ -58,6 +58,7 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { // data[KEY_INITIAL_QUERY]: initial query // data[KEY_LAUNCH_ACTIVITY]: launch activity // data[KEY_APP_SEARCH_DATA]: app search data + // data[KEY_TRIGGER]: 0 = false, 1 = true private static final int MSG_START_SEARCH = 1; // Takes no arguments private static final int MSG_STOP_SEARCH = 2; @@ -69,7 +70,8 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { private static final String KEY_INITIAL_QUERY = "q"; private static final String KEY_LAUNCH_ACTIVITY = "a"; private static final String KEY_APP_SEARCH_DATA = "d"; - private static final String KEY_IDENT= "i"; + private static final String KEY_IDENT = "i"; + private static final String KEY_TRIGGER = "t"; // Context used for getting search UI resources private final Context mContext; @@ -173,7 +175,8 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { final Bundle appSearchData, final boolean globalSearch, final ISearchManagerCallback searchManagerCallback, - int ident) { + int ident, + boolean trigger) { if (DBG) debug("startSearch()"); Message msg = Message.obtain(); msg.what = MSG_START_SEARCH; @@ -185,6 +188,7 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { msgData.putParcelable(KEY_LAUNCH_ACTIVITY, launchActivity); msgData.putBundle(KEY_APP_SEARCH_DATA, appSearchData); msgData.putInt(KEY_IDENT, ident); + msgData.putInt(KEY_TRIGGER, trigger ? 1 : 0); mSearchUiThread.sendMessage(msg); // be a little more eager in setting this so isVisible will return the correct value if // called immediately after startSearch @@ -268,8 +272,9 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { boolean globalSearch = msg.arg2 != 0; ISearchManagerCallback searchManagerCallback = (ISearchManagerCallback) msg.obj; int ident = msgData.getInt(KEY_IDENT); + boolean trigger = msgData.getInt(KEY_TRIGGER) != 0; performStartSearch(initialQuery, selectInitialQuery, launchActivity, - appSearchData, globalSearch, searchManagerCallback, ident); + appSearchData, globalSearch, searchManagerCallback, ident, trigger); } } @@ -284,7 +289,8 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { Bundle appSearchData, boolean globalSearch, ISearchManagerCallback searchManagerCallback, - int ident) { + int ident, + boolean trigger) { if (DBG) debug("performStartSearch()"); registerBroadcastReceiver(); @@ -301,6 +307,9 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { mSearchDialog.show(initialQuery, selectInitialQuery, launchActivity, appSearchData, globalSearch); mVisible = true; + if (trigger) { + mSearchDialog.launchQuerySearch(); + } } /** diff --git a/core/java/android/server/search/SearchManagerService.java b/core/java/android/server/search/SearchManagerService.java index afed4a4..5e0b3d2 100644 --- a/core/java/android/server/search/SearchManagerService.java +++ b/core/java/android/server/search/SearchManagerService.java @@ -233,7 +233,31 @@ public class SearchManagerService extends ISearchManager.Stub { appSearchData, globalSearch, searchManagerCallback, - ident); + ident, + false); // don't trigger + } + + /** + * Launches the search UI and triggers the search, as if the user had clicked on the + * search button within the dialog. + * + * @see SearchManager#triggerSearch(String, android.content.ComponentName, android.os.Bundle) + */ + public void triggerSearch(String query, + ComponentName launchActivity, + Bundle appSearchData, + ISearchManagerCallback searchManagerCallback, + boolean globalSearch, + int ident) { + getSearchDialog().startSearch( + query, + false, + launchActivity, + appSearchData, + globalSearch, + searchManagerCallback, + ident, + true); // triger search after launching } /** |