use of android.app.SearchManager in project android_frameworks_base by ResurrectionRemix.
the class SearchManagerTest method testSearchManagerInvocations.
/**
* The goal of this test is to confirm that we can start and then
* stop a simple search.
*/
public void testSearchManagerInvocations() throws Exception {
SearchManager searchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
assertNotNull(searchManager);
// These tests should simply run to completion w/o exceptions
searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
searchManager.startSearch("", false, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
searchManager.startSearch("test search string", false, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
searchManager.startSearch("test search string", true, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
}
use of android.app.SearchManager in project android_frameworks_base by ResurrectionRemix.
the class SearchManagerTest method testStopSearchIdempotent.
/**
* Tests that stopSearch() can be called when the search UI is not visible and can be
* called multiple times without startSearch() in between.
*/
public void testStopSearchIdempotent() throws Exception {
SearchManager searchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
assertNotNull(searchManager);
searchManager.stopSearch();
searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
searchManager.stopSearch();
}
use of android.app.SearchManager in project android_frameworks_base by ResurrectionRemix.
the class SearchManagerTest method testStartSearchIdempotent.
/**
* Tests that startSearch() can be called multiple times without stopSearch()
* in between.
*/
public void testStartSearchIdempotent() throws Exception {
SearchManager searchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
assertNotNull(searchManager);
searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
}
use of android.app.SearchManager in project android_packages_apps_Launcher2 by CyanogenMod.
the class LauncherTransitionable method updateGlobalSearchIcon.
private boolean updateGlobalSearchIcon() {
final View searchButtonContainer = findViewById(R.id.search_button_container);
final ImageView searchButton = (ImageView) findViewById(R.id.search_button);
final View voiceButtonContainer = findViewById(R.id.voice_button_container);
final View voiceButton = findViewById(R.id.voice_button);
final View voiceButtonProxy = findViewById(R.id.voice_button_proxy);
final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
ComponentName activityName = searchManager.getGlobalSearchActivity();
if (activityName != null) {
int coi = getCurrentOrientationIndexForGlobalIcons();
sGlobalSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.search_button, activityName, R.drawable.ic_home_search_normal_holo, TOOLBAR_SEARCH_ICON_METADATA_NAME);
if (sGlobalSearchIcon[coi] == null) {
sGlobalSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.search_button, activityName, R.drawable.ic_home_search_normal_holo, TOOLBAR_ICON_METADATA_NAME);
}
if (searchButtonContainer != null)
searchButtonContainer.setVisibility(View.VISIBLE);
searchButton.setVisibility(View.VISIBLE);
invalidatePressedFocusedStates(searchButtonContainer, searchButton);
return true;
} else {
// We disable both search and voice search when there is no global search provider
if (searchButtonContainer != null)
searchButtonContainer.setVisibility(View.GONE);
if (voiceButtonContainer != null)
voiceButtonContainer.setVisibility(View.GONE);
searchButton.setVisibility(View.GONE);
voiceButton.setVisibility(View.GONE);
if (voiceButtonProxy != null) {
voiceButtonProxy.setVisibility(View.GONE);
}
return false;
}
}
use of android.app.SearchManager in project android_packages_apps_Launcher2 by CyanogenMod.
the class LauncherTransitionable method startGlobalSearch.
/**
* 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);
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);
}
}
Aggregations