From af9dc29f589c6ee771db22e3a2923b8bae46aafc Mon Sep 17 00:00:00 2001 From: Jin Cao Date: Fri, 25 Jul 2014 15:33:32 -0700 Subject: [Quantum search] update search header Add search header to be part of list so it scrolls properly. Updated corresponding styles. b/16518233 Change-Id: I795ea687795c2f3d96dc241eca2a9044957a9936 --- res/drawable-hdpi/banner_background_search.9.png | Bin 205 -> 0 bytes res/drawable-mdpi/banner_background_search.9.png | Bin 176 -> 0 bytes .../banner_background_search.9.png | Bin 220 -> 0 bytes .../banner_background_search.9.png | Bin 190 -> 0 bytes .../banner_background_search.9.png | Bin 245 -> 0 bytes .../banner_background_search.9.png | Bin 1200 -> 0 bytes res/drawable-xhdpi/banner_background_search.9.png | Bin 225 -> 0 bytes res/drawable-xxhdpi/banner_background_search.9.png | Bin 1142 -> 0 bytes res/layout/conversation_list.xml | 12 ++-- res/layout/search_results_view.xml | 24 +++---- res/values-ldrtl/styles-ldrtl.xml | 8 --- res/values/colors.xml | 3 + res/values/dimen.xml | 5 +- res/values/styles.xml | 9 +-- .../android/mail/ui/ConversationListFragment.java | 71 +++++---------------- src/com/android/mail/ui/SwipeableListView.java | 4 ++ 16 files changed, 47 insertions(+), 89 deletions(-) delete mode 100644 res/drawable-hdpi/banner_background_search.9.png delete mode 100644 res/drawable-mdpi/banner_background_search.9.png delete mode 100644 res/drawable-sw600dp-hdpi/banner_background_search.9.png delete mode 100644 res/drawable-sw600dp-mdpi/banner_background_search.9.png delete mode 100644 res/drawable-sw600dp-xhdpi/banner_background_search.9.png delete mode 100644 res/drawable-sw600dp-xxhdpi/banner_background_search.9.png delete mode 100644 res/drawable-xhdpi/banner_background_search.9.png delete mode 100644 res/drawable-xxhdpi/banner_background_search.9.png diff --git a/res/drawable-hdpi/banner_background_search.9.png b/res/drawable-hdpi/banner_background_search.9.png deleted file mode 100644 index 0e2c2bedd..000000000 Binary files a/res/drawable-hdpi/banner_background_search.9.png and /dev/null differ diff --git a/res/drawable-mdpi/banner_background_search.9.png b/res/drawable-mdpi/banner_background_search.9.png deleted file mode 100644 index 0e5970edd..000000000 Binary files a/res/drawable-mdpi/banner_background_search.9.png and /dev/null differ diff --git a/res/drawable-sw600dp-hdpi/banner_background_search.9.png b/res/drawable-sw600dp-hdpi/banner_background_search.9.png deleted file mode 100644 index c3448d92c..000000000 Binary files a/res/drawable-sw600dp-hdpi/banner_background_search.9.png and /dev/null differ diff --git a/res/drawable-sw600dp-mdpi/banner_background_search.9.png b/res/drawable-sw600dp-mdpi/banner_background_search.9.png deleted file mode 100644 index 587c3a2ec..000000000 Binary files a/res/drawable-sw600dp-mdpi/banner_background_search.9.png and /dev/null differ diff --git a/res/drawable-sw600dp-xhdpi/banner_background_search.9.png b/res/drawable-sw600dp-xhdpi/banner_background_search.9.png deleted file mode 100644 index 02fafa20a..000000000 Binary files a/res/drawable-sw600dp-xhdpi/banner_background_search.9.png and /dev/null differ diff --git a/res/drawable-sw600dp-xxhdpi/banner_background_search.9.png b/res/drawable-sw600dp-xxhdpi/banner_background_search.9.png deleted file mode 100644 index 0ac64eda4..000000000 Binary files a/res/drawable-sw600dp-xxhdpi/banner_background_search.9.png and /dev/null differ diff --git a/res/drawable-xhdpi/banner_background_search.9.png b/res/drawable-xhdpi/banner_background_search.9.png deleted file mode 100644 index 17540618b..000000000 Binary files a/res/drawable-xhdpi/banner_background_search.9.png and /dev/null differ diff --git a/res/drawable-xxhdpi/banner_background_search.9.png b/res/drawable-xxhdpi/banner_background_search.9.png deleted file mode 100644 index c30bf1ab9..000000000 Binary files a/res/drawable-xxhdpi/banner_background_search.9.png and /dev/null differ diff --git a/res/layout/conversation_list.xml b/res/layout/conversation_list.xml index 2d2bfa84c..654092ce7 100644 --- a/res/layout/conversation_list.xml +++ b/res/layout/conversation_list.xml @@ -16,33 +16,37 @@ limitations under the License. --> - - - + + + + + + + diff --git a/res/layout/search_results_view.xml b/res/layout/search_results_view.xml index 87e86989a..9d8cfa3c2 100644 --- a/res/layout/search_results_view.xml +++ b/res/layout/search_results_view.xml @@ -21,32 +21,28 @@ android:id="@+id/search_status_view" android:layout_width="match_parent" android:layout_height="@dimen/notification_view_height" + android:background="@color/search_banner_bg" android:minHeight="@dimen/notification_view_height" - android:background="@drawable/banner_background_search" - android:visibility="gone" - android:orientation="horizontal" > + android:paddingLeft="@dimen/search_results_padding" + android:paddingRight="@dimen/search_results_padding"> + android:text="@string/search_results_header" + android:textAllCaps="true" + style="@style/SearchTextStyle" /> + android:gravity="center_vertical|end" + style="@style/SearchTextStyle" /> diff --git a/res/values-ldrtl/styles-ldrtl.xml b/res/values-ldrtl/styles-ldrtl.xml index b412a7340..ba48b6ba7 100644 --- a/res/values-ldrtl/styles-ldrtl.xml +++ b/res/values-ldrtl/styles-ldrtl.xml @@ -256,14 +256,6 @@ @dimen/widget_attachment_padding_end - - - - - - - diff --git a/src/com/android/mail/ui/ConversationListFragment.java b/src/com/android/mail/ui/ConversationListFragment.java index 3329c74ea..33497ee44 100644 --- a/src/com/android/mail/ui/ConversationListFragment.java +++ b/src/com/android/mail/ui/ConversationListFragment.java @@ -107,10 +107,8 @@ public final class ConversationListFragment extends ListFragment implements // The internal view objects. private SwipeableListView mListView; + private View mSearchHeaderView; private TextView mSearchResultCountTextView; - private TextView mSearchStatusTextView; - - private View mSearchStatusView; /** * Current Account being viewed @@ -250,59 +248,16 @@ public final class ConversationListFragment extends ListFragment implements return fragment; } - /** - * Show the header if the current conversation list is showing search - * results. - */ - void configureSearchResultHeader() { - if (mActivity == null) { - return; - } - // Only show the header if the context is for a search result - final Resources res = getResources(); - final boolean showHeader = ConversationListContext.isSearchResult(mViewContext); - // TODO(viki): This code contains intimate understanding of the view. - // Much of this logic - // needs to reside in a separate class that handles the text view in - // isolation. Then, - // that logic can be reused in other fragments. - mSearchStatusView.setVisibility(showHeader ? View.INVISIBLE : View.GONE); - int paddingTop = showHeader ? (int) res.getDimension(R.dimen.notification_view_height) : 0; - mListView.setPadding(mListView.getPaddingLeft(), paddingTop, mListView.getPaddingRight(), - mListView.getPaddingBottom()); - } - /** * Show the header if the current conversation list is showing search * results. */ private void updateSearchResultHeader(int count) { - if (mActivity == null) { + if (mActivity == null || mSearchHeaderView == null) { return; } - // Only show the header if the context is for a search result - final Resources res = getResources(); - final boolean showHeader = ConversationListContext.isSearchResult(mViewContext); - if (showHeader) { - mSearchStatusTextView.setText(res.getString(R.string.search_results_header)); - mSearchResultCountTextView - .setText(res.getString(R.string.search_results_loaded, count)); - mSearchStatusView.setVisibility(View.VISIBLE); - } - } - - /** - * Initializes all internal state for a rendering. - */ - private void initializeUiForFirstDisplay() { - // TODO(mindyp): find some way to make the notification container more - // re-usable. - // TODO(viki): refactor according to comment in - // configureSearchResultHandler() - mSearchStatusView = mActivity.findViewById(R.id.search_status_view); - mSearchStatusTextView = (TextView) mActivity.findViewById(R.id.search_status_text_view); - mSearchResultCountTextView = (TextView) mActivity - .findViewById(R.id.search_result_count_view); + mSearchResultCountTextView.setText( + getResources().getString(R.string.search_results_loaded, count)); } @Override @@ -337,10 +292,9 @@ public final class ConversationListFragment extends ListFragment implements mCallbacks = mActivity.getListHandler(); mErrorListener = mActivity.getErrorListener(); // Start off with the current state of the folder being viewed. - Context activityContext = mActivity.getActivityContext(); - mFooterView = (ConversationListFooterView) LayoutInflater.from( - activityContext).inflate(R.layout.conversation_list_footer_view, - null); + final LayoutInflater inflater = LayoutInflater.from(mActivity.getActivityContext()); + mFooterView = (ConversationListFooterView) inflater.inflate( + R.layout.conversation_list_footer_view, null); mFooterView.setClickListener(mActivity); final ConversationCursor conversationCursor = getConversationListCursor(); final LoaderManager manager = getLoaderManager(); @@ -378,8 +332,6 @@ public final class ConversationListFragment extends ListFragment implements mUpdater = mActivity.getConversationUpdater(); mUpdater.registerConversationListObserver(mConversationCursorObserver); mTabletDevice = Utils.useTabletUI(mActivity.getApplicationContext().getResources()); - initializeUiForFirstDisplay(); - configureSearchResultHeader(); // The onViewModeChanged callback doesn't get called when the mode // object is created, so // force setting the mode manually this time around. @@ -491,6 +443,15 @@ public final class ConversationListFragment extends ListFragment implements mListView.setListItemSwipedListener(this); mListView.setSwipeListener(this); + // Show search result header only if we are in search mode + final boolean showSearchHeader = ConversationListContext.isSearchResult(mViewContext); + if (showSearchHeader) { + mSearchHeaderView = inflater.inflate(R.layout.search_results_view, null); + mSearchResultCountTextView = (TextView) + mSearchHeaderView.findViewById(R.id.search_result_count_view); + mListView.addHeaderView(mSearchHeaderView); + } + // enable animateOnLayout (equivalent of setLayoutTransition) only for >=JB (b/14302062) if (Utils.isRunningJellybeanOrLater()) { ((ViewGroup) rootView.findViewById(R.id.conversation_list_parent_frame)) diff --git a/src/com/android/mail/ui/SwipeableListView.java b/src/com/android/mail/ui/SwipeableListView.java index d0e431242..fd2184f4f 100644 --- a/src/com/android/mail/ui/SwipeableListView.java +++ b/src/com/android/mail/ui/SwipeableListView.java @@ -28,6 +28,7 @@ import android.view.View; import android.view.ViewConfiguration; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; +import android.widget.HeaderViewListAdapter; import android.widget.ListView; import com.android.mail.R; @@ -329,6 +330,9 @@ public class SwipeableListView extends ListView implements Callback, OnScrollLis } private AnimatedAdapter getAnimatedAdapter() { + if (getAdapter() instanceof HeaderViewListAdapter) { + return (AnimatedAdapter) ((HeaderViewListAdapter) getAdapter()).getWrappedAdapter(); + } return (AnimatedAdapter) getAdapter(); } -- cgit v1.2.3