Merge "Show a search results header."

This commit is contained in:
Ben Komalo 2011-06-27 20:02:44 -07:00 committed by Android (Google) Code Review
commit 8935f6d39e
4 changed files with 66 additions and 8 deletions

View File

@ -18,26 +18,50 @@
The default ListFragment layout (include) + the "send outgoing message" button.
-->
<FrameLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:id="@+id/search_header"
style="@style/search_header"
android:gravity="center_vertical"
android:background="#666"
android:visibility="gone"
>
<TextView
android:id="@+id/search_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textColor="@android:color/white"
/>
<TextView
android:id="@+id/search_header_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textColor="@android:color/white"
/>
</RelativeLayout>
<TextView
android:id="@+id/no_messages_panel"
android:text="@string/message_list_no_messages"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:visibility="gone"
/>
<FrameLayout
android:id="@+id/list_panel"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
>
<include layout="@android:layout/list_content" />
</FrameLayout>
</FrameLayout>
</LinearLayout>

View File

@ -1160,6 +1160,10 @@ save attachment.</string>
<!-- The hint used in the search box when searching a single mailbox [CHAR LIMIT=35] -->
<string name="search_mailbox_hint">Search <xliff:g example="Inbox">%1$s</xliff:g></string>
<!-- The title above the messages list when showing search results. [CHAR LIMIT=50] -->
<string name="search_header_text_fmt"
>Search results for \"<xliff:g example="search query">%1$s</xliff:g>\"</string>
<!-- Title shown on the action bar on the mailbox list screen. [CHAR LIMIT=16] -->
<string name="action_bar_mailbox_list_title">Folders</string>

View File

@ -160,5 +160,12 @@
<item name="android:ellipsize">end</item>
</style>
<style name="search_header">
<item name="android:layout_height">32dip</item>
<item name="android:layout_width">match_parent</item>
<item name="android:paddingLeft">6dip</item>
<item name="android:paddingRight">6dip</item>
</style>
</resources>

View File

@ -104,6 +104,9 @@ public class MessageListFragment extends ListFragment
private View mListFooterProgress;
private View mListPanel;
private View mNoMessagesPanel;
private ViewGroup mSearchHeader;
private TextView mSearchHeaderText;
private TextView mSearchHeaderCount;
private static final int LIST_FOOTER_MODE_NONE = 0;
private static final int LIST_FOOTER_MODE_MORE = 1;
@ -325,8 +328,11 @@ public class MessageListFragment extends ListFragment
}
// Use a custom layout, which includes the original layout with "send messages" panel.
View root = inflater.inflate(R.layout.message_list_fragment,null);
mListPanel = root.findViewById(R.id.list_panel);
mNoMessagesPanel = root.findViewById(R.id.no_messages_panel);
mListPanel = UiUtilities.getView(root, R.id.list_panel);
mNoMessagesPanel = UiUtilities.getView(root, R.id.no_messages_panel);
mSearchHeader = UiUtilities.getView(root, R.id.search_header);
mSearchHeaderText = UiUtilities.getView(mSearchHeader, R.id.search_header_text);
mSearchHeaderCount = UiUtilities.getView(mSearchHeader, R.id.search_count);
mIsViewCreated = true;
return root;
}
@ -357,7 +363,6 @@ public class MessageListFragment extends ListFragment
lv.setItemsCanFocus(false);
lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
mListFooterView = getActivity().getLayoutInflater().inflate(
R.layout.message_list_item_footer, lv, false);
@ -1015,6 +1020,22 @@ public class MessageListFragment extends ListFragment
updateSelectionMode();
}
private void updateSearchHeader(Cursor searchResultsCursor) {
MessageListContext listContext = getListContext();
if (!listContext.isSearch() || searchResultsCursor == null) {
mSearchHeader.setVisibility(View.GONE);
return;
}
mSearchHeader.setVisibility(View.VISIBLE);
String header = String.format(
mActivity.getString(R.string.search_header_text_fmt),
listContext.getSearchParams().mFilter);
mSearchHeaderText.setText(header);
// TODO: populate the count with the info from the cursor.
mSearchHeaderCount.setText(null);
}
private void determineFooterMode() {
// TODO: Do something different for searches?
// We could, for example, indicate how many remain to be loaded, etc...
@ -1124,6 +1145,7 @@ public class MessageListFragment extends ListFragment
// Clear the list. (ListFragment will show the "Loading" animation)
showNoMessageText(false);
showSendCommand(false);
updateSearchHeader(null);
// Start loading...
final LoaderManager lm = getLoaderManager();
@ -1193,6 +1215,7 @@ public class MessageListFragment extends ListFragment
mListAdapter.setShowColorChips(isCombinedMailbox() && mCountTotalAccounts > 1);
// Various post processing...
updateSearchHeader(cursor);
autoRefreshStaleMailbox();
addFooterView();
updateSelectionMode();