diff options
author | Michael Jurka <mikejurka@google.com> | 2012-06-14 16:18:21 -0700 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2012-06-18 12:57:12 -0700 |
commit | a33411cb83e2c7f822d6486183a7a4ea7d1b09e6 (patch) | |
tree | 799fc61462183edfb7ec44011f476918cc8d9c1b /src/com/android/launcher2 | |
parent | e783cde98d59a2df1d4645f07b278322cab16ecb (diff) | |
download | android_packages_apps_Trebuchet-a33411cb83e2c7f822d6486183a7a4ea7d1b09e6.tar.gz android_packages_apps_Trebuchet-a33411cb83e2c7f822d6486183a7a4ea7d1b09e6.tar.bz2 android_packages_apps_Trebuchet-a33411cb83e2c7f822d6486183a7a4ea7d1b09e6.zip |
Removing use of private SearchManager api
also removing one unused import
Diffstat (limited to 'src/com/android/launcher2')
-rw-r--r-- | src/com/android/launcher2/AppsCustomizeTabHost.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 45 |
2 files changed, 42 insertions, 4 deletions
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java index a2cab5322..935a65676 100644 --- a/src/com/android/launcher2/AppsCustomizeTabHost.java +++ b/src/com/android/launcher2/AppsCustomizeTabHost.java @@ -23,7 +23,6 @@ import android.animation.ObjectAnimator; import android.content.Context; import android.content.res.Resources; import android.util.AttributeSet; -import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 415ccacfb..549d1b54b 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -65,6 +65,7 @@ import android.provider.Settings; import android.speech.RecognizerIntent; import android.text.Selection; import android.text.SpannableStringBuilder; +import android.text.TextUtils; import android.text.method.TextKeyListener; import android.util.Log; import android.view.Display; @@ -1498,10 +1499,48 @@ public final class Launcher extends Activity } Rect sourceBounds = mSearchDropTargetBar.getSearchBarBounds(); + startGlobalSearch(initialQuery, selectInitialQuery, + appSearchData, sourceBounds); + } + + /** + * Starts the global search activity. This code is a copied from SearchManager + */ + public void startGlobalSearch(String initialQuery, + boolean selectInitialQuery, Bundle appSearchData, Rect sourceBounds) { final SearchManager searchManager = - (SearchManager) getSystemService(Context.SEARCH_SERVICE); - searchManager.startSearch(initialQuery, selectInitialQuery, getComponentName(), - appSearchData, globalSearch, sourceBounds); + (SearchManager) getSystemService(Context.SEARCH_SERVICE); + ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity(); + if (globalSearchActivity == null) { + Log.w(TAG, "No global search activity found."); + return; + } + Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.setComponent(globalSearchActivity); + // Make sure that we have a Bundle to put source in + if (appSearchData == null) { + appSearchData = new Bundle(); + } else { + appSearchData = new Bundle(appSearchData); + } + // Set source to package name of app that starts global search, if not set already. + if (!appSearchData.containsKey("source")) { + appSearchData.putString("source", getPackageName()); + } + intent.putExtra(SearchManager.APP_DATA, appSearchData); + if (!TextUtils.isEmpty(initialQuery)) { + intent.putExtra(SearchManager.QUERY, initialQuery); + } + if (selectInitialQuery) { + intent.putExtra(SearchManager.EXTRA_SELECT_QUERY, selectInitialQuery); + } + intent.setSourceBounds(sourceBounds); + try { + startActivity(intent); + } catch (ActivityNotFoundException ex) { + Log.e(TAG, "Global search activity not found: " + globalSearchActivity); + } } @Override |