Add the right edge line to all teasers on tablets

Bug: 9177552
Change-Id: I5270a0ae2196e9a6f732ed6d3327ffe3d30f34be
diff --git a/res/layout/conversation_long_press_to_select_tip_view.xml b/res/layout/conversation_long_press_to_select_tip_view.xml
index 448ecee..0e92ff0 100644
--- a/res/layout/conversation_long_press_to_select_tip_view.xml
+++ b/res/layout/conversation_long_press_to_select_tip_view.xml
@@ -52,6 +52,8 @@
             android:scaleType="center"
             android:contentDescription="@string/dismiss_tip_hover_text"
             android:src="@drawable/ic_cancel_holo_light" />
+
+        <include layout="@layout/teaser_right_edge" />
     </LinearLayout>
 
 </com.android.mail.ui.ConversationLongPressTipView>
diff --git a/res/layout/conversation_outbox_tip_view.xml b/res/layout/conversation_outbox_tip_view.xml
index 8a1951f..61bb6f6 100644
--- a/res/layout/conversation_outbox_tip_view.xml
+++ b/res/layout/conversation_outbox_tip_view.xml
@@ -51,6 +51,8 @@
             android:scaleType="center"
             android:contentDescription="@string/dismiss_tip_hover_text"
             android:src="@drawable/ic_cancel_holo_light" />
+
+        <include layout="@layout/teaser_right_edge" />
     </LinearLayout>
 
 </com.android.mail.ui.ConversationsInOutboxTipView>
diff --git a/res/layout/conversation_photo_teaser_view.xml b/res/layout/conversation_photo_teaser_view.xml
index 86eac00..607c31d 100644
--- a/res/layout/conversation_photo_teaser_view.xml
+++ b/res/layout/conversation_photo_teaser_view.xml
@@ -60,6 +60,8 @@
             android:scaleType="center"
             android:contentDescription="@string/dismiss_tip_hover_text"
             android:src="@drawable/ic_cancel_holo_light" />
+
+        <include layout="@layout/teaser_right_edge" />
     </LinearLayout>
 
 </com.android.mail.ui.ConversationPhotoTeaserView>
diff --git a/res/layout/conversation_sync_disabled_tip_view.xml b/res/layout/conversation_sync_disabled_tip_view.xml
index 339c1ec..a361f1a 100644
--- a/res/layout/conversation_sync_disabled_tip_view.xml
+++ b/res/layout/conversation_sync_disabled_tip_view.xml
@@ -64,6 +64,8 @@
             android:scaleType="center"
             android:contentDescription="@string/dismiss_tip_hover_text"
             android:src="@drawable/ic_cancel_holo_light" />
+
+        <include layout="@layout/teaser_right_edge" />
     </LinearLayout>
 
 </com.android.mail.ui.ConversationSyncDisabledTipView>
diff --git a/res/layout/nested_folder.xml b/res/layout/nested_folder.xml
index d93765b..10ffb92 100644
--- a/res/layout/nested_folder.xml
+++ b/res/layout/nested_folder.xml
@@ -25,11 +25,11 @@
 
     <!--This is a rough layout. We don't have UX specs yet, so all the values are hardcoded.
         Also, it looks totally ugly. The ugliness is intentional.-->
-    <RelativeLayout
+    <LinearLayout
             android:id="@+id/swipeable_content"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center_vertical"
+            android:layout_height="match_parent"
+            android:orientation="horizontal"
             >
 
         <ImageView
@@ -38,31 +38,32 @@
                 android:layout_width="wrap_content"
                 android:layout_marginLeft="16dp"
                 android:layout_marginRight="16dp"
+                android:layout_gravity="center_vertical"
                 android:src="@drawable/ic_menu_folders_holo_light"
-                android:layout_alignParentLeft="true"
                 android:contentDescription="@string/folder_icon_desc"
-                android:layout_centerVertical="true"
                 />
         <TextView
-                android:layout_width="wrap_content"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:layout_gravity="center_vertical"
                 android:id="@+id/nested_folder_name"
                 android:includeFontPadding="false"
                 android:maxLines="2"
                 android:ellipsize="end"
                 android:textColor="@color/folder_item_text_color"
                 android:textAppearance="?android:attr/textAppearanceMedium"
-                android:layout_centerVertical="true"
-                android:layout_height="match_parent"
-                android:layout_toRightOf="@id/nested_folder_icon" />
+                />
 
         <TextView
                 android:layout_width="wrap_content"
                 android:layout_height="match_parent"
+                android:layout_gravity="center_vertical"
                 android:id="@+id/nested_folder_unread"
                 style="@style/UnreadCount"
-                android:layout_alignBaseline="@id/nested_folder_name"
-                android:layout_alignParentRight="true"
                 android:layout_marginRight="16dp"
                 />
-    </RelativeLayout>
+
+        <include layout="@layout/teaser_right_edge" />
+    </LinearLayout>
 </com.android.mail.ui.NestedFolderView>
\ No newline at end of file
diff --git a/res/layout/teaser_right_edge.xml b/res/layout/teaser_right_edge.xml
new file mode 100644
index 0000000..c3c0270
--- /dev/null
+++ b/res/layout/teaser_right_edge.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2013 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.
+-->
+<!-- This is used to show the line on the right edge of a list item in tablet ui -->
+<ImageView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/teaser_right_edge"
+    android:layout_width="wrap_content"
+    android:layout_height="match_parent"
+    android:src="@drawable/list_edge_tablet"/>
diff --git a/src/com/android/mail/browse/ConversationItemView.java b/src/com/android/mail/browse/ConversationItemView.java
index 240d506..b316bf0 100644
--- a/src/com/android/mail/browse/ConversationItemView.java
+++ b/src/com/android/mail/browse/ConversationItemView.java
@@ -1486,9 +1486,8 @@
         }
 
         // right-side edge effect when in tablet conversation mode and the list is not collapsed
-        if (mTabletDevice && !mListCollapsible &&
-                (ViewMode.isConversationMode(mConfig.getViewMode())
-                        || ViewMode.isAdMode(mConfig.getViewMode()))) {
+        if (Utils.getDisplayListRightEdgeEffect(mTabletDevice, mListCollapsible,
+                mConfig.getViewMode())) {
             RIGHT_EDGE_TABLET.setBounds(getWidth() - RIGHT_EDGE_TABLET.getIntrinsicWidth(), 0,
                     getWidth(), getHeight());
             RIGHT_EDGE_TABLET.draw(canvas);
diff --git a/src/com/android/mail/ui/AbstractActivityController.java b/src/com/android/mail/ui/AbstractActivityController.java
index edc1e33..332170c 100644
--- a/src/com/android/mail/ui/AbstractActivityController.java
+++ b/src/com/android/mail/ui/AbstractActivityController.java
@@ -2098,6 +2098,12 @@
                     ? DrawerLayout.LOCK_MODE_UNLOCKED : DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
             closeDrawerIfOpen();
         }
+
+        // Teasers and other items may need to change
+        final ConversationListFragment conversationListFragment = getConversationListFragment();
+        if (conversationListFragment != null) {
+            conversationListFragment.requestListRefresh();
+        }
     }
 
     /**
diff --git a/src/com/android/mail/ui/AnimatedAdapter.java b/src/com/android/mail/ui/AnimatedAdapter.java
index 634b645..7b9adee 100644
--- a/src/com/android/mail/ui/AnimatedAdapter.java
+++ b/src/com/android/mail/ui/AnimatedAdapter.java
@@ -499,7 +499,7 @@
         // Check if this is a special view
         final ConversationSpecialItemView specialView = mSpecialViews.get(position);
         if (specialView != null) {
-            specialView.onGetView();
+            specialView.onGetView(mActivity.getViewMode().getMode());
             return (View) specialView;
         }
 
diff --git a/src/com/android/mail/ui/ConversationLongPressTipView.java b/src/com/android/mail/ui/ConversationLongPressTipView.java
index ee7d67c..8c82b45 100644
--- a/src/com/android/mail/ui/ConversationLongPressTipView.java
+++ b/src/com/android/mail/ui/ConversationLongPressTipView.java
@@ -21,6 +21,7 @@
 import com.android.mail.browse.ConversationCursor;
 import com.android.mail.preferences.MailPrefs;
 import com.android.mail.providers.Folder;
+import com.android.mail.utils.Utils;
 
 import android.animation.Animator;
 import android.animation.ObjectAnimator;
@@ -52,6 +53,12 @@
     private boolean mShow;
     private int mAnimatedHeight = -1;
 
+    private View mTeaserRightEdge;
+    /** Whether we are on a tablet device or not */
+    private final boolean mTabletDevice;
+    /** When in conversation mode, true if the list is hidden */
+    private final boolean mListCollapsible;
+
     public ConversationLongPressTipView(final Context context) {
         this(context, null);
     }
@@ -73,6 +80,9 @@
         }
 
         mMailPrefs = MailPrefs.get(context);
+
+        mTabletDevice = Utils.useTabletUI(resources);
+        mListCollapsible = resources.getBoolean(R.bool.list_collapsible);
     }
 
     @Override
@@ -85,6 +95,8 @@
                 dismiss();
             }
         });
+
+        mTeaserRightEdge = findViewById(R.id.teaser_right_edge);
     }
 
     @Override
@@ -95,8 +107,12 @@
     }
 
     @Override
-    public void onGetView() {
-        // Do nothing
+    public void onGetView(final int viewMode) {
+        if (Utils.getDisplayListRightEdgeEffect(mTabletDevice, mListCollapsible, viewMode)) {
+            mTeaserRightEdge.setVisibility(VISIBLE);
+        } else {
+            mTeaserRightEdge.setVisibility(GONE);
+        }
     }
 
     @Override
diff --git a/src/com/android/mail/ui/ConversationPhotoTeaserView.java b/src/com/android/mail/ui/ConversationPhotoTeaserView.java
index c358028..30dc8c9 100644
--- a/src/com/android/mail/ui/ConversationPhotoTeaserView.java
+++ b/src/com/android/mail/ui/ConversationPhotoTeaserView.java
@@ -19,6 +19,7 @@
 import com.android.mail.browse.ConversationCursor;
 import com.android.mail.preferences.MailPrefs;
 import com.android.mail.providers.Folder;
+import com.android.mail.utils.Utils;
 
 /**
  * A teaser to introduce people to the contact photo check boxes
@@ -38,6 +39,12 @@
     private boolean mNeedLayout;
     private int mTextTop;
 
+    private View mTeaserRightEdge;
+    /** Whether we are on a tablet device or not */
+    private final boolean mTabletDevice;
+    /** When in conversation mode, true if the list is hidden */
+    private final boolean mListCollapsible;
+
     public ConversationPhotoTeaserView(final Context context) {
         this(context, null);
     }
@@ -63,6 +70,9 @@
         mMailPrefs = MailPrefs.get(context);
 
         mNeedLayout = true;
+
+        mTabletDevice = Utils.useTabletUI(resources);
+        mListCollapsible = resources.getBoolean(R.bool.list_collapsible);
     }
 
     @Override
@@ -75,6 +85,8 @@
                 dismiss();
             }
         });
+
+        mTeaserRightEdge = findViewById(R.id.teaser_right_edge);
     }
 
     @Override
@@ -113,8 +125,12 @@
     }
 
     @Override
-    public void onGetView() {
-        // Do nothing
+    public void onGetView(final int viewMode) {
+        if (Utils.getDisplayListRightEdgeEffect(mTabletDevice, mListCollapsible, viewMode)) {
+            mTeaserRightEdge.setVisibility(VISIBLE);
+        } else {
+            mTeaserRightEdge.setVisibility(GONE);
+        }
     }
 
     @Override
diff --git a/src/com/android/mail/ui/ConversationSpecialItemView.java b/src/com/android/mail/ui/ConversationSpecialItemView.java
index 92fc7ac..db9062a 100644
--- a/src/com/android/mail/ui/ConversationSpecialItemView.java
+++ b/src/com/android/mail/ui/ConversationSpecialItemView.java
@@ -38,7 +38,7 @@
      * Called before returning this view from
      * {@link Adapter#getView(int, android.view.View, android.view.ViewGroup)}
      */
-    void onGetView();
+    void onGetView(int viewMode);
 
     /**
      * Returns whether this view is to be displayed in the list or not. A view can be added freely
diff --git a/src/com/android/mail/ui/ConversationSyncDisabledTipView.java b/src/com/android/mail/ui/ConversationSyncDisabledTipView.java
index 1203e4e..b0090d6 100644
--- a/src/com/android/mail/ui/ConversationSyncDisabledTipView.java
+++ b/src/com/android/mail/ui/ConversationSyncDisabledTipView.java
@@ -74,6 +74,12 @@
 
     private int mReasonSyncOff = ReasonSyncOff.NONE;
 
+    private View mTeaserRightEdge;
+    /** Whether we are on a tablet device or not */
+    private final boolean mTabletDevice;
+    /** When in conversation mode, true if the list is hidden */
+    private final boolean mListCollapsible;
+
     public interface ReasonSyncOff {
         // Background sync is enabled for current account, do not display this tip
         public static final int NONE = 0;
@@ -133,6 +139,9 @@
                 index,
                 index + subString.length(),
                 0);
+
+        mTabletDevice = Utils.useTabletUI(resources);
+        mListCollapsible = resources.getBoolean(R.bool.list_collapsible);
     }
 
     public void bindAccount(Account account) {
@@ -141,8 +150,12 @@
     }
 
     @Override
-    public void onGetView() {
-        // Do nothing
+    public void onGetView(final int viewMode) {
+        if (Utils.getDisplayListRightEdgeEffect(mTabletDevice, mListCollapsible, viewMode)) {
+            mTeaserRightEdge.setVisibility(VISIBLE);
+        } else {
+            mTeaserRightEdge.setVisibility(GONE);
+        }
     }
 
     @Override
@@ -159,6 +172,8 @@
                 dismiss();
             }
         });
+
+        mTeaserRightEdge = findViewById(R.id.teaser_right_edge);
     }
 
     @Override
diff --git a/src/com/android/mail/ui/ConversationsInOutboxTipView.java b/src/com/android/mail/ui/ConversationsInOutboxTipView.java
index fb492c1..94c1b35 100644
--- a/src/com/android/mail/ui/ConversationsInOutboxTipView.java
+++ b/src/com/android/mail/ui/ConversationsInOutboxTipView.java
@@ -41,6 +41,7 @@
 import com.android.mail.providers.Account;
 import com.android.mail.providers.Folder;
 import com.android.mail.providers.UIProvider;
+import com.android.mail.utils.Utils;
 
 /**
  * Tip that is displayed in conversation list of 'Sent' folder whenever there are
@@ -65,6 +66,12 @@
 
     private int mAnimatedHeight = -1;
 
+    private View mTeaserRightEdge;
+    /** Whether we are on a tablet device or not */
+    private final boolean mTabletDevice;
+    /** When in conversation mode, true if the list is hidden */
+    private final boolean mListCollapsible;
+
     private static final int LOADER_FOLDER_LIST =
             AbstractActivityController.LAST_FRAGMENT_LOADER_ID + 100;
 
@@ -87,6 +94,9 @@
             sShrinkAnimationDuration = resources.getInteger(
                     R.integer.shrink_animation_duration);
         }
+
+        mTabletDevice = Utils.useTabletUI(resources);
+        mListCollapsible = resources.getBoolean(R.bool.list_collapsible);
     }
 
     public void bind(final Account account, final FolderSelector folderSelector) {
@@ -96,8 +106,12 @@
     }
 
     @Override
-    public void onGetView() {
-        // Do nothing
+    public void onGetView(final int viewMode) {
+        if (Utils.getDisplayListRightEdgeEffect(mTabletDevice, mListCollapsible, viewMode)) {
+            mTeaserRightEdge.setVisibility(VISIBLE);
+        } else {
+            mTeaserRightEdge.setVisibility(GONE);
+        }
     }
 
     @Override
@@ -119,6 +133,8 @@
                 dismiss();
             }
         });
+
+        mTeaserRightEdge = findViewById(R.id.teaser_right_edge);
     }
 
     private void goToOutbox() {
diff --git a/src/com/android/mail/ui/NestedFolderView.java b/src/com/android/mail/ui/NestedFolderView.java
index 856179a..30c1b89 100644
--- a/src/com/android/mail/ui/NestedFolderView.java
+++ b/src/com/android/mail/ui/NestedFolderView.java
@@ -19,6 +19,7 @@
 
 import android.app.LoaderManager;
 import android.content.Context;
+import android.content.res.Resources;
 import android.util.AttributeSet;
 import android.view.View;
 import android.widget.LinearLayout;
@@ -29,6 +30,7 @@
 import com.android.mail.providers.Folder;
 import com.android.mail.utils.LogTag;
 import com.android.mail.utils.LogUtils;
+import com.android.mail.utils.Utils;
 
 /**
  * For folders that might contain other folders, we show the nested folders within this view.
@@ -45,22 +47,34 @@
     /** The folder this view represents */
     private Folder mFolder;
 
+    private View mTeaserRightEdge;
+    /** Whether we are on a tablet device or not */
+    private final boolean mTabletDevice;
+    /** When in conversation mode, true if the list is hidden */
+    private final boolean mListCollapsible;
+
     public NestedFolderView(Context context) {
-        super(context);
+        this(context, null);
     }
 
     public NestedFolderView(Context context, AttributeSet attrs) {
-        super(context, attrs);
+        this(context, attrs, 0);
     }
 
     public NestedFolderView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
+
+        final Resources resources = context.getResources();
+        mTabletDevice = Utils.useTabletUI(resources);
+        mListCollapsible = resources.getBoolean(R.bool.list_collapsible);
     }
 
     @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
         mSwipeableContent = findViewById(R.id.swipeable_content);
+
+        mTeaserRightEdge = findViewById(R.id.teaser_right_edge);
     }
 
     @Override
@@ -71,8 +85,12 @@
     }
 
     @Override
-    public void onGetView() {
-        // Do nothing
+    public void onGetView(final int viewMode) {
+        if (Utils.getDisplayListRightEdgeEffect(mTabletDevice, mListCollapsible, viewMode)) {
+            mTeaserRightEdge.setVisibility(VISIBLE);
+        } else {
+            mTeaserRightEdge.setVisibility(GONE);
+        }
     }
 
     /**
diff --git a/src/com/android/mail/utils/Utils.java b/src/com/android/mail/utils/Utils.java
index a992dad..fd7ffec 100644
--- a/src/com/android/mail/utils/Utils.java
+++ b/src/com/android/mail/utils/Utils.java
@@ -71,6 +71,7 @@
 import com.android.mail.providers.UIProvider;
 import com.android.mail.providers.UIProvider.EditSettingsExtras;
 import com.android.mail.ui.FeedbackEnabledActivity;
+import com.android.mail.ui.ViewMode;
 
 import org.json.JSONObject;
 
@@ -545,6 +546,15 @@
     }
 
     /**
+     * @return <code>true</code> if the right edge effect should be displayed on list items
+     */
+    public static boolean getDisplayListRightEdgeEffect(final boolean tabletDevice,
+            final boolean listCollapsible, final int viewMode) {
+        return tabletDevice && !listCollapsible
+                && (ViewMode.isConversationMode(viewMode) || ViewMode.isAdMode(viewMode));
+    }
+
+    /**
      * Returns a boolean indicating whether or not we should animate in the
      * folder list fragment.
      */