use of android.app.SearchManager in project materialistic by hidroh.
the class BaseListActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (mIsMultiPane) {
getMenuInflater().inflate(R.menu.menu_item_compact, menu);
}
if (isSearchable()) {
getMenuInflater().inflate(R.menu.menu_search, menu);
MenuItem menuSearch = menu.findItem(R.id.menu_search);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) mActionViewResolver.getActionView(menuSearch);
searchView.setSearchableInfo(searchManager.getSearchableInfo(new ComponentName(this, SearchActivity.class)));
searchView.setIconified(true);
searchView.setQuery("", false);
}
return super.onCreateOptionsMenu(menu);
}
use of android.app.SearchManager in project android_frameworks_base by AOSPA.
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 AOSPA.
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_frameworks_base by crdroidandroid.
the class AssistManager method startAssistActivity.
private void startAssistActivity(Bundle args, @NonNull ComponentName assistComponent) {
if (!mBar.isDeviceProvisioned()) {
return;
}
// Close Recent Apps if needed
mBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL);
boolean structureEnabled = Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.ASSIST_STRUCTURE_ENABLED, 1, UserHandle.USER_CURRENT) != 0;
final Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)).getAssistIntent(structureEnabled);
if (intent == null) {
return;
}
intent.setComponent(assistComponent);
intent.putExtras(args);
if (structureEnabled) {
showDisclosure();
}
try {
final ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, R.anim.search_launch_enter, R.anim.search_launch_exit);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
AsyncTask.execute(new Runnable() {
@Override
public void run() {
mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(UserHandle.USER_CURRENT));
}
});
} catch (ActivityNotFoundException e) {
Log.w(TAG, "Activity not found for " + intent.getAction());
}
}
use of android.app.SearchManager in project Varis-Android by dkhmelenko.
the class MainActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.menu_main, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
mSearchView = null;
if (searchItem != null) {
mSearchView = (SearchView) searchItem.getActionView();
}
if (mSearchView != null) {
mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
boolean submitProhibited = true;
if (query.length() > SEARCH_LIMIT) {
// save search query to history
SearchRecentSuggestions suggestionsProvider = new SearchRecentSuggestions(MainActivity.this, SearchHistoryProvider.AUTHORITY, SearchHistoryProvider.MODE);
suggestionsProvider.saveRecentQuery(query, null);
submitProhibited = false;
}
return submitProhibited;
}
@Override
public boolean onQueryTextChange(String newText) {
reloadSearchHistoryAdapter(newText);
return true;
}
});
mSearchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
@Override
public boolean onSuggestionClick(int position) {
mSearchView.setQuery(mQueryItems.get(position), true);
return true;
}
@Override
public boolean onSuggestionSelect(int position) {
return true;
}
});
reloadSearchHistoryAdapter("");
// restore query if it was
if (!TextUtils.isEmpty(mSavedQuery)) {
mSearchView.setQuery(mSavedQuery, false);
mSearchView.setIconified(false);
}
}
return super.onCreateOptionsMenu(menu);
}
Aggregations