use of android.app.SearchManager in project platform_frameworks_base by android.
the class PhoneWindow method launchDefaultSearch.
/**
* Helper method for adding launch-search to most applications. Opens the
* search window using default settings.
*
* @return true if search window opened
*/
private boolean launchDefaultSearch(KeyEvent event) {
boolean result;
final Callback cb = getCallback();
if (cb == null || isDestroyed()) {
result = false;
} else {
sendCloseSystemWindows("search");
int deviceId = event.getDeviceId();
SearchEvent searchEvent = null;
if (deviceId != 0) {
searchEvent = new SearchEvent(InputDevice.getDevice(deviceId));
}
try {
result = cb.onSearchRequested(searchEvent);
} catch (AbstractMethodError e) {
Log.e(TAG, "WindowCallback " + cb.getClass().getName() + " does not implement" + " method onSearchRequested(SearchEvent); fa", e);
result = cb.onSearchRequested();
}
}
if (!result && (getContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_TELEVISION) {
// On TVs, if the app doesn't implement search, we want to launch assist.
Bundle args = new Bundle();
args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, event.getDeviceId());
return ((SearchManager) getContext().getSystemService(Context.SEARCH_SERVICE)).launchLegacyAssist(null, UserHandle.myUserId(), args);
}
return result;
}
use of android.app.SearchManager in project weiciyuan by qii.
the class SearchMainParentFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.actionbar_menu_searchmainactivity, menu);
final SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
searchView.setIconifiedByDefault(false);
searchView.setSubmitButtonEnabled(false);
searchView.setMaxWidth(Utility.dip2px(250));
ThemeUtility.customActionBarSearchViewTextColor(searchView);
searchView.requestFocus();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
search(q);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
SearchMainParentFragment.this.q = newText;
return false;
}
});
searchView.setOnSearchClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
search(q);
}
});
if (!TextUtils.isEmpty(this.q)) {
searchView.setQuery(this.q, false);
}
}
use of android.app.SearchManager in project PocketHub by pockethub.
the class IssuesFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu optionsMenu, MenuInflater inflater) {
inflater.inflate(R.menu.fragment_issues, optionsMenu);
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
MenuItem searchItem = optionsMenu.findItem(R.id.m_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
Bundle args = new Bundle();
args.putParcelable(EXTRA_REPOSITORY, repository);
searchView.setAppSearchData(args);
}
use of android.app.SearchManager in project PocketHub by pockethub.
the class SearchActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu options) {
getMenuInflater().inflate(R.menu.activity_search, options);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
MenuItem searchItem = options.findItem(R.id.m_search);
searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
return true;
}
use of android.app.SearchManager in project plaid by nickbutcher.
the class SearchActivity method setupSearchView.
private void setupSearchView() {
SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
// hint, inputType & ime options seem to be ignored from XML! Set in code
searchView.setQueryHint(getString(R.string.search_hint));
searchView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
searchView.setImeOptions(searchView.getImeOptions() | EditorInfo.IME_ACTION_SEARCH | EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_FLAG_NO_FULLSCREEN);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
searchFor(query);
return true;
}
@Override
public boolean onQueryTextChange(String query) {
if (TextUtils.isEmpty(query)) {
clearResults();
}
return true;
}
});
searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus && confirmSaveContainer.getVisibility() == View.VISIBLE) {
hideSaveConfirmation();
}
}
});
}
Aggregations