From 04cde9853829b1f1ea6c528d0c11b76f2932982d Mon Sep 17 00:00:00 2001 From: Fabrice Di Meglio Date: Mon, 9 Jun 2014 17:07:04 -0700 Subject: [PATCH] Tune Recents Search and Search Results - add the capability to scroll recents and results with their header (old request from UX) See bug: #12910134 Implement Search into the Settings App Change-Id: If3c4a23b928b189803f2ef8e13a61746c2790b4b --- res/layout/search_panel.xml | 22 --------------- res/layout/search_panel_results_header.xml | 27 +++++++++++++++++++ .../search_panel_suggestions_header.xml | 27 +++++++++++++++++++ .../dashboard/SearchResultsSummary.java | 11 ++++++++ 4 files changed, 65 insertions(+), 22 deletions(-) create mode 100644 res/layout/search_panel_results_header.xml create mode 100644 res/layout/search_panel_suggestions_header.xml diff --git a/res/layout/search_panel.xml b/res/layout/search_panel.xml index 1242c73581c..c892ff98baf 100644 --- a/res/layout/search_panel.xml +++ b/res/layout/search_panel.xml @@ -33,17 +33,6 @@ android:layout_gravity="center" android:orientation="vertical"> - - - - + + + diff --git a/res/layout/search_panel_suggestions_header.xml b/res/layout/search_panel_suggestions_header.xml new file mode 100644 index 00000000000..21500bc7e33 --- /dev/null +++ b/res/layout/search_panel_suggestions_header.xml @@ -0,0 +1,27 @@ + + + + diff --git a/src/com/android/settings/dashboard/SearchResultsSummary.java b/src/com/android/settings/dashboard/SearchResultsSummary.java index c31a8933137..69816347542 100644 --- a/src/com/android/settings/dashboard/SearchResultsSummary.java +++ b/src/com/android/settings/dashboard/SearchResultsSummary.java @@ -166,6 +166,9 @@ public class SearchResultsSummary extends Fragment { mResultsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { + // We have a header, so we need to decrement the position by one + position--; + final Cursor cursor = mResultsAdapter.mCursor; cursor.moveToPosition(position); @@ -202,12 +205,17 @@ public class SearchResultsSummary extends Fragment { saveQueryToDatabase(); } }); + mResultsListView.addHeaderView( + LayoutInflater.from(getActivity()).inflate( + R.layout.search_panel_results_header, mResultsListView, false)); mSuggestionsListView = (ListView) view.findViewById(R.id.list_suggestions); mSuggestionsListView.setAdapter(mSuggestionsAdapter); mSuggestionsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { + // We have a header, so we need to decrement the position by one + position--; final Cursor cursor = mSuggestionsAdapter.mCursor; cursor.moveToPosition(position); @@ -216,6 +224,9 @@ public class SearchResultsSummary extends Fragment { mSearchView.setQuery(mQuery, false); } }); + mSuggestionsListView.addHeaderView( + LayoutInflater.from(getActivity()).inflate( + R.layout.search_panel_suggestions_header, mSuggestionsListView, false)); return view; }