Merge "Fix bug #14323469 Settings crash on selecting keyword from recent searches ... after changing orientation"
This commit is contained in:
committed by
Android (Google) Code Review
commit
eab58139f4
@@ -410,6 +410,10 @@ public class SettingsActivity extends Activity
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mSearchResultsFragment != null) {
|
||||||
|
mSearchResultsFragment.setSearchView(mSearchView);
|
||||||
|
}
|
||||||
|
|
||||||
mSearchMenuItem.setOnActionExpandListener(this);
|
mSearchMenuItem.setOnActionExpandListener(this);
|
||||||
mSearchView.setOnQueryTextListener(this);
|
mSearchView.setOnQueryTextListener(this);
|
||||||
mSearchView.setOnCloseListener(this);
|
mSearchView.setOnCloseListener(this);
|
||||||
|
@@ -51,6 +51,8 @@ public class SearchResultsSummary extends Fragment {
|
|||||||
private static final String EMPTY_QUERY = "";
|
private static final String EMPTY_QUERY = "";
|
||||||
private static char ELLIPSIS = '\u2026';
|
private static char ELLIPSIS = '\u2026';
|
||||||
|
|
||||||
|
private static final String SAVE_KEY_SHOW_ONLY_RESULTS = ":settings:show_only_results";
|
||||||
|
|
||||||
private SearchView mSearchView;
|
private SearchView mSearchView;
|
||||||
|
|
||||||
private ListView mResultsListView;
|
private ListView mResultsListView;
|
||||||
@@ -66,6 +68,8 @@ public class SearchResultsSummary extends Fragment {
|
|||||||
|
|
||||||
private String mQuery;
|
private String mQuery;
|
||||||
|
|
||||||
|
private boolean mShowOnlyResults;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A basic AsyncTask for updating the query results cursor
|
* A basic AsyncTask for updating the query results cursor
|
||||||
*/
|
*/
|
||||||
@@ -110,6 +114,17 @@ public class SearchResultsSummary extends Fragment {
|
|||||||
|
|
||||||
mResultsAdapter = new SearchResultsAdapter(getActivity());
|
mResultsAdapter = new SearchResultsAdapter(getActivity());
|
||||||
mSuggestionsAdapter = new SuggestionsAdapter(getActivity());
|
mSuggestionsAdapter = new SuggestionsAdapter(getActivity());
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
mShowOnlyResults = savedInstanceState.getBoolean(SAVE_KEY_SHOW_ONLY_RESULTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
|
||||||
|
outState.putBoolean(SAVE_KEY_SHOW_ONLY_RESULTS, mShowOnlyResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -197,6 +212,7 @@ public class SearchResultsSummary extends Fragment {
|
|||||||
mQuery = cursor.getString(0);
|
mQuery = cursor.getString(0);
|
||||||
mSearchView.setQuery(mQuery, false);
|
mSearchView.setQuery(mQuery, false);
|
||||||
setSuggestionsVisibility(false);
|
setSuggestionsVisibility(false);
|
||||||
|
mShowOnlyResults = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -207,7 +223,9 @@ public class SearchResultsSummary extends Fragment {
|
|||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
showSomeSuggestions();
|
if (!mShowOnlyResults) {
|
||||||
|
showSomeSuggestions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSearchView(SearchView searchView) {
|
public void setSearchView(SearchView searchView) {
|
||||||
@@ -232,13 +250,30 @@ public class SearchResultsSummary extends Fragment {
|
|||||||
|
|
||||||
public boolean onQueryTextSubmit(String query) {
|
public boolean onQueryTextSubmit(String query) {
|
||||||
mQuery = getFilteredQueryString(query);
|
mQuery = getFilteredQueryString(query);
|
||||||
|
setSuggestionsVisibility(!mShowOnlyResults);
|
||||||
updateSearchResults();
|
updateSearchResults();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onQueryTextChange(String query) {
|
public boolean onQueryTextChange(String query) {
|
||||||
mQuery = getFilteredQueryString(query);
|
final String newQuery = getFilteredQueryString(query);
|
||||||
updateSuggestions();
|
|
||||||
|
boolean isNewQuery;
|
||||||
|
if (!TextUtils.isEmpty(mQuery)) {
|
||||||
|
isNewQuery = !mQuery.equals(query);
|
||||||
|
} else {
|
||||||
|
isNewQuery = !TextUtils.isEmpty(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
mQuery = newQuery;
|
||||||
|
|
||||||
|
if (isNewQuery) {
|
||||||
|
mShowOnlyResults = false;
|
||||||
|
}
|
||||||
|
if (!mShowOnlyResults) {
|
||||||
|
updateSuggestions();
|
||||||
|
}
|
||||||
|
|
||||||
updateSearchResults();
|
updateSearchResults();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user