Make sure view mode changes actually get to the conversation list fragment.

Set the background of the loading item properly depending in mode.

Fixes b/6409001 Shadow on left side of emails is not consistent. You see it only on email items but not on the "loading" message or empty section,

Change-Id: Ie0b15e6853665e4e5ece16a836f9a0fc1e114555
diff --git a/res/layout/loading_message.xml b/res/layout/loading_message.xml
index 4528513..a8ae942 100644
--- a/res/layout/loading_message.xml
+++ b/res/layout/loading_message.xml
@@ -21,7 +21,8 @@
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_gravity="center"
-    android:gravity="center">
+    android:gravity="center"
+    android:background="@drawable/conversation_unread_selector">
     <ProgressBar
         style="?android:attr/progressBarStyleSmall"
         android:layout_width="wrap_content"
diff --git a/src/com/android/mail/browse/ConversationListFooterView.java b/src/com/android/mail/browse/ConversationListFooterView.java
index 19d048e..ae52e2f 100644
--- a/src/com/android/mail/browse/ConversationListFooterView.java
+++ b/src/com/android/mail/browse/ConversationListFooterView.java
@@ -20,6 +20,7 @@
 import android.app.DialogFragment;
 import android.app.FragmentManager;
 import android.content.Context;
+import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
 import android.util.AttributeSet;
@@ -33,6 +34,7 @@
 import com.android.mail.providers.UIProvider;
 import com.android.mail.ui.AbstractActivityController;
 import com.android.mail.ui.AsyncRefreshTask;
+import com.android.mail.ui.ViewMode;
 import com.android.mail.utils.Utils;
 
 public class ConversationListFooterView extends LinearLayout implements View.OnClickListener {
@@ -46,9 +48,14 @@
     private Uri mLoadMoreUri;
     private int mErrorStatus;
     private FragmentManager mFragmentManager;
+    private boolean mTabletDevice;
+    // Backgrounds for different states.
+    private static Drawable sWideBackground;
+    private static Drawable sNormalBackground;
 
     public ConversationListFooterView(Context context, AttributeSet attrs) {
         super(context, attrs);
+        mTabletDevice = Utils.useTabletUI(context);
     }
 
     @Override
@@ -184,4 +191,35 @@
         }
         return showFooter;
     }
+
+    /**
+     * Update to the appropriate background when the view mode changes.
+     */
+    public void onViewModeChanged(int newMode) {
+        Drawable drawable;
+        if (mTabletDevice && newMode == ViewMode.CONVERSATION_LIST) {
+            drawable = getWideBackground();
+        } else {
+            drawable = getNormalBackground();
+        }
+        setBackgroundDrawable(drawable);
+    }
+
+    private Drawable getWideBackground() {
+        if (sWideBackground == null) {
+            sWideBackground = getBackground(R.drawable.conversation_wide_unread_selector);
+        }
+        return sWideBackground;
+    }
+
+    private Drawable getNormalBackground() {
+        if (sNormalBackground == null) {
+            sNormalBackground = getBackground(R.drawable.conversation_unread_selector);
+        }
+        return sNormalBackground;
+    }
+
+    private Drawable getBackground(int resId) {
+        return getContext().getResources().getDrawable(resId);
+    }
 }
diff --git a/src/com/android/mail/ui/ConversationListFragment.java b/src/com/android/mail/ui/ConversationListFragment.java
index 8a6d253..93a1ff7 100644
--- a/src/com/android/mail/ui/ConversationListFragment.java
+++ b/src/com/android/mail/ui/ConversationListFragment.java
@@ -248,6 +248,7 @@
         // The onViewModeChanged callback doesn't get called when the mode object is created, so
         // force setting the mode manually this time around.
         onViewModeChanged(mActivity.getViewMode().getMode());
+        mActivity.getViewMode().addListener(this);
 
         // Restore the list state
         if (mListSavedState != null) {
@@ -436,14 +437,19 @@
             if (newMode == ViewMode.CONVERSATION) {
                 mListView.setBackgroundResource(R.drawable.panel_conversation_leftstroke);
             } else if (newMode == ViewMode.CONVERSATION_LIST) {
-                // There are no selected conversations when in conversation list mode.
+                // There are no selected conversations when in conversation
+                // list mode.
                 mListView.clearChoices();
                 mListView.setBackgroundDrawable(null);
             }
         } else {
             mListView.setBackgroundDrawable(null);
         }
+        if (mFooterView != null) {
+            mFooterView.onViewModeChanged(newMode);
+        }
     }
+
     /**
      * Handles a request to show a new conversation list, either from a search query or for viewing
      * a folder. This will initiate a data load, and hence must be called on the UI thread.