Message header ui update. b/15595931
Change-Id: Ic3ce06409707e326e4dc2eef6bb8617f5f03d1b8
diff --git a/res/drawable-hdpi/ic_menu_expander_maximized_holo_light.png b/res/drawable-hdpi/ic_menu_expander_maximized_holo_light.png
deleted file mode 100644
index 924e8bb..0000000
--- a/res/drawable-hdpi/ic_menu_expander_maximized_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_menu_expander_minimized_holo_light.png b/res/drawable-hdpi/ic_menu_expander_minimized_holo_light.png
deleted file mode 100644
index de78288..0000000
--- a/res/drawable-hdpi/ic_menu_expander_minimized_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_expander_maximized_holo_light.png b/res/drawable-mdpi/ic_menu_expander_maximized_holo_light.png
deleted file mode 100644
index e2a2dfd..0000000
--- a/res/drawable-mdpi/ic_menu_expander_maximized_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_expander_minimized_holo_light.png b/res/drawable-mdpi/ic_menu_expander_minimized_holo_light.png
deleted file mode 100644
index 7eed231..0000000
--- a/res/drawable-mdpi/ic_menu_expander_minimized_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_menu_expander_maximized_holo_light.png b/res/drawable-xhdpi/ic_menu_expander_maximized_holo_light.png
deleted file mode 100644
index b174cf8..0000000
--- a/res/drawable-xhdpi/ic_menu_expander_maximized_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_menu_expander_minimized_holo_light.png b/res/drawable-xhdpi/ic_menu_expander_minimized_holo_light.png
deleted file mode 100644
index fab561e..0000000
--- a/res/drawable-xhdpi/ic_menu_expander_minimized_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_menu_expander_maximized_holo_light.png b/res/drawable-xxhdpi/ic_menu_expander_maximized_holo_light.png
deleted file mode 100644
index a42aec2..0000000
--- a/res/drawable-xxhdpi/ic_menu_expander_maximized_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_menu_expander_minimized_holo_light.png b/res/drawable-xxhdpi/ic_menu_expander_minimized_holo_light.png
deleted file mode 100644
index 1ca2e46..0000000
--- a/res/drawable-xxhdpi/ic_menu_expander_minimized_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/layout/conversation_message_details_header.xml b/res/layout/conversation_message_details_header.xml
deleted file mode 100644
index 0a4fad8..0000000
--- a/res/layout/conversation_message_details_header.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2011 Google Inc.
- Licensed to The Android Open Source Project.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/details_collapsed_content"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="?android:attr/selectableItemBackground"
- android:paddingBottom="@dimen/message_details_header_vertical_padding"
- style="@style/MessageDetailsHeaderStyle" >
- <TextView
- android:id="@+id/recipients_summary"
- android:layout_width="0dp"
- android:layout_gravity="fill_horizontal"
- android:singleLine="true"
- android:bufferType="spannable"
- style="@style/RecipientSummaryStyle" />
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:contentDescription="@string/expand_recipient_details"
- android:src="@drawable/ic_menu_expander_minimized_holo_light" />
-</GridLayout>
diff --git a/res/layout/conversation_message_footer.xml b/res/layout/conversation_message_footer.xml
index 6080b4e..c257590 100644
--- a/res/layout/conversation_message_footer.xml
+++ b/res/layout/conversation_message_footer.xml
@@ -33,7 +33,7 @@
android:paddingLeft="@dimen/conversation_message_content_margin_side"
android:paddingRight="@dimen/conversation_message_content_margin_side"
android:text="@string/view_entire_message"
- android:textColor="@color/conv_header_text_link_blue"
+ android:textColor="@color/conversation_view_text_color_link_blue"
android:textSize="14sp"
android:visibility="gone" />
diff --git a/res/layout/conversation_message_header.xml b/res/layout/conversation_message_header.xml
index 4d1ddd8..e741d25 100644
--- a/res/layout/conversation_message_header.xml
+++ b/res/layout/conversation_message_header.xml
@@ -34,8 +34,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/message_header_background_color"
- android:orientation="vertical"
- style="@style/ConversationViewMarginStyle"/>
+ android:orientation="vertical" />
<View android:id="@+id/snap_header_bottom_border"
android:layout_width="match_parent"
diff --git a/res/layout/conversation_message_details_header_expanded.xml b/res/layout/conversation_message_header_details.xml
similarity index 92%
rename from res/layout/conversation_message_details_header_expanded.xml
rename to res/layout/conversation_message_header_details.xml
index 5e0182c..31d0e26 100644
--- a/res/layout/conversation_message_details_header_expanded.xml
+++ b/res/layout/conversation_message_header_details.xml
@@ -21,7 +21,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
- app:columnCount="3"
+ app:columnCount="2"
app:rowCount="6"
style="@style/MessageDetailsHeaderStyle" >
@@ -46,15 +46,6 @@
app:layout_row="0"
android:visibility="gone"
style="@style/MessageDetailsValueStyle" />
- <ImageView
- android:id="@+id/details_expander"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:layout_column="2"
- app:layout_row="0"
- android:contentDescription="@string/collapse_recipient_details"
- android:src="@drawable/ic_menu_expander_maximized_holo_light"
- style="@style/DetailsExpanderStyle" />
<TextView
android:id="@+id/replyto_heading"
android:layout_width="wrap_content"
@@ -83,7 +74,7 @@
android:focusable="true"
app:layout_column="0"
app:layout_row="2"
- android:text="@string/to_heading"
+ android:text="@string/to_heading_no_space"
android:visibility="gone"
style="@style/MessageHeaderDetailsHeadingStyle" />
<TextView
diff --git a/res/layout/conversation_message_upper_header.xml b/res/layout/conversation_message_upper_header.xml
index 0ca6507..56722bc 100644
--- a/res/layout/conversation_message_upper_header.xml
+++ b/res/layout/conversation_message_upper_header.xml
@@ -19,31 +19,29 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/message_header_background_color"
- android:duplicateParentState="true"
- style="@style/ConversationViewMarginStyle" >
+ android:duplicateParentState="true" >
<com.android.mail.browse.MessageHeaderContactBadge
android:id="@+id/photo"
android:layout_width="@dimen/message_header_contact_photo_width"
android:layout_height="@dimen/message_header_contact_photo_height"
- android:layout_gravity="center_vertical"
- android:layout_marginTop="12dp"
- android:layout_marginBottom="12dp"
+ android:layout_marginTop="@dimen/message_header_contact_photo_margin"
+ android:layout_marginBottom="@dimen/message_header_contact_photo_margin"
+ android:background="?android:attr/selectableItemBackground"
android:scaleType="centerCrop"
android:contentDescription="@string/contact_info_string"
- style="@style/MessageHeaderContactImageStyle" />
+ style="@style/ConversationViewMarginStyle" />
<!-- draft should match photo in dimensions -->
<ImageView
android:id="@+id/draft"
android:layout_width="@dimen/message_header_contact_photo_width"
android:layout_height="@dimen/message_header_contact_photo_height"
- android:layout_gravity="center_vertical"
- android:layout_marginTop="12dp"
- android:layout_marginBottom="12dp"
+ android:layout_marginTop="@dimen/message_header_contact_photo_margin"
+ android:layout_marginBottom="@dimen/message_header_contact_photo_margin"
android:visibility="gone"
android:scaleType="center"
android:src="@drawable/ic_draft"
- style="@style/MessageHeaderContactImageStyle" />
+ style="@style/ConversationViewMarginStyle" />
<include layout="@layout/conversation_message_upper_header_text" />
<include layout="@layout/conversation_message_upper_header_actions" />
diff --git a/res/layout/conversation_message_upper_header_text.xml b/res/layout/conversation_message_upper_header_text.xml
index 2a6ea08..63f261e 100644
--- a/res/layout/conversation_message_upper_header_text.xml
+++ b/res/layout/conversation_message_upper_header_text.xml
@@ -24,13 +24,14 @@
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:layout_marginTop="12dp"
+ android:layout_marginTop="14dp"
style="@style/MessageUpperHeaderTextStyle" >
<TextView
android:id="@+id/upper_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_alignBaseline="@+id/sender_name"
android:visibility="gone"
android:lines="1"
style="@style/MessageHeaderUpperDateStyle" />
@@ -38,19 +39,20 @@
android:id="@+id/attachment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginTop="6dp"
android:layout_toStartOf="@id/upper_date"
android:layout_toLeftOf="@id/upper_date"
android:src="@drawable/ic_attach_file_20dp"
style="@style/AttachmentIconStyle" />
<TextView
- android:id="@+id/sender_name"
+ android:id="@id/sender_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="@id/attachment"
android:layout_toLeftOf="@id/attachment"
style="@style/MessageSenderNameStyle" />
<TextView
- android:id="@+id/sender_email"
+ android:id="@+id/recipient_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/sender_name"
@@ -59,12 +61,26 @@
android:id="@+id/send_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_below="@id/sender_email"
+ android:layout_below="@id/recipient_summary"
+ android:background="?android:attr/selectableItemBackground"
+ android:paddingBottom="@dimen/message_header_margin_bottom"
+ style="@style/MessageHeaderSubtitleStyle" />
+ <TextView
+ android:id="@+id/hide_details"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/recipient_summary"
+ android:background="?android:attr/selectableItemBackground"
+ android:paddingBottom="@dimen/message_header_margin_bottom"
+ android:text="@string/hide_details"
+ android:textColor="@color/conversation_view_text_color_link_blue"
+ android:visibility="gone"
style="@style/MessageHeaderSubtitleStyle" />
<TextView
android:id="@+id/email_snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/message_header_margin_bottom"
android:layout_below="@id/sender_name"
style="@style/MessageHeaderSnippetStyle" />
</RelativeLayout>
diff --git a/res/layout/super_collapsed_block.xml b/res/layout/super_collapsed_block.xml
index 444f941..37eb1a1 100644
--- a/res/layout/super_collapsed_block.xml
+++ b/res/layout/super_collapsed_block.xml
@@ -34,7 +34,6 @@
android:layout_height="@dimen/super_collapsed_height"
android:gravity="center"
android:textSize="@dimen/super_collapsed_text_size"
- android:textColor="@color/dark_gray_text_color"
- style="@style/ConversationViewMarginStyle" />
+ android:textColor="@color/dark_gray_text_color" />
</com.android.mail.browse.SuperCollapsedBlock>
diff --git a/res/values-ldrtl/styles-ldrtl.xml b/res/values-ldrtl/styles-ldrtl.xml
index dd0432f..0196f29 100644
--- a/res/values-ldrtl/styles-ldrtl.xml
+++ b/res/values-ldrtl/styles-ldrtl.xml
@@ -23,8 +23,7 @@
</style>
<style name="MessageDetailsHeaderStyle">
- <item name="android:paddingStart">@dimen/message_details_header_padding_start_collapsed
- </item>
+ <item name="android:paddingStart">@dimen/message_details_header_padding_start_expanded</item>
<item name="android:paddingEnd">@dimen/message_details_header_padding_end</item>
</style>
@@ -33,8 +32,7 @@
</style>
<style name="MessageHeaderShowPicsStyle" parent="AbstractMessageHeaderShowPicsStyle">
- <item name="android:paddingStart">@dimen/message_details_header_padding_start_collapsed
- </item>
+ <item name="android:paddingStart">@dimen/message_details_header_padding_start_expanded</item>
<item name="android:paddingEnd">@dimen/message_show_pics_header_padding_end</item>
<item name="android:drawableStart">@drawable/ic_show_images_holo_light</item>
</style>
@@ -69,7 +67,6 @@
<style name="ConversationViewMarginStyle">
<item name="android:layout_marginStart">@dimen/conversation_view_margin_side</item>
- <item name="android:layout_marginEnd">@dimen/conversation_view_margin_side</item>
</style>
<style name="NewMessageButtonStyle" parent="AbstractNewMessageButtonStyle">
@@ -98,10 +95,6 @@
<item name="android:layout_marginStart">@dimen/teaser_text_padding</item>
</style>
- <style name="DetailsExpanderStyle">
- <item name="android:layout_marginStart">@dimen/message_header_inner_side_padding</item>
- </style>
-
<style name="MessageHeaderDetailsHeadingStyle" parent="MessageHeaderSmallStyle">
<item name="android:layout_marginEnd">@dimen/message_header_inner_side_padding</item>
</style>
@@ -111,10 +104,6 @@
<item name="android:layout_marginEnd">@dimen/attachment_margin_side</item>
</style>
- <style name="MessageHeaderContactImageStyle">
- <item name="android:layout_marginStart">@dimen/message_header_padding_start</item>
- </style>
-
<style name="AttachmentIconStyle">
<item name="android:layout_marginStart">@dimen/attachment_icon_padding</item>
</style>
@@ -132,10 +121,6 @@
<item name="android:layout_marginEnd">@dimen/folder_list_item_end_margin</item>
</style>
- <style name="RecipientSummaryStyle" parent="MessageHeaderSmallStyle">
- <item name="android:layout_marginEnd">@dimen/recipient_summary_margin</item>
- </style>
-
<style name="AttachmentTextContainer">
<item name="android:paddingStart">@dimen/compose_attachment_text_padding</item>
</style>
@@ -237,8 +222,9 @@
<item name="android:layout_alignParentStart">true</item>
</style>
- <style name="MessageHeaderUpperDateStyle" parent="AbstractMessageHeaderUpperDateStyle">
+ <style name="MessageHeaderUpperDateStyle" parent="MessageHeaderSmallStyle">
<item name="android:layout_alignParentEnd">true</item>
+ <item name="android:layout_marginStart">@dimen/attachment_icon_padding</item>
</style>
<style name="FolderParentIconStyle">
diff --git a/res/values-sw600dp/dimen.xml b/res/values-sw600dp/dimen.xml
index aacdee2..e8724e7 100644
--- a/res/values-sw600dp/dimen.xml
+++ b/res/values-sw600dp/dimen.xml
@@ -20,14 +20,13 @@
<dimen name="conversation_header_margin_side">15dp</dimen>
<dimen name="conversation_header_font_size">24sp</dimen>
<dimen name="conversation_header_padding_side">24dp</dimen>
- <dimen name="conversation_message_content_margin_side">24dp</dimen>
<dimen name="conversation_page_gutter">0dip</dimen>
<dimen name="message_header_inner_side_padding">16dp</dimen>
<dimen name="message_header_contact_photo_width">64dp</dimen>
<dimen name="message_header_contact_photo_height">64dp</dimen>
<dimen name="message_header_action_button_width">56dp</dimen>
<dimen name="message_header_action_button_height">56dp</dimen>
- <dimen name="message_details_header_padding_start_collapsed">104dip</dimen>
+ <dimen name="message_details_header_padding_start_expanded">104dip</dimen>
<dimen name="message_sender_name_text_size">20sp</dimen>
<dimen name="message_header_subtitle_text_size">16sp</dimen>
<dimen name="super_collapsed_height">39sp</dimen>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 1c9b107..99e2c64 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -64,9 +64,9 @@
<!-- Conversation message header colors -->
<color name="conversation_view_border_color">#cbcbcb</color>
<color name="conversation_view_background_color">#f5f5f5</color>
- <color name="conv_header_text_light">#a6a8ab</color>
- <color name="conv_header_text_dark">#212121</color>
- <color name="conv_header_text_link_blue">#35b4e3</color>
+ <color name="conversation_view_text_color_light">#757575</color>
+ <color name="conversation_view_text_color_dark">#212121</color>
+ <color name="conversation_view_text_color_link_blue">#00bfd8</color>
<!-- Folder colors -->
<color name="folder_disabled_drop_target_text_color">#999999</color>
diff --git a/res/values/dimen.xml b/res/values/dimen.xml
index 640a257..394c8cf 100644
--- a/res/values/dimen.xml
+++ b/res/values/dimen.xml
@@ -35,8 +35,8 @@
<dimen name="folder_cell_width">32dip</dimen>
<dimen name="folders_start_padding">8dip</dimen>
<dimen name="conversation_page_gutter">16dp</dimen>
- <dimen name="conversation_message_content_margin_side">10dp</dimen>
- <dimen name="conversation_view_margin_side">8dp</dimen>
+ <dimen name="conversation_message_content_margin_side">16dp</dimen>
+ <dimen name="conversation_view_margin_side">16dp</dimen>
<dimen name="conversation_header_margin_side">0dp</dimen>
<dimen name="conversation_header_font_size">20sp</dimen>
<dimen name="conversation_header_padding_side">16dp</dimen>
@@ -47,23 +47,25 @@
<dimen name="conversation_folder_rounded_corner_radius">1dp</dimen>
<dimen name="conversation_folder_margin_top">6dp</dimen>
<dimen name="message_details_header_padding_start">16dip</dimen>
- <dimen name="message_details_header_padding_start_collapsed">68dip</dimen>
- <dimen name="message_details_header_padding_end">10dip</dimen>
+ <dimen name="message_details_header_padding_start_expanded">72dip</dimen>
+ <dimen name="message_details_header_padding_end">16dp</dimen>
<dimen name="message_details_header_vertical_padding">7dp</dimen>
+ <dimen name="message_details_header_inner_side_padding">8dp</dimen>
<dimen name="message_show_pics_header_padding_end">14dip</dimen>
<dimen name="message_header_presence_top_margin">-4dp</dimen>
<dimen name="message_header_action_button_width">48dp</dimen>
<dimen name="message_header_action_button_height">48dp</dimen>
- <dimen name="message_header_padding_start">
- @dimen/conversation_message_content_margin_side</dimen>
<dimen name="message_sender_name_text_size">16sp</dimen>
- <dimen name="message_header_subtitle_text_size">12sp</dimen>
+ <dimen name="message_header_subtitle_text_size">14sp</dimen>
+ <dimen name="message_header_small_text_size">12sp</dimen>
+ <dimen name="message_header_margin_bottom">12dp</dimen>
<dimen name="super_collapsed_height">30sp</dimen>
<dimen name="super_collapsed_text_size">14sp</dimen>
<dimen name="notification_view_height">36dip</dimen>
- <dimen name="message_header_contact_photo_width">48sp</dimen>
- <dimen name="message_header_contact_photo_height">48sp</dimen>
- <dimen name="message_header_inner_side_padding">10dp</dimen>
+ <dimen name="message_header_contact_photo_width">40dp</dimen>
+ <dimen name="message_header_contact_photo_height">40dp</dimen>
+ <dimen name="message_header_contact_photo_margin">16dp</dimen>
+ <dimen name="message_header_inner_side_padding">16dp</dimen>
<dimen name="attachment_toast_yoffset">-100dip</dimen>
<dimen name="spinner_frame_width">196dip</dimen>
<dimen name="folder_list_heading_padding_side">16dp</dimen>
@@ -93,7 +95,7 @@
<dimen name="search_view_width">400dip</dimen>
<dimen name="wait_padding">16dp</dimen>
<integer name="chips_max_lines">2</integer>
- <dimen name="tile_letter_font_size">33dp</dimen>
+ <dimen name="tile_letter_font_size">24dp</dimen>
<dimen name="tile_letter_font_size_small">16dp</dimen>
<dimen name="tile_divider_width">1dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e6ad123..bd19b07 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -465,10 +465,12 @@
</plurals>
<!-- Conversation message header strings -->
- <!-- Icon name for expanding recipient details in a message when viewing it. [CHAR LIMIT=40] -->
- <string name="expand_recipient_details">Expand recipient details</string>
- <!-- Icon name for collapsing recipient details in a message when viewing it. [CHAR LIMIT=40] -->
- <string name="collapse_recipient_details">Collapse recipient details</string>
+ <!-- Text for showing the date and expanding recipient details in a message when viewing it. [CHAR LIMIT=40] -->
+ <string name="date_and_view_details"><xliff:g id="date">%1$s</xliff:g> <a href=\'http://www.example.com\'>View details</a></string>
+ <!-- Text for collapsing recipient details in a message when viewing it. [CHAR LIMIT=40] -->
+ <string name="hide_details">Hide details</string>
+ <!-- Shown to display the recipient(s) of the message [CHAR LIMIT=10] -->
+ <string name="to_message_header">to <xliff:g id="recipients">%1$s</xliff:g></string>
<!-- Icon name for showing sender contact information. [CHAR LIMIT=100] -->
<string name="contact_info_string">Show contact information for <xliff:g id="name">%1$s</xliff:g></string>
<!-- Icon name for showing sender contact information when we cannot get sender info. [CHAR LIMIT=100] -->
@@ -479,17 +481,19 @@
<item quantity="other"><xliff:g id="count" example="4">%1$d</xliff:g> older messages</item>
</plurals>
<!-- Shown to display the from address of the message [CHAR LIMIT=10] -->
- <string name="from_heading">From:\u0020</string>
+ <string name="from_heading">From:</string>
<!-- Shown to display the reply to address of the message [CHAR LIMIT=20] -->
- <string name="replyto_heading">Reply-to:\u0020</string>
+ <string name="replyto_heading">Reply-to:</string>
<!-- Shown to display the to recipient(s) of the message [CHAR LIMIT=10] -->
<string name="to_heading">To:\u0020</string>
+ <!-- Shown to display the to recipient(s) of the message [CHAR LIMIT=10] -->
+ <string name="to_heading_no_space">To:</string>
<!-- Shown to display the cc recipient(s) of the message [CHAR LIMIT=10] -->
- <string name="cc_heading">Cc:\u0020</string>
+ <string name="cc_heading">Cc:</string>
<!-- Shown to display the bcc recipient(s) of the message [CHAR LIMIT=10] -->
- <string name="bcc_heading">Bcc:\u0020</string>
- <!-- Shown to display the recipient(s) of the message [CHAR LIMIT=10] -->
- <string name="date_heading">Date:\u0020</string>
+ <string name="bcc_heading">Bcc:</string>
+ <!-- Shown to display the date of the message [CHAR LIMIT=10] -->
+ <string name="date_heading">Date:</string>
<!-- Displayed above an HTML message to show the images in that message [CHAR LIMIT=40] -->
<string name="show_images">Show pictures</string>
<!-- Displayed above an HTML message to always show images in messages from that sender [CHAR LIMIT=40] -->
@@ -886,9 +890,6 @@
<!-- Action bar title for viewing messages that are attached to another message. -->
<string name="attached_message">Attached message</string>
- <!-- Shown to display the date of the message when the message was received yesterday. [CHAR LIMIT=50] -->
- <string name="date_message_received_yesterday">Yesterday, <xliff:g id="datetime">%1$s</xliff:g></string>
-
<!-- Content description for the "X" image icon for dismissing a tip. This is used for spoken description of the icon when touch explore is enabled. [CHAR LIMIT=50] -->
<string name="dismiss_tip_hover_text">Dismiss tip</string>
@@ -959,7 +960,7 @@
<!-- Shown to display the date of the message [CHAR LIMIT=50] -->
<string name="date_message_received_print"><xliff:g id="day_and_date">%1$s</xliff:g> at <xliff:g id="time">%2$s</xliff:g></string>
<!-- Shown to display the to recipient(s) of the message if the message is a draft [CHAR LIMIT=20] -->
- <string name="draft_to_heading">Draft To:\u0020</string>
+ <string name="draft_to_heading">Draft To:</string>
<!-- Shown to display in the message header if the message is a draft and there are no "to" addresses in the draft [CHAR LIMIT=10] -->
<string name="draft_heading">Draft</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 5373bec..cca2ad7 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -208,7 +208,7 @@
</style>
<style name="ConversationSubjectStyle">
- <item name="android:textColor">@color/conv_header_text_dark</item>
+ <item name="android:textColor">@color/conversation_view_text_color_dark</item>
<item name="android:textIsSelectable">true</item>
<item name="android:textSize">@dimen/conversation_header_font_size</item>
</style>
@@ -231,7 +231,7 @@
<style name="AbstractMessageSenderNameStyle">
<item name="android:singleLine">true</item>
<item name="android:textSize">@dimen/message_sender_name_text_size</item>
- <item name="android:textColor">@color/conv_header_text_dark</item>
+ <item name="android:textColor">@color/conversation_view_text_color_dark</item>
</style>
<style name="MessageSenderNameStyle" parent="AbstractMessageSenderNameStyle">
@@ -241,7 +241,8 @@
<style name="AbstractMessageHeaderSubtitleStyle">
<item name="android:singleLine">true</item>
<item name="android:textSize">@dimen/message_header_subtitle_text_size</item>
- <item name="android:textColor">@color/conv_header_text_dark</item>
+ <item name="android:textColor">@color/conversation_view_text_color_light</item>
+ <item name="android:textColorLink">@color/conversation_view_text_color_link_blue</item>
</style>
<style name="MessageHeaderSubtitleStyle" parent="AbstractMessageHeaderSubtitleStyle">
@@ -251,37 +252,31 @@
<style name="MessageHeaderSnippetStyle">
<item name="android:lines">2</item>
<item name="android:textSize">@dimen/message_header_subtitle_text_size</item>
- <item name="android:textColor">@color/conv_header_text_light</item>
+ <item name="android:textColor">@color/conversation_view_text_color_light</item>
</style>
<style name="MessageHeaderSmallStyle">
- <item name="android:layout_height">wrap_content</item>
- <item name="android:layout_width">wrap_content</item>
- <item name="android:textColor">@color/conv_header_text_dark</item>
- <item name="android:textSize">@dimen/message_header_subtitle_text_size</item>
+ <item name="android:textColor">@color/conversation_view_text_color_light</item>
+ <item name="android:textSize">@dimen/message_header_small_text_size</item>
</style>
<style name="MessageHeaderDetailsHeadingStyle" parent="MessageHeaderSmallStyle">
- <item name="android:layout_marginRight">@dimen/message_header_inner_side_padding</item>
+ <item name="android:layout_marginRight">@dimen/message_details_header_inner_side_padding</item>
</style>
<style name="AbstractMessageHeaderShowPicsStyle" parent="MessageHeaderSmallStyle">
- <item name="android:textColor">@color/conv_header_text_light</item>
+ <item name="android:textColor">@color/conversation_view_text_color_light</item>
</style>
<style name="MessageHeaderShowPicsStyle" parent="AbstractMessageHeaderShowPicsStyle">
- <item name="android:paddingLeft">@dimen/message_details_header_padding_start_collapsed
- </item>
+ <item name="android:paddingLeft">@dimen/message_details_header_padding_start_expanded</item>
<item name="android:paddingRight">@dimen/message_show_pics_header_padding_end</item>
<item name="android:drawableLeft">@drawable/ic_show_images_holo_light</item>
</style>
- <style name="AbstractMessageHeaderUpperDateStyle" parent="MessageHeaderSmallStyle">
- <item name="android:minHeight">24dp</item>
- </style>
-
- <style name="MessageHeaderUpperDateStyle" parent="AbstractMessageHeaderUpperDateStyle">
+ <style name="MessageHeaderUpperDateStyle" parent="MessageHeaderSmallStyle">
<item name="android:layout_alignParentRight">true</item>
+ <item name="android:layout_marginLeft">@dimen/attachment_icon_padding</item>
</style>
<style name="AbstractMessageAttachmentsHeaderStyle" parent="MessageHeaderSmallStyle">
@@ -296,8 +291,8 @@
<style name="MessageDetailsValueStyle" parent="MessageHeaderSmallStyle">
<item name="android:autoLink">email</item>
<item name="android:linksClickable">true</item>
- <item name="android:textColor">@color/conv_header_text_light</item>
- <item name="android:textColorLink">@color/conv_header_text_link_blue</item>
+ <item name="android:textColor">@color/conversation_view_text_color_light</item>
+ <item name="android:textColorLink">@color/conversation_view_text_color_link_blue</item>
<item name="android:textIsSelectable">true</item>
</style>
@@ -553,8 +548,7 @@
</style>
<style name="MessageDetailsHeaderStyle">
- <item name="android:paddingLeft">@dimen/message_details_header_padding_start_collapsed
- </item>
+ <item name="android:paddingLeft">@dimen/message_details_header_padding_start_expanded</item>
<item name="android:paddingRight">@dimen/message_details_header_padding_end</item>
</style>
@@ -578,7 +572,6 @@
<style name="ConversationViewMarginStyle">
<item name="android:layout_marginLeft">@dimen/conversation_view_margin_side</item>
- <item name="android:layout_marginRight">@dimen/conversation_view_margin_side</item>
</style>
<style name="FolderListItemStartStyle">
@@ -616,19 +609,11 @@
<item name="android:layout_marginLeft">@dimen/teaser_text_padding</item>
</style>
- <style name="DetailsExpanderStyle">
- <item name="android:layout_marginLeft">@dimen/message_header_inner_side_padding</item>
- </style>
-
<style name="AttachmentMarginStyle">
<item name="android:layout_marginLeft">@dimen/attachment_margin_side</item>
<item name="android:layout_marginRight">@dimen/attachment_margin_side</item>
</style>
- <style name="MessageHeaderContactImageStyle">
- <item name="android:layout_marginLeft">@dimen/message_header_padding_start</item>
- </style>
-
<style name="AttachmentIconStyle">
<item name="android:layout_marginLeft">@dimen/attachment_icon_padding</item>
</style>
@@ -646,10 +631,6 @@
<item name="android:layout_marginRight">@dimen/folder_list_item_end_margin</item>
</style>
- <style name="RecipientSummaryStyle" parent="MessageHeaderSmallStyle">
- <item name="android:layout_marginRight">@dimen/recipient_summary_margin</item>
- </style>
-
<style name="ToastBarDescriptionIconStyle">
<item name="android:paddingLeft">@dimen/toast_bar_description_icon_padding_start</item>
<item name="android:paddingRight">@dimen/toast_bar_description_icon_padding_end</item>
diff --git a/src/com/android/mail/FormattedDateBuilder.java b/src/com/android/mail/FormattedDateBuilder.java
index d93c3a5..9c0a52a 100644
--- a/src/com/android/mail/FormattedDateBuilder.java
+++ b/src/com/android/mail/FormattedDateBuilder.java
@@ -19,11 +19,8 @@
import android.content.Context;
import android.text.format.DateUtils;
-import com.android.mail.R;
-
import java.util.Calendar;
import java.util.Formatter;
-import java.util.GregorianCalendar;
/**
* Convenience class to efficiently make multiple short date strings. Instantiating and reusing
@@ -80,8 +77,7 @@
} else if (isCurrentYear(when)) {
return DateUtils.getRelativeDateTimeString(mContext, when, DateUtils.DAY_IN_MILLIS,
2 * DateUtils.WEEK_IN_MILLIS,
- DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE |
- DateUtils.FORMAT_ABBREV_MONTH);
+ DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH);
} else {
return formatDateTime(when, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NUMERIC_DATE);
}
@@ -97,18 +93,10 @@
*/
public CharSequence formatFullDateTime(long when) {
sb.setLength(0);
- if (isYesterday(when)) {
- DateUtils.formatDateRange(mContext, dateFormatter, when, when,
- DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE |
- DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_ABBREV_ALL);
- return mContext.getString(R.string.date_message_received_yesterday, sb.toString());
- } else {
- DateUtils.formatDateRange(mContext, dateFormatter, when, when,
- DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE |
- DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_YEAR |
- DateUtils.FORMAT_ABBREV_ALL);
- return sb.toString();
- }
+ DateUtils.formatDateRange(mContext, dateFormatter, when, when,
+ DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE |
+ DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_ABBREV_ALL);
+ return sb.toString();
}
/**
@@ -132,16 +120,6 @@
return (nowCal.get(Calendar.YEAR) == whenCal.get(Calendar.YEAR));
}
- private boolean isYesterday(long when) {
- final Calendar nowCal = Calendar.getInstance();
- final Calendar whenCal = Calendar.getInstance();
- whenCal.setTimeInMillis(when);
- // Decrement the "now" calendar back one day, and see if both are now the same day.
- nowCal.add(Calendar.DAY_OF_YEAR, -1);
- return (whenCal.get(Calendar.DAY_OF_YEAR) == nowCal.get(Calendar.DAY_OF_YEAR) &&
- whenCal.get(Calendar.YEAR) == nowCal.get(Calendar.YEAR));
- }
-
private CharSequence formatDateTime(long when, int flags) {
sb.setLength(0);
DateUtils.formatDateRange(mContext, dateFormatter, when, when, flags);
diff --git a/src/com/android/mail/analytics/AnalyticsUtils.java b/src/com/android/mail/analytics/AnalyticsUtils.java
index ee5a684..7894feb 100644
--- a/src/com/android/mail/analytics/AnalyticsUtils.java
+++ b/src/com/android/mail/analytics/AnalyticsUtils.java
@@ -123,9 +123,9 @@
s = "forward";
} else if (id == R.id.edit_draft) {
s = "edit_draft";
- } else if (id == R.id.details_collapsed_content) {
+ } else if (id == R.id.send_date) {
s = "expand_message_details";
- } else if (id == R.id.details_expanded_content) {
+ } else if (id == R.id.details_expanded_content || id == R.id.hide_details) {
s = "collapse_message_details";
} else if (id == R.id.upper_header) {
s = "message_upper_header";
diff --git a/src/com/android/mail/browse/MessageHeaderContactBadge.java b/src/com/android/mail/browse/MessageHeaderContactBadge.java
index 1bf745d..3d2c0fb 100644
--- a/src/com/android/mail/browse/MessageHeaderContactBadge.java
+++ b/src/com/android/mail/browse/MessageHeaderContactBadge.java
@@ -18,29 +18,55 @@
package com.android.mail.browse;
import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.net.Uri;
import android.util.AttributeSet;
import android.view.View;
+import android.widget.ImageView;
import android.widget.QuickContactBadge;
+import com.android.mail.R;
import com.android.mail.analytics.Analytics;
-import com.android.mail.utils.LogUtils;
-public class MessageHeaderContactBadge extends QuickContactBadge {
+public class MessageHeaderContactBadge extends ImageView implements View.OnClickListener {
+
+ private final QuickContactBadge mQuickContactBadge;
+
+ private Drawable mDefaultAvatar;
+
public MessageHeaderContactBadge(Context context) {
- super(context);
+ this(context, null);
}
public MessageHeaderContactBadge(Context context, AttributeSet attrs) {
- super(context, attrs);
+ this(context, attrs, 0);
}
public MessageHeaderContactBadge(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+
+ mQuickContactBadge = new QuickContactBadge(context, attrs, defStyle);
+ setOnClickListener(this);
}
@Override
public void onClick(View v) {
Analytics.getInstance().sendEvent("quick_contact", "clicked", null, 0);
- super.onClick(v);
+ mQuickContactBadge.onClick(v);
+ }
+
+ public void setImageToDefault() {
+ if (mDefaultAvatar == null) {
+ mDefaultAvatar = getResources().getDrawable(R.drawable.ic_contact_picture);
+ }
+ setImageDrawable(mDefaultAvatar);
+ }
+
+ public void assignContactUri(Uri contactUri) {
+ mQuickContactBadge.assignContactUri(contactUri);
+ }
+
+ public void assignContactFromEmail(String emailAddress, boolean lazyLookup) {
+ mQuickContactBadge.assignContactFromEmail(emailAddress, lazyLookup);
}
}
diff --git a/src/com/android/mail/browse/MessageHeaderView.java b/src/com/android/mail/browse/MessageHeaderView.java
index 6910c8b..229d122 100644
--- a/src/com/android/mail/browse/MessageHeaderView.java
+++ b/src/com/android/mail/browse/MessageHeaderView.java
@@ -23,13 +23,17 @@
import android.content.res.Resources;
import android.database.DataSetObserver;
import android.graphics.Bitmap;
-import android.graphics.Typeface;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffXfermode;
import android.support.v4.text.BidiFormatter;
+import android.text.Html;
import android.text.Spannable;
-import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
-import android.text.style.StyleSpan;
+import android.text.method.LinkMovementMethod;
import android.text.style.URLSpan;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@@ -40,7 +44,6 @@
import android.view.ViewGroup;
import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
-import android.widget.QuickContactBadge;
import android.widget.TextView;
import android.widget.Toast;
@@ -59,10 +62,12 @@
import com.android.mail.providers.Message;
import com.android.mail.providers.Settings;
import com.android.mail.providers.UIProvider;
+import com.android.mail.text.EmailAddressSpan;
import com.android.mail.ui.AbstractConversationViewFragment;
import com.android.mail.ui.ImageCanvas;
import com.android.mail.utils.LogTag;
import com.android.mail.utils.LogUtils;
+import com.android.mail.utils.StyleUtils;
import com.android.mail.utils.Utils;
import com.android.mail.utils.VeiledAddressMatcher;
import com.google.common.annotations.VisibleForTesting;
@@ -98,14 +103,15 @@
private MessageHeaderViewCallbacks mCallbacks;
private ViewGroup mUpperHeaderView;
+ private View mTitleContainer;
private View mSnapHeaderBottomBorder;
private TextView mSenderNameView;
- private TextView mSenderEmailView;
+ private TextView mRecipientSummary;
private TextView mDateView;
+ private View mHideDetailsView;
private TextView mSnippetView;
- private QuickContactBadge mPhotoView;
+ private MessageHeaderContactBadge mPhotoView;
private ViewGroup mExtraContentView;
- private ViewGroup mCollapsedDetailsView;
private ViewGroup mExpandedDetailsView;
private SpamWarningView mSpamWarningView;
private TextView mImagePromptView;
@@ -151,7 +157,7 @@
private MessageHeaderItem mMessageHeaderItem;
private ConversationMessage mMessage;
- private boolean mCollapsedDetailsValid;
+ private boolean mRecipientSummaryValid;
private boolean mExpandedDetailsValid;
private final LayoutInflater mInflater;
@@ -181,6 +187,7 @@
private LetterTileProvider mLetterTileProvider;
private final int mContactPhotoWidth;
private final int mContactPhotoHeight;
+ private final int mTitleContainerMarginEnd;
/**
* The snappy header has special visibility rules (i.e. no details header,
@@ -232,23 +239,27 @@
mInflater = LayoutInflater.from(context);
mMyName = context.getString(R.string.me_object_pronoun);
- final Resources resources = getResources();
- mContactPhotoWidth = resources.getDimensionPixelSize(
+ final Resources res = getResources();
+ mContactPhotoWidth = res.getDimensionPixelSize(
R.dimen.message_header_contact_photo_width);
- mContactPhotoHeight = resources.getDimensionPixelSize(
+ mContactPhotoHeight = res.getDimensionPixelSize(
R.dimen.message_header_contact_photo_height);
+ mTitleContainerMarginEnd = res.getDimensionPixelSize(
+ R.dimen.conversation_view_margin_side);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mUpperHeaderView = (ViewGroup) findViewById(R.id.upper_header);
+ mTitleContainer = findViewById(R.id.title_container);
mSnapHeaderBottomBorder = findViewById(R.id.snap_header_bottom_border);
mSenderNameView = (TextView) findViewById(R.id.sender_name);
- mSenderEmailView = (TextView) findViewById(R.id.sender_email);
+ mRecipientSummary = (TextView) findViewById(R.id.recipient_summary);
mDateView = (TextView) findViewById(R.id.send_date);
+ mHideDetailsView = findViewById(R.id.hide_details);
mSnippetView = (TextView) findViewById(R.id.email_snippet);
- mPhotoView = (QuickContactBadge) findViewById(R.id.photo);
+ mPhotoView = (MessageHeaderContactBadge) findViewById(R.id.photo);
mReplyButton = findViewById(R.id.reply);
mReplyAllButton = findViewById(R.id.reply_all);
mForwardButton = findViewById(R.id.forward);
@@ -261,15 +272,14 @@
setExpanded(true);
- registerMessageClickTargets(R.id.reply, R.id.reply_all, R.id.forward,
- R.id.edit_draft, R.id.overflow, R.id.upper_header);
+ registerMessageClickTargets(mReplyButton, mReplyAllButton, mForwardButton,
+ mEditDraftButton, mOverflowButton, mUpperHeaderView, mDateView, mHideDetailsView);
mUpperHeaderView.setOnCreateContextMenuListener(mEmailCopyMenu);
}
- private void registerMessageClickTargets(int... ids) {
- for (int id : ids) {
- View v = findViewById(id);
+ private void registerMessageClickTargets(View... views) {
+ for (View v : views) {
if (v != null) {
v.setOnClickListener(this);
}
@@ -389,7 +399,7 @@
Timer t = new Timer();
t.start(HEADER_RENDER_TAG);
- mCollapsedDetailsValid = false;
+ mRecipientSummaryValid = false;
mExpandedDetailsValid = false;
mMessage = mMessageHeaderItem.getMessage();
@@ -451,8 +461,8 @@
mSnippet = snippet == null ? null : getBidiFormatter().unicodeWrap(snippet);
mSenderNameView.setText(getHeaderTitle());
- mSenderEmailView.setText(getHeaderSubtitle());
- mDateView.setText(mMessageHeaderItem.getTimestampLong());
+ setRecipientSummary();
+ setDateText();
mSnippetView.setText(mSnippet);
setAddressOnContextMenu();
@@ -539,23 +549,30 @@
return title;
}
- private CharSequence getHeaderSubtitle() {
- CharSequence sub;
- if (mSendingState != UIProvider.ConversationSendingState.OTHER) {
- sub = null;
- } else {
- if (isExpanded()) {
- if (mMessage.viaDomain != null) {
- sub = getResources().getString(
- R.string.via_domain, mMessage.viaDomain);
- } else {
- sub = getSenderAddress(mSender);
- }
- } else {
- sub = mSnippet;
+ private void setRecipientSummary() {
+ if (!mRecipientSummaryValid) {
+ if (mMessageHeaderItem.recipientSummaryText == null) {
+ final Account account = getAccount();
+ final String meEmailAddress = (account != null) ? account.getEmailAddress() : "";
+ mMessageHeaderItem.recipientSummaryText = getRecipientSummaryText(getContext(),
+ meEmailAddress, mMyName, mTo, mCc, mBcc, mAddressCache, mVeiledMatcher,
+ getBidiFormatter());
}
+ mRecipientSummary.setText(mMessageHeaderItem.recipientSummaryText);
+ mRecipientSummaryValid = true;
}
- return sub;
+ }
+
+ private void setDateText() {
+ if (mIsSnappy) {
+ mDateView.setText(mMessageHeaderItem.getTimestampLong());
+ mDateView.setOnClickListener(null);
+ } else {
+ mDateView.setMovementMethod(LinkMovementMethod.getInstance());
+ mDateView.setText(Html.fromHtml(getResources().getString(
+ R.string.date_and_view_details, mMessageHeaderItem.getTimestampLong())));
+ StyleUtils.stripUnderlinesAndUrl(mDateView);
+ }
}
/**
@@ -569,13 +586,6 @@
return TextUtils.isEmpty(displayName) ? sender.getAddress() : displayName;
}
- /**
- * Return the address, if a name is present, or null if not.
- */
- private static CharSequence getSenderAddress(Address sender) {
- return (sender != null) ? sender.getAddress() : "";
- }
-
private static void setChildVisibility(int visibility, View... children) {
for (View v : children) {
if (v != null) {
@@ -607,7 +617,9 @@
setChildVisibility(GONE, mReplyButton, mReplyAllButton, mForwardButton,
mOverflowButton, mDraftIcon, mEditDraftButton,
mAttachmentIcon, mUpperDateView, mSnippetView);
- setChildVisibility(VISIBLE, mPhotoView, mSenderEmailView, mDateView);
+ setChildVisibility(VISIBLE, mPhotoView, mRecipientSummary);
+
+ setChildMarginEnd(mTitleContainer, 0);
} else if (isExpanded()) {
int normalVis, draftVis;
@@ -626,30 +638,31 @@
setReplyOrReplyAllVisible();
setChildVisibility(normalVis, mPhotoView, mForwardButton, mOverflowButton);
setChildVisibility(draftVis, mDraftIcon, mEditDraftButton);
- setChildVisibility(VISIBLE, mSenderEmailView, mDateView);
+ setChildVisibility(VISIBLE, mRecipientSummary);
setChildVisibility(GONE, mAttachmentIcon, mUpperDateView, mSnippetView);
+
+ setChildMarginEnd(mTitleContainer, 0);
} else {
setMessageDetailsVisibility(GONE);
setChildVisibility(GONE, mSnapHeaderBottomBorder);
setChildVisibility(VISIBLE, mSnippetView, mUpperDateView);
setChildVisibility(GONE, mEditDraftButton, mReplyButton, mReplyAllButton,
- mForwardButton, mOverflowButton, mSenderEmailView, mDateView);
+ mForwardButton, mOverflowButton, mRecipientSummary,
+ mDateView, mHideDetailsView);
setChildVisibility(mMessage.hasAttachments ? VISIBLE : GONE,
mAttachmentIcon);
if (mIsDraft) {
-
setChildVisibility(VISIBLE, mDraftIcon);
setChildVisibility(GONE, mPhotoView);
-
} else {
-
setChildVisibility(GONE, mDraftIcon);
setChildVisibility(VISIBLE, mPhotoView);
-
}
+
+ setChildMarginEnd(mTitleContainer, mTitleContainerMarginEnd);
}
}
@@ -687,60 +700,75 @@
childView.setLayoutParams(mlp);
}
+
+
+ @VisibleForTesting
+ static CharSequence getRecipientSummaryText(Context context, String meEmailAddress,
+ String myName, String[] to, String[] cc, String[] bcc,
+ Map<String, Address> addressCache, VeiledAddressMatcher matcher,
+ BidiFormatter bidiFormatter) {
+
+ final RecipientListsBuilder builder = new RecipientListsBuilder(
+ context, meEmailAddress, myName, addressCache, matcher, bidiFormatter);
+
+ builder.append(to);
+ builder.append(cc);
+ builder.append(bcc);
+
+ return builder.build();
+ }
+
/**
* Utility class to build a list of recipient lists.
*/
private static class RecipientListsBuilder {
private final Context mContext;
- private final String mMe;
+ private final String mMeEmailAddress;
private final String mMyName;
- private final SpannableStringBuilder mBuilder = new SpannableStringBuilder();
+ private final StringBuilder mBuilder = new StringBuilder();
private final CharSequence mComma;
private final Map<String, Address> mAddressCache;
private final VeiledAddressMatcher mMatcher;
+ private final BidiFormatter mBidiFormatter;
int mRecipientCount = 0;
boolean mFirst = true;
- public RecipientListsBuilder(Context context, String me, String myName,
- Map<String, Address> addressCache, VeiledAddressMatcher matcher) {
+ public RecipientListsBuilder(Context context, String meEmailAddress, String myName,
+ Map<String, Address> addressCache, VeiledAddressMatcher matcher,
+ BidiFormatter bidiFormatter) {
mContext = context;
- mMe = me;
+ mMeEmailAddress = meEmailAddress;
mMyName = myName;
mComma = mContext.getText(R.string.enumeration_comma);
mAddressCache = addressCache;
mMatcher = matcher;
+ mBidiFormatter = bidiFormatter;
}
- public void append(String[] recipients, int headingRes) {
- int addLimit = SUMMARY_MAX_RECIPIENTS - mRecipientCount;
- CharSequence recipientList = getSummaryTextForHeading(headingRes, recipients, addLimit);
- if (recipientList != null) {
- // duplicate TextUtils.join() logic to minimize temporary
- // allocations, and because we need to support spans
- if (mFirst) {
- mFirst = false;
- } else {
- mBuilder.append(RECIPIENT_HEADING_DELIMITER);
- }
- mBuilder.append(recipientList);
+ public void append(String[] recipients) {
+ final int addLimit = SUMMARY_MAX_RECIPIENTS - mRecipientCount;
+ final boolean hasRecipients = appendRecipients(recipients, addLimit);
+ if (hasRecipients) {
mRecipientCount += Math.min(addLimit, recipients.length);
}
}
- private CharSequence getSummaryTextForHeading(int headingStrRes, String[] rawAddrs,
+ /**
+ * Appends formatted recipients of the message to the recipient list,
+ * as long as there are recipients left to append and the maximum number
+ * of addresses limit has not been reached.
+ * @param rawAddrs The addresses to append.
+ * @param maxToCopy The maximum number of addresses to append.
+ * @return {@code true} if a recipient has been appended. {@code false}, otherwise.
+ */
+ private boolean appendRecipients(String[] rawAddrs,
int maxToCopy) {
if (rawAddrs == null || rawAddrs.length == 0 || maxToCopy == 0) {
- return null;
+ return false;
}
- SpannableStringBuilder ssb = new SpannableStringBuilder(
- mContext.getString(headingStrRes));
- ssb.setSpan(new StyleSpan(Typeface.NORMAL), 0, ssb.length(),
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
-
final int len = Math.min(maxToCopy, rawAddrs.length);
- boolean first = true;
for (int i = 0; i < len; i++) {
final Address email = Utils.getAddress(mAddressCache, rawAddrs[i]);
final String emailAddress = email.getAddress();
@@ -754,42 +782,27 @@
}
} else {
// Not a veiled address, show first part of email, or "me".
- name = mMe.equals(emailAddress) ? mMyName : email.getSimplifiedName();
+ name = mMeEmailAddress.equals(emailAddress) ?
+ mMyName : email.getSimplifiedName();
}
- // duplicate TextUtils.join() logic to minimize temporary
- // allocations, and because we need to support spans
- if (first) {
- first = false;
+ // duplicate TextUtils.join() logic to minimize temporary allocations
+ if (mFirst) {
+ mFirst = false;
} else {
- ssb.append(mComma);
+ mBuilder.append(mComma);
}
- ssb.append(name);
+ mBuilder.append(mBidiFormatter.unicodeWrap(name));
}
- return ssb;
+ return true;
}
public CharSequence build() {
- return mBuilder;
+ return mContext.getString(R.string.to_message_header, mBuilder);
}
}
- @VisibleForTesting
- static CharSequence getRecipientSummaryText(Context context, String me, String myName,
- String[] to, String[] cc, String[] bcc, Map<String, Address> addressCache,
- VeiledAddressMatcher matcher) {
-
- final RecipientListsBuilder builder =
- new RecipientListsBuilder(context, me, myName, addressCache, matcher);
-
- builder.append(to, R.string.to_heading);
- builder.append(cc, R.string.cc_heading);
- builder.append(bcc, R.string.bcc_heading);
-
- return builder.build();
- }
-
private void updateContactInfo() {
if (mContactInfoSource == null || mSender == null) {
mPhotoView.setImageToDefault();
@@ -809,6 +822,7 @@
boolean photoSet = false;
final String email = mSender.getAddress();
final ContactInfo info = mContactInfoSource.getContactInfo(email);
+ final Resources res = getResources();
if (info != null) {
if (info.contactUri != null) {
mPhotoView.assignContactUri(info.contactUri);
@@ -817,7 +831,7 @@
}
if (info.photo != null) {
- mPhotoView.setImageBitmap(info.photo);
+ mPhotoView.setImageBitmap(frameBitmapInCircle(info.photo));
photoSet = true;
}
} else {
@@ -825,7 +839,8 @@
}
if (!photoSet) {
- mPhotoView.setImageBitmap(makeLetterTile(mSender.getPersonal(), email));
+ mPhotoView.setImageBitmap(
+ frameBitmapInCircle(makeLetterTile(mSender.getPersonal(), email)));
}
}
@@ -840,6 +855,45 @@
return mLetterTileProvider.getLetterTile(dimensions, displayName, senderAddress);
}
+ /**
+ * Frames the input bitmap in a circle.
+ */
+ private static Bitmap frameBitmapInCircle(Bitmap input) {
+ if (input == null) {
+ return null;
+ }
+
+ // Crop the image if not squared.
+ int inputWidth = input.getWidth();
+ int inputHeight = input.getHeight();
+ int targetX, targetY, targetSize;
+ if (inputWidth >= inputHeight) {
+ targetX = inputWidth / 2 - inputHeight / 2;
+ targetY = 0;
+ targetSize = inputHeight;
+ } else {
+ targetX = 0;
+ targetY = inputHeight / 2 - inputWidth / 2;
+ targetSize = inputWidth;
+ }
+
+ // Create an output bitmap and a canvas to draw on it.
+ Bitmap output = Bitmap.createBitmap(targetSize, targetSize, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(output);
+
+ // Create a black paint to draw the mask.
+ Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ paint.setColor(Color.BLACK);
+
+ // Draw a circle.
+ canvas.drawCircle(targetSize / 2, targetSize / 2, targetSize / 2, paint);
+
+ // Replace the black parts of the mask with the input image.
+ paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
+ canvas.drawBitmap(input, targetX /* left */, targetY /* top */, paint);
+
+ return output;
+ }
@Override
public boolean onMenuItemClick(MenuItem item) {
@@ -902,9 +956,9 @@
m.findItem(R.id.report_rendering_problem).setVisible(reportRendering);
mPopup.show();
- } else if (id == R.id.details_collapsed_content
- || id == R.id.details_expanded_content) {
- toggleMessageDetails(v);
+ } else if (id == R.id.send_date || id == R.id.hide_details ||
+ id == R.id.details_expanded_content) {
+ toggleMessageDetails();
} else if (id == R.id.upper_header) {
toggleExpanded();
} else if (id == R.id.show_pictures_text) {
@@ -957,8 +1011,8 @@
// The snappy header will disappear; no reason to update text.
if (!isSnappy()) {
mSenderNameView.setText(getHeaderTitle());
- mSenderEmailView.setText(getHeaderSubtitle());
- mDateView.setText(mMessageHeaderItem.getTimestampLong());
+ setRecipientSummary();
+ setDateText();
mSnippetView.setText(mSnippet);
}
@@ -988,25 +1042,22 @@
return mIsSnappy;
}
- private void toggleMessageDetails(View visibleDetailsView) {
+ private void toggleMessageDetails() {
int heightBefore = measureHeight();
- final boolean detailsExpanded = (visibleDetailsView == mCollapsedDetailsView);
- Analytics.getInstance().sendEvent(
- "message_header", "toggle_details", detailsExpanded ? "expand" : "collapse", 0);
- setMessageDetailsExpanded(detailsExpanded);
+ final boolean expand =
+ (mExpandedDetailsView == null || mExpandedDetailsView.getVisibility() == GONE);
+ setMessageDetailsExpanded(expand);
updateSpacerHeight();
if (mCallbacks != null) {
- mCallbacks.setMessageDetailsExpanded(mMessageHeaderItem, detailsExpanded, heightBefore);
+ mCallbacks.setMessageDetailsExpanded(mMessageHeaderItem, expand, heightBefore);
}
}
private void setMessageDetailsExpanded(boolean expand) {
if (expand) {
showExpandedDetails();
- hideCollapsedDetails();
} else {
hideExpandedDetails();
- showCollapsedDetails();
}
if (mMessageHeaderItem != null) {
@@ -1016,7 +1067,6 @@
public void setMessageDetailsVisibility(int vis) {
if (vis == GONE) {
- hideCollapsedDetails();
hideExpandedDetails();
hideSpamWarning();
hideShowImagePrompt();
@@ -1051,16 +1101,12 @@
setMessageDetailsVisibility(GONE);
}
- private void hideCollapsedDetails() {
- if (mCollapsedDetailsView != null) {
- mCollapsedDetailsView.setVisibility(GONE);
- }
- }
-
private void hideExpandedDetails() {
if (mExpandedDetailsView != null) {
mExpandedDetailsView.setVisibility(GONE);
}
+ mDateView.setVisibility(VISIBLE);
+ mHideDetailsView.setVisibility(GONE);
}
private void hideInvite() {
@@ -1178,32 +1224,6 @@
}
/**
- * Makes collapsed details visible. If necessary, will inflate details
- * layout and render using saved-off state (senders, timestamp, etc).
- */
- private void showCollapsedDetails() {
- if (mCollapsedDetailsView == null) {
- mCollapsedDetailsView = (ViewGroup) mInflater.inflate(
- R.layout.conversation_message_details_header, this, false);
- mExtraContentView.addView(mCollapsedDetailsView, 0);
- mCollapsedDetailsView.setOnClickListener(this);
- }
- if (!mCollapsedDetailsValid) {
- if (mMessageHeaderItem.recipientSummaryText == null) {
- final Account account = getAccount();
- final String name = (account != null) ? account.getEmailAddress() : "";
- mMessageHeaderItem.recipientSummaryText = getRecipientSummaryText(getContext(),
- name, mMyName, mTo, mCc, mBcc, mAddressCache, mVeiledMatcher);
- }
- ((TextView) findViewById(R.id.recipients_summary))
- .setText(mMessageHeaderItem.recipientSummaryText);
-
- mCollapsedDetailsValid = true;
- }
- mCollapsedDetailsView.setVisibility(VISIBLE);
- }
-
- /**
* Makes expanded details visible. If necessary, will inflate expanded
* details layout and render using saved-off state (senders, timestamp,
* etc).
@@ -1215,6 +1235,8 @@
mExtraContentView.addView(mExpandedDetailsView, 0);
}
mExpandedDetailsView.setVisibility(VISIBLE);
+ mDateView.setVisibility(GONE);
+ mHideDetailsView.setVisibility(VISIBLE);
}
private boolean ensureExpandedDetailsView() {
@@ -1238,8 +1260,7 @@
}
public static View inflateExpandedDetails(LayoutInflater inflater) {
- return inflater.inflate(R.layout.conversation_message_details_header_expanded, null,
- false);
+ return inflater.inflate(R.layout.conversation_message_header_details, null, false);
}
public static void renderExpandedDetails(Resources res, View detailsView,
diff --git a/src/com/android/mail/print/PrintUtils.java b/src/com/android/mail/print/PrintUtils.java
index 30d11ce..ee04d9c 100644
--- a/src/com/android/mail/print/PrintUtils.java
+++ b/src/com/android/mail/print/PrintUtils.java
@@ -190,7 +190,7 @@
.append(DIV_END);
} else {
buildEmailDiv(res, recipients, to, DIV_START, DIV_END,
- isDraft ? R.string.draft_to_heading : R.string.to_heading);
+ isDraft ? R.string.draft_to_heading : R.string.to_heading_no_space);
}
// cc
@@ -213,7 +213,7 @@
String divStart, String divEnd, int headingId) {
if (emailList != null) {
recipients.append(divStart).append(res.getString(headingId))
- .append(emailList).append(divEnd);
+ .append('\u0020').append(emailList).append(divEnd);
}
}
diff --git a/src/com/android/mail/browse/EmailAddressSpan.java b/src/com/android/mail/text/EmailAddressSpan.java
similarity index 97%
rename from src/com/android/mail/browse/EmailAddressSpan.java
rename to src/com/android/mail/text/EmailAddressSpan.java
index cbf5ec4..194bc42 100644
--- a/src/com/android/mail/browse/EmailAddressSpan.java
+++ b/src/com/android/mail/text/EmailAddressSpan.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.mail.browse;
+package com.android.mail.text;
import android.text.TextPaint;
import android.text.style.URLSpan;
diff --git a/src/com/android/mail/browse/UrlSpan.java b/src/com/android/mail/text/LinkStyleSpan.java
similarity index 76%
copy from src/com/android/mail/browse/UrlSpan.java
copy to src/com/android/mail/text/LinkStyleSpan.java
index 9e3d172..a817bc4 100644
--- a/src/com/android/mail/browse/UrlSpan.java
+++ b/src/com/android/mail/text/LinkStyleSpan.java
@@ -15,23 +15,25 @@
* limitations under the License.
*/
-package com.android.mail.browse;
+package com.android.mail.text;
import android.text.TextPaint;
-import android.text.style.URLSpan;
+import android.text.style.ClickableSpan;
+import android.view.View;
/**
- * Extension to URLSpan that does not have underlines.
- * Stupid URLSpan.<p/>
+ * A span that makes text look like a link. It uses link color and
+ * has no underline but clicking it does nothing.<p/>
*
* WARNING: this span will not work if the TextView it uses
* saves and restores its text since TextView can only save
* and restore {@link android.text.ParcelableSpan}s which
* can only be implemented by framework Spans.
*/
-public class UrlSpan extends URLSpan {
- public UrlSpan(String url) {
- super(url);
+public class LinkStyleSpan extends ClickableSpan {
+ @Override
+ public void onClick(View widget) {
+ // do nothing
}
/**
diff --git a/src/com/android/mail/browse/UrlSpan.java b/src/com/android/mail/text/UrlSpan.java
similarity index 97%
rename from src/com/android/mail/browse/UrlSpan.java
rename to src/com/android/mail/text/UrlSpan.java
index 9e3d172..7d7f989 100644
--- a/src/com/android/mail/browse/UrlSpan.java
+++ b/src/com/android/mail/text/UrlSpan.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.mail.browse;
+package com.android.mail.text;
import android.text.TextPaint;
import android.text.style.URLSpan;
diff --git a/src/com/android/mail/utils/StyleUtils.java b/src/com/android/mail/utils/StyleUtils.java
index 5a0a38e..57581e3 100644
--- a/src/com/android/mail/utils/StyleUtils.java
+++ b/src/com/android/mail/utils/StyleUtils.java
@@ -19,10 +19,14 @@
import android.text.Spannable;
import android.text.Spanned;
+import android.text.TextPaint;
+import android.text.style.ClickableSpan;
import android.text.style.URLSpan;
+import android.view.View;
import android.widget.TextView;
-import com.android.mail.browse.UrlSpan;
+import com.android.mail.text.LinkStyleSpan;
+import com.android.mail.text.UrlSpan;
/**
* Utility class for styling UI.
@@ -31,7 +35,7 @@
/**
* Removes any {@link android.text.style.URLSpan}s from the text view
- * and replaces them with their non-underline version {@link com.android.mail.browse.UrlSpan}.
+ * and replaces them with their non-underline version {@link com.android.mail.text.UrlSpan}.
*/
public static void stripUnderlines(TextView textView) {
final Spannable spannable = (Spannable) textView.getText();
@@ -45,4 +49,21 @@
spannable.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
+
+ /**
+ * Removes any {@link android.text.style.URLSpan}s from the text view
+ * and replaces them with a non-underline version {@link LinkStyleSpan}
+ * that does nothing when clicked.
+ */
+ public static void stripUnderlinesAndUrl(TextView textView) {
+ final Spannable spannable = (Spannable) textView.getText();
+ final URLSpan[] urls = textView.getUrls();
+
+ for (URLSpan span : urls) {
+ final int start = spannable.getSpanStart(span);
+ final int end = spannable.getSpanEnd(span);
+ spannable.removeSpan(span);
+ spannable.setSpan(new LinkStyleSpan(), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
+ }
}
diff --git a/tests/src/com/android/mail/browse/MessageHeaderViewTest.java b/tests/src/com/android/mail/browse/MessageHeaderViewTest.java
index 1cadb73..f5fd557 100644
--- a/tests/src/com/android/mail/browse/MessageHeaderViewTest.java
+++ b/tests/src/com/android/mail/browse/MessageHeaderViewTest.java
@@ -17,6 +17,7 @@
package com.android.mail.browse;
+import android.support.v4.text.BidiFormatter;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
@@ -31,7 +32,7 @@
String[] to = makeRecipientArray("TO", 60);
String[] cc = makeRecipientArray("CC", 60);
String summary = MessageHeaderView.getRecipientSummaryText(getContext(), "", "", to, cc,
- null, new HashMap<String, Address>(), null).toString();
+ null, new HashMap<String, Address>(), null, BidiFormatter.getInstance()).toString();
assertTrue(summary.contains("TO00"));
assertTrue(summary.contains("TO49"));
@@ -44,7 +45,7 @@
String[] cc = makeRecipientArray("CC", 10);
String[] bcc = makeRecipientArray("BB", 60);
String summary = MessageHeaderView.getRecipientSummaryText(getContext(), "", "", to, cc,
- bcc, new HashMap<String, Address>(), null).toString();
+ bcc, new HashMap<String, Address>(), null, BidiFormatter.getInstance()).toString();
assertTrue(summary.contains("TO00"));
assertTrue(summary.contains("TO19"));