Show Conversation Lists

Change-Id: Ia4356aaa5ee698cad6f648b9d26a5719ba8076ba
diff --git a/res/layout-sw600dp/account_switch_spinner_item.xml b/res/layout-sw600dp/account_switch_spinner_item.xml
index 8a03f33..62acd23 100644
--- a/res/layout-sw600dp/account_switch_spinner_item.xml
+++ b/res/layout-sw600dp/account_switch_spinner_item.xml
@@ -16,43 +16,50 @@
      limitations under the License.
 -->
 
-<RelativeLayout
+<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     style="@style/AccountSwitchSpinnerItem"
     android:layout_height="match_parent"
+    android:layout_width="match_parent"
     android:paddingLeft="0dip"
     android:layout_marginLeft="0dip">
 
+    <!-- This spacer is here just to soak up horizontal space. -->
+    <!-- If this is omitted, the spinner triangle is too far from the text. -->
+    <FrameLayout
+        android:id="@+id/spinner_frame"
+        android:layout_width="@dimen/spinner_frame_width"
+        android:layout_height="match_parent"
+        android:layout_alignParentLeft="true">
+
         <LinearLayout
             android:id="@+id/spinner"
             style="?android:attr/actionDropDownStyle"
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:orientation="vertical"
             android:gravity="center_vertical">
             <TextView
-                android:id="@+id/label"
+                android:id="@+id/account_spinner_label"
                 style="@style/AccountSpinnerAnchorTextPrimary"
                 android:singleLine="true"
                 android:ellipsize="end"
-                android:includeFontPadding="false"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content" />
             <TextView
-                android:id="@+id/name"
+                android:id="@+id/account_spinner_account_name"
                 style="@style/AccountSpinnerAnchorTextSecondary"
                 android:singleLine="true"
                 android:ellipsize="end"
-                android:includeFontPadding="false"
                 android:layout_marginRight="4dp"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content" />
         </LinearLayout>
 
+    </FrameLayout>
+
     <TextView
         android:id="@+id/unread"
-        android:layout_marginLeft="24dp"
-        style="@style/UnreadCountActionBar" />
-        android:layout_toRightOf="@id/spinner_frame" />
+        style="@style/unreadCountActionBarTablet" />
 
-</RelativeLayout>
+</LinearLayout>
diff --git a/res/values-sw600dp-port-v14/styles.xml b/res/values-sw600dp-port-v14/styles.xml
new file mode 100644
index 0000000..338b028
--- /dev/null
+++ b/res/values-sw600dp-port-v14/styles.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2012 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.
+-->
+<resources>
+    <style name="unreadCountActionBarTablet" parent="@style/UnreadCountActionBar">
+        <item name="android:layout_marginLeft">12dp</item>
+        <item name="android:layout_width">wrap_content</item>
+    </style>
+</resources>
diff --git a/res/values-sw600dp-port/styles.xml b/res/values-sw600dp-port/styles.xml
new file mode 100644
index 0000000..af21f63
--- /dev/null
+++ b/res/values-sw600dp-port/styles.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2012 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.
+-->
+<resources>
+    <style name="unreadCountActionBarTablet" parent="@style/UnreadCountActionBar">
+        <item name="android:layout_width">0dip</item>
+        <item name="android:layout_marginLeft">0dip</item>
+    </style>
+</resources>
diff --git a/res/values-sw600dp/dimen.xml b/res/values-sw600dp/dimen.xml
index afec463..b0378cf 100644
--- a/res/values-sw600dp/dimen.xml
+++ b/res/values-sw600dp/dimen.xml
@@ -24,4 +24,5 @@
     <dimen name="max_total_label_width_wide">128dip</dimen>
     <dimen name="wide_subject_margin_right">28dip</dimen>
     <dimen name="subject_width">238dip</dimen>
+    <dimen name="spinner_frame_width">180dp</dimen>
 </resources>
diff --git a/res/values-sw600dp/styles.xml b/res/values-sw600dp/styles.xml
deleted file mode 100644
index 19b48b3..0000000
--- a/res/values-sw600dp/styles.xml
+++ /dev/null
@@ -1,130 +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.
--->
-<resources>
-
-    <!-- Compose styles -->
-    <style name="RecipientEditTextViewStyle" parent="@style/RecipientEditTextView">
-        <item name="android:minHeight">42dip</item>
-        <item name="android:gravity">bottom</item>
-    </style>
-
-    <style name="ComposeEditTextView">
-        <item name="android:minHeight">44dip</item>
-        <item name="android:layout_gravity">center_vertical</item>
-        <item name="android:layout_height">wrap_content</item>
-        <item name="android:layout_width">match_parent</item>
-        <item name="android:background">@null</item>
-    </style>
-
-    <style name="ComposeBodyStyle">
-        <item name="android:layout_height">wrap_content</item>
-        <item name="android:layout_width">match_parent</item>
-        <item name="android:gravity">center_vertical</item>
-        <item name="android:layout_gravity">center_vertical</item>
-        <item name="android:inputType">textLongMessage|textMultiLine|textAutoCorrect|textCapSentences</item>
-        <item name="android:imeOptions">flagNoExtractUi|actionDone|flagNoEnterAction</item>
-        <item name="android:textColorHint">@color/compose_label_text</item>
-        <item name="android:background">@null</item>
-        <item name="android:minHeight">42dip</item>
-    </style>
-
-    <style name="RecipientComposeFieldSpacer">
-        <item name="android:layout_width">match_parent</item>
-        <item name="android:layout_height">4dip</item>
-    </style>
-
-    <style name="ComposeHeading">
-        <item name="android:layout_width">wrap_content</item>
-        <item name="android:layout_height">wrap_content</item>
-        <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
-        <item name="android:textColor">@color/compose_label_text</item>
-        <item name="android:layout_gravity">center_vertical</item>
-    </style>
-
-    <style name="RecipientComposeHeading" parent="@style/ComposeHeading">
-        <item name="android:layout_marginRight">4dip</item>
-        <item name="android:layout_marginTop">4dip</item>
-        <item name="android:paddingLeft">0dip</item>
-        <item name="android:layout_marginLeft">0dip</item>
-    </style>
-
-    <style name="ComposeFieldLayout" parent="android:Widget.Holo.Light.EditText">
-        <item name="android:layout_height">wrap_content</item>
-        <item name="android:layout_width">match_parent</item>
-        <item name="android:addStatesFromChildren">true</item>
-        <item name="android:focusable">false</item>
-        <item name="android:focusableInTouchMode">false</item>
-        <item name="android:gravity">center_vertical</item>
-        <item name="android:paddingTop">0dip</item>
-    </style>
-
-    <style name="RecipientComposeFieldLayout" parent="@style/ComposeFieldLayout">
-        <item name="android:orientation">vertical</item>
-    </style>
-    <!-- End compose styles -->
-
-    <style name="AccountSwitchSpinnerItem">
-        <item name="android:layout_width">332dip</item>
-    </style>
-
-    <style name="AccountSpinnerAnchorTextPrimary" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title"></style>
-
-    <!-- Browse list item styles -->
-    <style name="PersonalIndicatorStyle">
-        <item name="android:layout_width">wrap_content</item>
-        <item name="android:layout_height">wrap_content</item>
-        <item name="android:layout_marginLeft">8dip</item>
-        <item name="android:layout_marginTop">1sp</item>
-    </style>
-
-    <style name="SendersStyle">
-        <item name="android:layout_marginLeft">8dip</item>
-        <item name="android:layout_marginTop">10sp</item>
-    </style>
-
-    <style name="SubjectStyle">
-        <item name="android:layout_marginLeft">8dip</item>
-        <item name="android:layout_marginTop">-6sp</item>
-        <item name="android:layout_weight">1</item>
-        <item name="android:textColor">@color/subject_text_color</item>
-        <item name="android:textSize">14sp</item>
-        <item name="android:layout_height">wrap_content</item>
-        <item name="android:lines">2</item>
-        <item name="android:layout_width">0dip</item>
-    </style>
-
-    <style name="CheckmarkStyle">
-        <item name="android:layout_marginTop">-6sp</item>
-        <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="ConversationListFade" parent="@android:attr/listViewWhiteStyle">
-        <item name="android:cacheColorHint">@android:color/transparent</item>
-    </style>
-
-    <style name="StarStyle">
-        <item name="android:layout_marginRight">12dip</item>
-        <item name="android:layout_marginTop">-6sp</item>
-        <item name="android:layout_width">wrap_content</item>
-        <item name="android:layout_height">wrap_content</item>
-    </style>
-    <!-- End browse list item styles -->
-
-</resources>
\ No newline at end of file
diff --git a/res/values-sw720dp/styles.xml b/res/values-sw720dp/styles.xml
new file mode 100644
index 0000000..fbec80e
--- /dev/null
+++ b/res/values-sw720dp/styles.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2012 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.
+-->
+<resources>
+    <style name="unreadCountActionBarTablet" parent="@style/UnreadCountActionBar">
+        <item name="android:layout_marginLeft">16dp</item>
+        <item name="android:layout_width">wrap_content</item>
+    </style>
+</resources>
diff --git a/res/values/dimen.xml b/res/values/dimen.xml
index c111478..bc6c497 100644
--- a/res/values/dimen.xml
+++ b/res/values/dimen.xml
@@ -59,5 +59,5 @@
     <dimen name="contact_photo_height">48sp</dimen>
     <dimen name="message_header_inner_side_padding">8dip</dimen>
     <dimen name="attachment_toast_yoffset">-100dip</dimen>
-
-</resources>
\ No newline at end of file
+    <dimen name="spinner_frame_width">168dip</dimen>
+</resources>
diff --git a/src/com/android/mail/ConversationListContext.java b/src/com/android/mail/ConversationListContext.java
index ce5e927..4f9e407 100644
--- a/src/com/android/mail/ConversationListContext.java
+++ b/src/com/android/mail/ConversationListContext.java
@@ -48,16 +48,15 @@
     /**
      * The account for whom we are showing a list
      */
-    private final Account mAccount;
+    public final Account mAccount;
     /**
      * The folder whose conversations we are displaying, if any.
      */
-    private final String mFolderName;
-
+    public final String mFolderName;
     /**
      * The search query whose results we are displaying, if any.
      */
-    private final String mSearchQuery;
+    public final String mSearchQuery;
 
     // Tokenized search terms for search queries.
     private ArrayList<String> mSearchTerms;
diff --git a/src/com/android/mail/ui/AbstractActivityController.java b/src/com/android/mail/ui/AbstractActivityController.java
index b8af88b..35b5b6a 100644
--- a/src/com/android/mail/ui/AbstractActivityController.java
+++ b/src/com/android/mail/ui/AbstractActivityController.java
@@ -22,9 +22,13 @@
 import android.app.ActionBar.LayoutParams;
 import android.app.Activity;
 import android.app.Dialog;
+import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
 import android.os.Bundle;
+import android.util.Log;
 import android.view.ActionMode;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
@@ -37,7 +41,9 @@
 import com.android.mail.R;
 import com.android.mail.ConversationListContext;
 import com.android.mail.providers.Account;
+import com.android.mail.providers.AccountCacheProvider;
 import com.android.mail.providers.Folder;
+import com.android.mail.providers.UIProvider;
 import com.android.mail.utils.Utils;
 
 /**
@@ -72,7 +78,7 @@
      */
     private ConversationSelectionSet mBatchConversations = new ConversationSelectionSet();
     protected final Context mContext;
-    protected ConversationListContext mConversationListContext;
+    protected ConversationListContext mConvListContext;
 
     protected ConversationListFragment mConversationListFragment;
     /**
@@ -81,6 +87,7 @@
      * of view mode changes.
      */
     protected final ViewMode mViewMode;
+    protected ContentResolver mResolver;
 
     public AbstractActivityController(MailActivity activity, ViewMode viewMode) {
         mActivity = activity;
@@ -261,8 +268,7 @@
 
         // Allow shortcut keys to function for the ActionBar and menus.
         mActivity.setDefaultKeyMode(Activity.DEFAULT_KEYS_SHORTCUT);
-        final Context context = mActivity.getApplicationContext();
-
+        mResolver = mActivity.getContentResolver();
         mViewMode.addListener(this);
         restoreState(savedState);
         return true;
@@ -333,8 +339,8 @@
 
     @Override
     public void onSaveInstanceState(Bundle outState) {
-        if (mConversationListContext != null) {
-            outState.putBundle(SAVED_LIST_CONTEXT, mConversationListContext.toBundle());
+        if (mConvListContext != null) {
+            outState.putBundle(SAVED_LIST_CONTEXT, mConvListContext.toBundle());
         }
     }
 
@@ -427,7 +433,7 @@
         // TODO(viki): Auto-generated method stub
         Bundle listContextBundle = savedState.getBundle(SAVED_LIST_CONTEXT);
         if (listContextBundle != null) {
-            mConversationListContext = ConversationListContext.forBundle(listContextBundle);
+            mConvListContext = ConversationListContext.forBundle(listContextBundle);
         }
     }
 
@@ -467,14 +473,24 @@
             // Restore the view mode
             mViewMode.handleRestore(savedState);
         } else {
+            // Null saved state. We have to initialize the activity to a sane first state
+
+            // Set the account. Use the first account for want of anything better.
+            // TODO(viki): Use a cursor loader here to notice changes to the underlying data.
+            final Cursor accountCursor = mResolver.query(AccountCacheProvider.getAccountsUri(),
+                    UIProvider.ACCOUNTS_PROJECTION, null, null, null);
+            if (accountCursor != null && accountCursor.moveToFirst()) {
+                final int uriCol = accountCursor.getColumnIndex(
+                        UIProvider.AccountColumns.FOLDER_LIST_URI);
+                mAccount = new Account(accountCursor);
+            }
+
             final Intent intent = mActivity.getIntent();
             //  TODO(viki): Show the list context from Intent
-            mConversationListContext = ConversationListContext.forIntent(
-                    mContext, mAccount, intent);
+            mConvListContext = ConversationListContext.forIntent(mContext, mAccount, intent);
             // Instead of this, switch to the conversation list mode and have that do the right
             // things automatically.
-            // showConversationList(ConversationListContext.forIntent(mContext, mAccount, intent));
-
+            showConversationList(mConvListContext);
             mViewMode.enterConversationListMode();
         }
 
diff --git a/src/com/android/mail/ui/ConversationListFragment.java b/src/com/android/mail/ui/ConversationListFragment.java
index 0173ad5..de5dad7 100644
--- a/src/com/android/mail/ui/ConversationListFragment.java
+++ b/src/com/android/mail/ui/ConversationListFragment.java
@@ -17,13 +17,18 @@
 
 package com.android.mail.ui;
 
+import android.animation.Animator;
 import android.animation.Animator.AnimatorListener;
 import android.app.Activity;
 import android.app.ListFragment;
+import android.content.ContentResolver;
 import android.content.res.Resources;
+import android.database.Cursor;
+import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Parcelable;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
@@ -36,7 +41,11 @@
 
 import com.android.mail.R;
 import com.android.mail.ConversationListContext;
+import com.android.mail.browse.ConversationCursor;
 import com.android.mail.browse.ConversationItemView.StarHandler;
+import com.android.mail.providers.Account;
+import com.android.mail.providers.AccountCacheProvider;
+import com.android.mail.providers.UIProvider;
 import com.android.mail.ui.ViewMode.ModeChangeListener;
 import com.android.mail.utils.LogUtils;
 import com.android.mail.utils.Utils;
@@ -47,7 +56,7 @@
 public final class ConversationListFragment extends ListFragment
         implements ConversationSetObserver,
         OnItemLongClickListener,
-        ModeChangeListener {
+        ModeChangeListener, UndoBarView.OnUndoCancelListener {
     // Keys used to pass data to {@link ConversationListFragment}.
     private static final String CONVERSATION_LIST_KEY = "conversation-list";
 
@@ -65,19 +74,39 @@
      */
     private static int TIMESTAMP_UPDATE_INTERVAL = 0;
 
-    private ControllableActivity mActivity;
+    private static final AnimatorListener UNDO_HIDE_ANIMATOR_LISTENER = new AnimatorListener() {
+        @Override
+        public void onAnimationCancel(Animator animation) {
+            // Do nothing.
+        }
+        @Override
+        public void onAnimationEnd(Animator animation) {
+            // Do nothing.
+        }
+        @Override
+        public void onAnimationRepeat(Animator animation) {
+            // Do nothing.
+        }
+        @Override
+        public void onAnimationStart(Animator animation) {
+            // Do nothing.
+        }
+    };
 
+    private ControllableActivity mActivity;
     private boolean mAnimateChanges;
+
     // Control state.
     private ConversationListCallbacks mCallbacks;
-
+    private ConversationCursor mConversationListCursor;
     private View mEmptyView;
+
     private final Handler mHandler = new Handler();
     // True if the view is in CAB (Contextual Action Bar: some conversations are selected) mode
     private boolean mIsCabMode;
-
     // List save state.
     private Parcelable mListSavedState;
+
     // The internal view objects.
     private ListView mListView;
     private int mPosition = ListView.INVALID_POSITION;
@@ -86,9 +115,23 @@
     private TextView mSearchStatusTextView;
 
     private View mSearchStatusView;
+
     private int mSelectedCursorPosition = mPosition;
 
-    private AnimatorListener mUndoHideListener;
+    /**
+     * Current Account being viewed
+     */
+    private String mAccount;
+    /**
+     * Current label/folder being viewed.
+     */
+    private String mFolder;
+    /**
+     * Object to deal with starring of messages.
+     */
+    private StarHandler mStarHandler;
+
+    private UndoBarView mUndoView;
 
     /**
      * A simple method to update the timestamps of conversations periodically.
@@ -96,12 +139,11 @@
     private Runnable mUpdateTimestampsRunnable = null;
 
     private ConversationListContext mViewContext;
+    private ContentResolver mResolver;
 
-    /**
-     * Object to deal with starring of messages.
-     */
-    private StarHandler mStarHandler;
+    private AnimatedAdapter mListAdapter;
 
+    private ConversationSelectionSet mBatchConversations = new ConversationSelectionSet();
     /**
      * Creates a new instance of {@link ConversationListFragment}, initialized to display
      * conversation list context.
@@ -115,21 +157,6 @@
     }
 
     /**
-     * Initializes all internal state for a rendering.
-     */
-    private void bindActivityInfo() {
-        mActivity.setViewModeListener(this);
-        mActivity.getBatchConversations().addObserver(this);
-
-        // TODO(mindyp): find some way to make the notification container more re-usable.
-        // TODO(viki): refactor according to comment in configureSearchResultHandler()
-        mSearchStatusView = mActivity.findViewById(R.id.search_status_view);
-        mSearchStatusTextView = (TextView) mActivity.findViewById(R.id.search_status_text_view);
-        mSearchResultCountTextView = (TextView) mActivity.findViewById(
-                R.id.search_result_count_view);
-    }
-
-    /**
      * Show the header if the current conversation list is showing search results.
      */
     private void configureSearchResultHeader() {
@@ -151,6 +178,31 @@
         mListView.setLayoutParams(layoutParams);
     }
 
+    /**
+     * Hides the control for an {@link UndoOperation}
+     * @param animate if true, hiding the undo view will be animated.
+     */
+    private void hideUndoView(boolean animate) {
+        if (mUndoView.isShown()) {
+            mUndoView.hide(animate);
+        }
+    }
+
+    /**
+     * Initializes all internal state for a rendering.
+     */
+    private void initializeUiForFirstDisplay() {
+        // TODO(mindyp): find some way to make the notification container more re-usable.
+        // TODO(viki): refactor according to comment in configureSearchResultHandler()
+        mSearchStatusView = mActivity.findViewById(R.id.search_status_view);
+        mSearchStatusTextView = (TextView) mActivity.findViewById(R.id.search_status_text_view);
+        mSearchResultCountTextView = (TextView) mActivity.findViewById(
+                R.id.search_result_count_view);
+        mUndoView = (UndoBarView) mActivity.findViewById(R.id.undo_view);
+        mUndoView.setOnCancelListener(this);
+        mUndoView.setUndoHideListener(UNDO_HIDE_ANIMATOR_LISTENER);
+    }
+
     private boolean isSearchResult() {
         return mViewContext != null && mViewContext.isSearchResult();
     }
@@ -160,13 +212,25 @@
         LogUtils.v(LOG_TAG, "onActivityCreated in ConversationListFragment(this=%s)",
                 this);
         super.onActivityCreated(savedInstanceState);
-        mActivity = (ControllableActivity) getActivity();
+        // Strictly speaking, we get back an android.app.Activity from getActivity. However, the
+        // only activity creating a ConversationListContext is a MailActivity which is of type
+        // ControllableActivity, so this cast should be safe. If this cast fails, some other
+        // activity is creating ConversationListFragments. This activity must be of type
+        // ControllableActivity.
+        final Activity activity = getActivity();
+        if (! (activity instanceof ControllableActivity)){
+            LogUtils.e(LOG_TAG, "ConversationListFragment expects only a ControllableActivity to" +
+                    "create it. Cannot proceed.");
+        }
+        mActivity = (ControllableActivity) activity;
         mCallbacks = mActivity.getListHandler();
         mStarHandler = mActivity.getStarHandler();
-
+        mActivity.getBatchConversations().addObserver(this);
+        mActivity.setViewModeListener(this);
         mActivity.attachConversationList(this);
         mTabletDevice = Utils.useTabletUI(mActivity.getApplicationContext());
-        bindActivityInfo();
+        mResolver = mActivity.getContentResolver();
+        initializeUiForFirstDisplay();
 
         // The onViewModeChanged callback doesn't get called when the mode object is created, so
         // force setting the mode manually this time around.
@@ -197,12 +261,13 @@
             }
         };
 
+        // Get the context from the arguments
         Bundle args = getArguments();
         mViewContext = ConversationListContext.forBundle(args.getBundle(CONVERSATION_LIST_KEY));
+
         if (savedInstanceState != null) {
             mListSavedState = savedInstanceState.getParcelable(LIST_STATE_KEY);
         }
-
         setRetainInstance(true);
     }
 
@@ -311,6 +376,11 @@
     }
 
     @Override
+    public void onUndoCancel() {
+        mUndoView.hide(false);
+    }
+
+    @Override
     public void onViewModeChanged(int newMode) {
         // Change the divider based on view mode.
         if (mTabletDevice) {
@@ -338,6 +408,39 @@
      * a label. This will initiate a data load, and hence must be called on the UI thread.
      */
     private void showList() {
+        mListView.setEmptyView(null);
+
+        // Get an account and a folder list
+        Uri foldersUri = Uri.parse(mViewContext.mAccount.folderListUri);
+        // TODO(viki) fill with real position
+        final int position = 0;
+        Account mSelectedAccount = mViewContext.mAccount;
+
+        Uri conversationListUri = null;
+        if (foldersUri != null) {
+            // TODO(viki): Look up the folder from the ConversationListContext rather than the first
+            // folder here.
+            Cursor cursor = mResolver.query(AccountCacheProvider.getAccountsUri(),
+                    UIProvider.ACCOUNTS_PROJECTION, null, null, null);
+            if (cursor != null) {
+                try {
+                    final int uriCol = cursor.getColumnIndex(
+                            UIProvider.FolderColumns.CONVERSATION_LIST_URI);
+                    cursor.moveToFirst();
+                    conversationListUri = Uri.parse(cursor.getString(uriCol));
+                } finally {
+                    cursor.close();
+                }
+            }
+        }
+        // Create the cursor for the list using the update cache
+        // Make this asynchronous
+        mConversationListCursor = ConversationCursor.create((Activity) mActivity, //f unsafe
+                UIProvider.ConversationColumns.URI, conversationListUri,
+                UIProvider.CONVERSATION_PROJECTION, null, null, null);
+        mListAdapter = new AnimatedAdapter(mActivity.getApplicationContext(), position,
+                mConversationListCursor, mBatchConversations, mSelectedAccount);
+        mListView.setAdapter(mListAdapter);
         configureSearchResultHeader();
     }
 
diff --git a/src/com/android/mail/ui/MailActionBar.java b/src/com/android/mail/ui/MailActionBar.java
index fe7cf70..cb73b79 100644
--- a/src/com/android/mail/ui/MailActionBar.java
+++ b/src/com/android/mail/ui/MailActionBar.java
@@ -174,7 +174,6 @@
         mActionBar = actionBar;
         mCallback = callback;
         mActivity = activity;
-
         mSpinnerView = (AccountRecentLabelSpinner) findViewById(R.id.account_spinner);
 
         // Set the mode to Navigation mode
@@ -250,7 +249,6 @@
         if (mActionBar == null) {
             return;
         }
-
         mActionBar.setDisplayOptions(
                 ActionBar.DISPLAY_SHOW_HOME,
                 ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
@@ -262,7 +260,6 @@
         if (mActionBar == null){
             return;
         }
-
         mActionBar.setDisplayOptions(
                 ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME,
                 ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
diff --git a/src/com/android/mail/ui/OnePaneController.java b/src/com/android/mail/ui/OnePaneController.java
index 005f047..6ee2b90 100644
--- a/src/com/android/mail/ui/OnePaneController.java
+++ b/src/com/android/mail/ui/OnePaneController.java
@@ -46,7 +46,7 @@
     @Override
     public void resetActionBarIcon() {
         final int mode = mViewMode.getMode();
-        if ((mode == ViewMode.CONVERSATION_LIST && mConversationListContext.isSearchResult())
+        if ((mode == ViewMode.CONVERSATION_LIST && mConvListContext.isSearchResult())
                 || mode == ViewMode.CONVERSATION || mode == ViewMode.FOLDER_LIST) {
             mActionBarView.setBackButton();
         } else {
@@ -97,8 +97,8 @@
                 FragmentTransaction.TRANSIT_FRAGMENT_OPEN;
         fragmentTransaction.setTransition(transition);
 
-        Fragment conversationListFragment = ConversationListFragment
-                .newInstance(mConversationListContext);
+        Fragment conversationListFragment = ConversationListFragment.newInstance(
+                mConvListContext);
         fragmentTransaction.replace(R.id.content_pane, conversationListFragment);
 
         fragmentTransaction.commitAllowingStateLoss();
diff --git a/src/com/android/mail/ui/TwoPaneController.java b/src/com/android/mail/ui/TwoPaneController.java
index 1874ed9..40068e4 100644
--- a/src/com/android/mail/ui/TwoPaneController.java
+++ b/src/com/android/mail/ui/TwoPaneController.java
@@ -57,7 +57,7 @@
         // Use cross fading animation.
         fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
         Fragment conversationListFragment = ConversationListFragment
-                .newInstance(mConversationListContext);
+                .newInstance(mConvListContext);
         fragmentTransaction.replace(R.id.conversation_list_pane, conversationListFragment);
         fragmentTransaction.commitAllowingStateLoss();
     }