Fix selection state. Don't recreate the folder list fragment each time the conv list is shown.

Change-Id: Ic0fc7bf00c55e1332de0fa6964844f80f9a52c8c
diff --git a/res/drawable-sw600dp/folder_item.xml b/res/drawable-sw600dp/folder_item.xml
new file mode 100644
index 0000000..7632b33
--- /dev/null
+++ b/res/drawable-sw600dp/folder_item.xml
@@ -0,0 +1,23 @@
+<?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.
+-->
+
+<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="@drawable/list_activated_holo" />
+    <item android:drawable="@android:color/transparent" />
+</selector>
diff --git a/src/com/android/mail/ui/TwoPaneController.java b/src/com/android/mail/ui/TwoPaneController.java
index f815c9a..6053b7a 100644
--- a/src/com/android/mail/ui/TwoPaneController.java
+++ b/src/com/android/mail/ui/TwoPaneController.java
@@ -19,6 +19,7 @@
 
 import com.android.mail.ConversationListContext;
 import com.android.mail.R;
+import com.android.mail.providers.Account;
 import com.android.mail.providers.Conversation;
 import com.android.mail.utils.LogUtils;
 
@@ -73,13 +74,16 @@
      * Render the folder list in the correct pane.
      */
     private void renderFolderList() {
-        Fragment folderListFragment = FolderListFragment.newInstance(this, mAccount.folderListUri);
+        FolderListFragment folderListFragment = FolderListFragment.newInstance(this,
+                mAccount.folderListUri);
         FragmentTransaction fragmentTransaction = mActivity.getFragmentManager().beginTransaction();
         fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
         fragmentTransaction.replace(R.id.folders_pane, folderListFragment);
         fragmentTransaction.commitAllowingStateLoss();
-        // Since we are showing the folder list, we are at the start of the view stack.
+        // Since we are showing the folder list, we are at the start of the view
+        // stack.
         resetActionBarIcon();
+        attachFolderList(folderListFragment);
     }
 
     @Override
@@ -91,7 +95,6 @@
     @Override
     public void showConversationList(ConversationListContext context) {
         initializeConversationListFragment(true);
-        renderFolderList();
     }
 
     @Override
@@ -114,12 +117,17 @@
         mViewMode.addListener(mLayout);
         // The activity controller needs to listen to layout changes.
         mLayout.setListener(this);
-
         final boolean isParentInitialized = super.onCreate(savedState);
         return isParentInitialized;
     }
 
     @Override
+    public void onAccountChanged(Account account) {
+        super.onAccountChanged(account);
+        renderFolderList();
+    }
+
+    @Override
     public void onViewModeChanged(int newMode) {
         super.onViewModeChanged(newMode);
         if (newMode != ViewMode.CONVERSATION) {