Fixed searched text not visible for voice search

This commit is contained in:
Nite 2021-02-16 19:11:06 +01:00
parent 81ce23bafd
commit 09c8c56f59
No known key found for this signature in database
GPG Key ID: 1D1AD59B1C6386C1
1 changed files with 11 additions and 5 deletions

View File

@ -178,14 +178,13 @@ public class SearchFragment extends Fragment {
registerForContextMenu(list);
// Fragment was started with a query, try to execute search right away
// Fragment was started with a query (e.g. from voice search), try to execute search right away
Bundle arguments = getArguments();
if (arguments != null) {
String query = arguments.getString(Constants.INTENT_EXTRA_NAME_QUERY);
boolean autoPlay = arguments.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
if (query != null)
{
if (query != null) {
mergeAdapter = new MergeAdapter();
list.setAdapter(mergeAdapter);
search(query, autoPlay);
@ -202,14 +201,21 @@ public class SearchFragment extends Fragment {
Activity activity = getActivity();
if (activity == null) return;
SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE);
Bundle arguments = getArguments();
final boolean autoPlay = arguments != null && arguments.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
inflater.inflate(R.menu.search, menu);
MenuItem searchItem = menu.findItem(R.id.search_item);
final SearchView searchView = (SearchView) searchItem.getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
Bundle arguments = getArguments();
final boolean autoPlay = arguments != null && arguments.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
String query = arguments == null? null : arguments.getString(Constants.INTENT_EXTRA_NAME_QUERY);
// If started with a query, enter it to the searchView
if (query != null) {
searchView.setQuery(query, false);
searchView.clearFocus();
}
searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
@Override
public boolean onSuggestionSelect(int position) { return true; }