Merge "Sending a mail to self crashes gmail" into ub-gmail-ur14-dev
diff --git a/res/color/folder_item_text_color.xml b/res/color/folder_unread_text_color.xml
similarity index 78%
rename from res/color/folder_item_text_color.xml
rename to res/color/folder_unread_text_color.xml
index 55663cb..a51f6ba 100644
--- a/res/color/folder_item_text_color.xml
+++ b/res/color/folder_unread_text_color.xml
@@ -16,8 +16,7 @@
      limitations under the License.
 -->
 
-<selector xmlns:android="http://schemas.android.com/apk/res/android"
-          xmlns:app="http://schemas.android.com/apk/res-auto">
-    <item android:state_activated="true" android:color="@android:color/white" />
-    <item android:color="@color/folder_item_text_color_normal" />
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_activated="true" android:color="@color/text_color_black" />
+    <item android:color="@color/text_color_grey" />
 </selector>
diff --git a/res/drawable/folder_item.xml b/res/drawable/folder_item.xml
index f344803..98b1588 100644
--- a/res/drawable/folder_item.xml
+++ b/res/drawable/folder_item.xml
@@ -17,8 +17,6 @@
 -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:state_pressed="true" android:drawable="@drawable/list_pressed_holo" />
-    <item android:state_activated="true" android:drawable="@color/mail_app_blue" />
-    <item android:state_focused="true" android:drawable="@drawable/list_focused_holo" />
+    <item android:state_activated="true" android:drawable="@color/drawer_item_selected_background_color" />
     <item android:drawable="@android:color/transparent" />
 </selector>
diff --git a/res/layout-sw600dp/mail_toolbar_view.xml b/res/layout-sw600dp/mail_toolbar_view.xml
index f014999..3af1967 100644
--- a/res/layout-sw600dp/mail_toolbar_view.xml
+++ b/res/layout-sw600dp/mail_toolbar_view.xml
@@ -28,18 +28,23 @@
 
     <!-- Custom view for search icon -->
     <LinearLayout
+        android:id="@+id/actionbar_custom_view"
         android:layout_width="match_parent"
         android:layout_height="match_parent">
 
         <TextView
             android:id="@+id/actionbar_title"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
             android:ellipsize="end"
             android:gravity="center_vertical|start"
             android:paddingLeft="12dp"
             android:paddingRight="12dp"
             android:singleLine="true"
             android:textAlignment="viewStart"
-            style="@style/ActionBarTitleStyle" />
+            android:textColor="@android:color/white"
+            style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" />
 
         <ImageView
             android:id="@+id/actionbar_search_button"
diff --git a/res/layout/attachment.xml b/res/layout/attachment.xml
index 6ca4c03..deafb96 100644
--- a/res/layout/attachment.xml
+++ b/res/layout/attachment.xml
@@ -16,12 +16,16 @@
      limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    style="@style/AttachmentContainer"
-    android:focusableInTouchMode="true"
-    android:focusable="true">
+    android:layout_width="match_parent"
+    android:layout_height="48dp"
+    android:background="@drawable/attachment_bg_holo"
+    android:focusable="true"
+    android:focusableInTouchMode="true">
 
     <ImageView
         android:id="@+id/thumbnail"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
         android:src="@drawable/ic_attach_file_20dp"
         android:layout_gravity="center_vertical"
         style="@style/AttachmentThumbnail"/>
@@ -29,28 +33,36 @@
     <!-- Attachment name and size -->
     <LinearLayout
         android:orientation="vertical"
-        android:layout_width="0dip"
+        android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_weight="1"
         android:layout_gravity="center_vertical"
         style="@style/AttachmentTextContainer" >
 
         <TextView android:id="@+id/attachment_name"
-            style="@style/AttachmentName" />
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textAppearance="?android:attr/textAppearanceSmall"
+            android:textColor="@color/attachment_name_color"
+            android:singleLine="true" />
 
         <TextView android:id="@+id/attachment_size"
-            style="@style/AttachmentSize" />
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textColor="@color/text_color_hint_grey"
+            android:textSize="12sp"
+            android:singleLine="true" />
 
     </LinearLayout>
 
     <!-- Remove button -->
     <ImageButton android:id="@+id/remove_attachment"
-        android:src="@drawable/ic_cancel_holo_light"
-        android:layout_width="48dip"
+        android:layout_width="48dp"
         android:layout_height="match_parent"
+        android:background="?android:attr/selectableItemBackground"
         android:clickable="true"
         android:gravity="center"
-        android:background="?android:attr/selectableItemBackground"/>
+        android:src="@drawable/ic_cancel_holo_light" />
 
 
 </LinearLayout>
diff --git a/res/layout/compose_attachment_tile.xml b/res/layout/compose_attachment_tile.xml
index f3496f8..aa68328 100644
--- a/res/layout/compose_attachment_tile.xml
+++ b/res/layout/compose_attachment_tile.xml
@@ -76,6 +76,7 @@
             android:layout_width="44dip"
             android:layout_height="44dip"
             android:layout_gravity="center_vertical|end|right"
+            android:contentDescription="@string/remove_attachment_desc"
             android:gravity="center"
             android:focusable="true"
             android:background="?android:attr/selectableItemBackground" />
diff --git a/res/layout/conversation_footer.xml b/res/layout/conversation_footer.xml
index 0306216..647999d 100644
--- a/res/layout/conversation_footer.xml
+++ b/res/layout/conversation_footer.xml
@@ -54,9 +54,8 @@
 
     </LinearLayout>
 
-    <View
+    <Space
         android:layout_width="match_parent"
-        android:layout_height="48dp"
-        android:background="@color/conversation_view_item_background_color" />
+        android:layout_height="48dp" />
 
-</com.android.mail.browse.ConversationFooterView>
\ No newline at end of file
+</com.android.mail.browse.ConversationFooterView>
diff --git a/res/layout/conversation_view_header.xml b/res/layout/conversation_view_header.xml
index e819e7a..89f9574 100644
--- a/res/layout/conversation_view_header.xml
+++ b/res/layout/conversation_view_header.xml
@@ -20,7 +20,6 @@
     android:id="@+id/conversation_header"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:background="@color/conversation_view_item_background_color"
     android:orientation="horizontal"
     android:minHeight="88sp"
     android:paddingTop="16dp"
diff --git a/res/layout/fake_bottom_border.xml b/res/layout/fake_bottom_border.xml
index c80ff4a..e27d7d6 100644
--- a/res/layout/fake_bottom_border.xml
+++ b/res/layout/fake_bottom_border.xml
@@ -15,7 +15,6 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<View xmlns:android="http://schemas.android.com/apk/res/android"
+<Space xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="match_parent"
-      android:layout_height="wrap_content"
-      android:background="@color/conversation_view_item_background_color" />
+      android:layout_height="wrap_content" />
diff --git a/res/layout/folder_item.xml b/res/layout/folder_item.xml
index 4b3b411..f4cccbb 100644
--- a/res/layout/folder_item.xml
+++ b/res/layout/folder_item.xml
@@ -45,7 +45,7 @@
         android:maxLines="2"
         android:ellipsize="end"
         android:textAlignment="viewStart"
-        android:textColor="@color/folder_item_text_color"
+        android:textColor="@color/text_color_black"
         android:textSize="@dimen/drawer_item_font_size"
         style="@style/FolderListItemStyle" />
 
diff --git a/res/values-ldrtl/styles-ldrtl.xml b/res/values-ldrtl/styles-ldrtl.xml
index f94abea..5dbe494 100644
--- a/res/values-ldrtl/styles-ldrtl.xml
+++ b/res/values-ldrtl/styles-ldrtl.xml
@@ -101,6 +101,10 @@
         <item name="android:layout_marginStart">@dimen/attachment_icon_padding</item>
     </style>
 
+    <style name="AttachmentThumbnail">
+        <item name="android:layout_marginStart">@dimen/attachment_item_padding_start</item>
+    </style>
+
     <style name="UnreadCountWithMarginEndStyle" parent="UnreadCountRelativeLayout">
         <item name="android:layout_marginEnd">@dimen/folder_list_item_end_margin</item>
         <item name="android:layout_alignParentEnd">true</item>
diff --git a/res/values-sw600dp-land/styles.xml b/res/values-sw600dp-land/styles.xml
index 0754f8e..9da5e9d 100644
--- a/res/values-sw600dp-land/styles.xml
+++ b/res/values-sw600dp-land/styles.xml
@@ -21,10 +21,4 @@
         <item name="android:layout_weight">70</item>
         <item name="android:maxWidth">@dimen/compose_scrollview_max_width</item>
     </style>
-
-    <style name="ActionBarTitleStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
-        <item name="android:layout_width">wrap_content</item>
-        <item name="android:layout_height">match_parent</item>
-        <item name="android:textColor">@android:color/white</item>
-    </style>
 </resources>
diff --git a/res/values-sw600dp/colors.xml b/res/values-sw600dp/colors.xml
index ddd1dee..1fe2717 100644
--- a/res/values-sw600dp/colors.xml
+++ b/res/values-sw600dp/colors.xml
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <color name="folder_list_divider_color">#b2b2b2</color>
-</resources>
\ No newline at end of file
+    <color name="drawer_item_selected_background_color">#e4e4e4</color>
+</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index aa76131..462fa2c 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -53,6 +53,7 @@
     <color name="account_item_selected_text_color">@color/mail_app_blue</color>
     <color name="folder_list_heading_text_color">@color/text_color_medium_grey</color>
     <color name="list_background_color">@android:color/white</color>
+    <color name="drawer_item_selected_background_color">#eeeeee</color>
     <!-- overridden in sw600dp -->
     <color name="folder_list_divider_color">@color/divider_color</color>
 
@@ -71,8 +72,6 @@
     <!-- Conversation message header colors -->
     <color name="conversation_view_border_color">@color/divider_color</color>
     <color name="conversation_view_background_color">#f5f5f5</color>
-    <!-- Overridden on tablet to give a white background -->
-    <color name="conversation_view_item_background_color">@android:color/white</color>
     <color name="conversation_view_text_color_light">@color/text_color_grey</color>
     <color name="conversation_view_text_color_dark">@color/text_color_black</color>
     <color name="conversation_view_text_color_link_blue">@color/text_color_blue</color>
@@ -82,6 +81,7 @@
     <color name="widget_header_bg_color">#da4336</color>
     <color name="widget_conversation_list_divider_color">#e5e5e5</color>
 
+    <color name="attachment_name_color">#333333</color>
     <!--  Color of the semi-transparent shadow box on attachment tiles -->
     <color name="attachment_tile_shadow_box_color">#7F000000</color>
     <!--  Color of the subtitle message in the attachment tile -->
diff --git a/res/values/dimen.xml b/res/values/dimen.xml
index 59a05bb..1494c35 100644
--- a/res/values/dimen.xml
+++ b/res/values/dimen.xml
@@ -123,6 +123,7 @@
     <dimen name="send_mail_as_padding">8dip</dimen>
     <dimen name="dismiss_separator_padding">16dip</dimen>
     <dimen name="teaser_text_padding">16dp</dimen>
+    <dimen name="attachment_item_padding_start">8dp</dimen>
     <dimen name="attachment_padding_start">16dp</dimen>
     <dimen name="attachment_padding_end">16dp</dimen>
     <dimen name="attachment_icon_padding">5dip</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index d0a48f5..0c9e109 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -148,35 +148,6 @@
         <item name="android:paddingRight">@dimen/compose_attachment_tile_text_end_padding</item>
     </style>
 
-    <style name="AttachmentContainer">
-        <item name="android:background">@drawable/attachment_bg_holo</item>
-        <item name="android:layout_width">match_parent</item>
-        <item name="android:layout_height">48dip</item>
-    </style>
-
-    <style name="AttachmentTextContainer">
-        <item name="android:paddingLeft">@dimen/compose_attachment_text_padding</item>
-    </style>
-
-    <style name="AttachmentName">
-        <item name="android:singleLine">true</item>
-        <item name="android:layout_width">wrap_content</item>
-        <item name="android:layout_height">wrap_content</item>
-        <item name="android:textColor">#333333</item>
-        <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
-    </style>
-
-    <style name="AttachmentSize" parent="@style/AttachmentName">
-        <item name="android:textColor">#aaaaaa</item>
-        <item name="android:textSize">12sp</item>
-    </style>
-
-    <style name="AttachmentThumbnail">
-        <item name="android:layout_marginLeft">8dip</item>
-        <item name="android:layout_width">wrap_content</item>
-        <item name="android:layout_height">wrap_content</item>
-    </style>
-
     <style name="QuotedTextCheckbox">
         <item name="android:layout_marginLeft">@dimen/quoted_text_checkbox_margin_offset</item>
     </style>
@@ -190,7 +161,7 @@
         <item name="android:singleLine">true</item>
         <item name="android:includeFontPadding">true</item>
         <item name="android:textSize">14sp</item>
-        <item name="android:textColor">@color/folder_item_text_color</item>
+        <item name="android:textColor">@color/folder_unread_text_color</item>
         <item name="android:paddingTop">4dp</item>
         <item name="android:paddingBottom">4dp</item>
     </style>
@@ -459,13 +430,6 @@
         <item name="android:background">@color/actionbar_color</item>
     </style>
 
-    <style name="ActionBarTitleStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
-        <item name="android:layout_width">0dp</item>
-        <item name="android:layout_height">match_parent</item>
-        <item name="android:layout_weight">1</item>
-        <item name="android:textColor">@android:color/white</item>
-    </style>
-
     <style name="ActionBarTextAppearanceLargeStyle" parent="@android:style/TextAppearance.Holo.Widget.PopupMenu.Large">
         <item name="android:textColor">?android:attr/textColorPrimaryInverse</item>
     </style>
@@ -668,6 +632,14 @@
         <item name="android:layout_marginLeft">@dimen/attachment_icon_padding</item>
     </style>
 
+    <style name="AttachmentTextContainer">
+        <item name="android:paddingLeft">@dimen/compose_attachment_text_padding</item>
+    </style>
+
+    <style name="AttachmentThumbnail">
+        <item name="android:layout_marginLeft">@dimen/attachment_item_padding_start</item>
+    </style>
+
     <style name="UnreadCountWithMarginEndStyle" parent="UnreadCountRelativeLayout">
         <item name="android:layout_marginRight">@dimen/folder_list_item_end_margin</item>
         <item name="android:layout_alignParentRight">true</item>
diff --git a/src/com/android/mail/ui/CustomViewToolbar.java b/src/com/android/mail/ui/CustomViewToolbar.java
index 676321a..9d80af6 100644
--- a/src/com/android/mail/ui/CustomViewToolbar.java
+++ b/src/com/android/mail/ui/CustomViewToolbar.java
@@ -18,10 +18,10 @@
 package com.android.mail.ui;
 
 import android.content.Context;
-import android.graphics.Canvas;
 import android.support.v7.widget.Toolbar;
 import android.util.AttributeSet;
 import android.view.View;
+import android.view.ViewGroup;
 import android.widget.TextView;
 
 import com.android.mail.R;
@@ -33,11 +33,13 @@
  */
 public class CustomViewToolbar extends Toolbar implements ViewMode.ModeChangeListener,
         TwoPaneLayout.ConversationListLayoutListener {
+    private static final long FADE_ANIMATION_DURATION_MS = 150;
 
     private ControllableActivity mActivity;
     private ActivityController mController;
     private ViewMode mViewMode;
 
+    protected View mCustomView;
     protected TextView mActionBarTitle;
     protected View mSearchButton;
 
@@ -61,6 +63,7 @@
     protected void onFinishInflate() {
         super.onFinishInflate();
 
+        mCustomView = findViewById(R.id.actionbar_custom_view);
         mActionBarTitle = (TextView) findViewById(R.id.actionbar_title);
         mSearchButton = findViewById(R.id.actionbar_search_button);
 
@@ -90,25 +93,26 @@
     @Override
     public void onConversationListLayout(int xEnd, boolean drawerOpen) {
         if (drawerOpen) {
-            mSearchButton.setVisibility(INVISIBLE);
+            mSearchButton.setClickable(false);
+            mSearchButton.animate().alpha(0).setDuration(FADE_ANIMATION_DURATION_MS).start();
         } else {
-            mSearchButton.setVisibility(VISIBLE);
-            // Since we no longer shift the search button when the drawer opens/closes, only set
-            // the width of the title on the first pass (when width is 0) so we avoid changing
-            // width during layout passes.
+            mSearchButton.setClickable(true);
+            mSearchButton.animate().alpha(1).setDuration(FADE_ANIMATION_DURATION_MS).start();
+
             final int[] coords = new int[2];
-            mActionBarTitle.getLocationInWindow(coords);
+            mCustomView.getLocationInWindow(coords);
             final int newWidth;
             if (ViewUtils.isViewRtl(this)) {
-                newWidth = coords[0] + mActionBarTitle.getWidth() - xEnd -
-                        mSearchButton.getWidth();
+                newWidth = coords[0] + mCustomView.getWidth() - xEnd;
             } else {
-                newWidth = xEnd - coords[0] - mSearchButton.getWidth();
+                newWidth = xEnd - coords[0];
             }
 
             // Only set the width if it's different than before so we avoid draw on layout pass.
-            if (mActionBarTitle.getWidth() != newWidth) {
-                mActionBarTitle.setWidth(newWidth);
+            if (mCustomView.getWidth() != newWidth) {
+                final ViewGroup.LayoutParams params = mCustomView.getLayoutParams();
+                params.width = newWidth;
+                mCustomView.setLayoutParams(params);
             }
         }
     }
diff --git a/src/com/android/mail/ui/TwoPaneLayout.java b/src/com/android/mail/ui/TwoPaneLayout.java
index d687114..6cf560c 100644
--- a/src/com/android/mail/ui/TwoPaneLayout.java
+++ b/src/com/android/mail/ui/TwoPaneLayout.java
@@ -284,10 +284,13 @@
         final boolean listVisible = isRtl ? listX + mListView.getWidth() >= 0 : listX >= 0;
         adjustPaneVisibility(folderVisible, listVisible, cvOnScreen);
 
-        final List<ConversationListLayoutListener> layoutListeners =
-                mController.getConversationListLayoutListeners();
-        for (ConversationListLayoutListener listener : layoutListeners) {
-            listener.onConversationListLayout(isRtl ? listX : convX, isDrawerOpen);
+        if (!mListCollapsible) {
+            final int xEnd = isRtl ? listX : convX;
+            final List<ConversationListLayoutListener> layoutListeners =
+                    mController.getConversationListLayoutListeners();
+            for (ConversationListLayoutListener listener : layoutListeners) {
+                listener.onConversationListLayout(xEnd, isDrawerOpen);
+            }
         }
 
         mPositionedMode = mCurrentMode;