am f88e4087: Merge "Remove collapsed headers for tablet only" into jb-ub-mail-ur9

* commit 'f88e408767feba2fd4974d0dddafebc3964cea03':
  Remove collapsed headers for tablet only
diff --git a/src/com/android/mail/ui/FolderListFragment.java b/src/com/android/mail/ui/FolderListFragment.java
index 98adf19..d30b3f0 100644
--- a/src/com/android/mail/ui/FolderListFragment.java
+++ b/src/com/android/mail/ui/FolderListFragment.java
@@ -59,6 +59,8 @@
     private Uri mFolderListUri;
     /** True if you want a sectioned FolderList, false otherwise. */
     private boolean mIsSectioned;
+    /** Is the current device using tablet UI (true if 2-pane, false if 1-pane) */
+    private boolean mIsTabletUI;
     /** An {@link ArrayList} of {@link FolderType}s to exclude from displaying. */
     private ArrayList<Integer> mExcludedFolderTypes;
     /** Object that changes folders on our behalf. */
@@ -83,6 +85,8 @@
     private static final String ARG_FOLDER_URI = "arg-folder-list-uri";
     /** Key to store {@link #mIsSectioned} */
     private static final String ARG_IS_SECTIONED = "arg-is-sectioned";
+    /** Key to store {@link #mIsTabletUI} */
+    private static final String ARG_IS_TABLET_UI = "arg-is-tablet-ui";
     /** Key to store {@link #mExcludedFolderTypes} */
     private static final String ARG_EXCLUDED_FOLDER_TYPES = "arg-excluded-folder-types";
     /** Should the {@link FolderListFragment} show less labels to begin with? */
@@ -139,21 +143,24 @@
     /**
      * Creates a new instance of {@link ConversationListFragment}, initialized
      * to display conversation list context.
-     * @param isSectioned TODO(viki):
+     * @param isSectioned True if sections should be shown for folder list
+     * @param isTabletUI True if two-pane layout, false if not
      */
     public static FolderListFragment newInstance(Folder parentFolder, Uri folderUri,
-            boolean isSectioned) {
-        return newInstance(parentFolder, folderUri, isSectioned, null);
+            boolean isSectioned, boolean isTabletUI) {
+        return newInstance(parentFolder, folderUri, isSectioned, null, isTabletUI);
     }
 
     /**
      * Creates a new instance of {@link ConversationListFragment}, initialized
      * to display conversation list context.
-     * @param isSectioned TODO(viki):
+     * @param isSectioned True if sections should be shown for folder list
      * @param excludedFolderTypes A list of {@link FolderType}s to exclude from displaying
+     * @param isTabletUI True if two-pane layout, false if not
      */
     public static FolderListFragment newInstance(Folder parentFolder, Uri folderUri,
-            boolean isSectioned, final ArrayList<Integer> excludedFolderTypes) {
+            boolean isSectioned, final ArrayList<Integer> excludedFolderTypes,
+            boolean isTabletUI) {
         final FolderListFragment fragment = new FolderListFragment();
         final Bundle args = new Bundle();
         if (parentFolder != null) {
@@ -161,6 +168,7 @@
         }
         args.putString(ARG_FOLDER_URI, folderUri.toString());
         args.putBoolean(ARG_IS_SECTIONED, isSectioned);
+        args.putBoolean(ARG_IS_TABLET_UI, isTabletUI);
         if (excludedFolderTypes != null) {
             args.putIntegerArrayList(ARG_EXCLUDED_FOLDER_TYPES, excludedFolderTypes);
         }
@@ -225,8 +233,11 @@
             selectedFolder = mActivity.getHierarchyFolder();
         } else {
             // Initiate FLA with accounts and folders collapsed in the list
-            mCursorAdapter = new FolderListAdapter(mIsSectioned, ARE_ITEMS_COLLAPSED,
-                    ARE_ITEMS_COLLAPSED);
+            // The second param is for whether folders should be collapsed
+            // The third param is for whether accounts should be collapsed
+            mCursorAdapter = new FolderListAdapter(mIsSectioned,
+                    !mIsTabletUI && ARE_ITEMS_COLLAPSED,
+                    !mIsTabletUI && ARE_ITEMS_COLLAPSED);
             selectedFolder = controller == null ? null : controller.getFolder();
         }
         // Is the selected folder fresher than the one we have restored from a bundle?
@@ -245,6 +256,7 @@
         mFolderListUri = Uri.parse(args.getString(ARG_FOLDER_URI));
         mParentFolder = (Folder) args.getParcelable(ARG_PARENT_FOLDER);
         mIsSectioned = args.getBoolean(ARG_IS_SECTIONED);
+        mIsTabletUI = args.getBoolean(ARG_IS_TABLET_UI);
         mExcludedFolderTypes = args.getIntegerArrayList(ARG_EXCLUDED_FOLDER_TYPES);
         final View rootView = inflater.inflate(R.layout.folder_list, null);
         mListView = (ListView) rootView.findViewById(android.R.id.list);
diff --git a/src/com/android/mail/ui/FolderSelectionActivity.java b/src/com/android/mail/ui/FolderSelectionActivity.java
index e71981f..3bee9b0 100644
--- a/src/com/android/mail/ui/FolderSelectionActivity.java
+++ b/src/com/android/mail/ui/FolderSelectionActivity.java
@@ -110,7 +110,7 @@
     private void createFolderListFragment(Folder parent, Uri uri) {
         final FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
         final Fragment fragment = FolderListFragment.newInstance(parent, uri, false,
-                getExcludedFolderTypes());
+                getExcludedFolderTypes(), true);
         fragmentTransaction.replace(R.id.content_pane, fragment);
         fragmentTransaction.commitAllowingStateLoss();
     }
diff --git a/src/com/android/mail/ui/OnePaneController.java b/src/com/android/mail/ui/OnePaneController.java
index cf2266e..44d7ed9 100644
--- a/src/com/android/mail/ui/OnePaneController.java
+++ b/src/com/android/mail/ui/OnePaneController.java
@@ -337,7 +337,7 @@
          */
         replaceFragment(
                 FolderListFragment.newInstance(null, mAccount.folderListUri,
-                        SECTIONS_AND_RECENT_FOLDERS_ENABLED),
+                        SECTIONS_AND_RECENT_FOLDERS_ENABLED, false),
                 FragmentTransaction.TRANSIT_FRAGMENT_OPEN, TAG_FOLDER_LIST,
                 R.id.drawer_pullout);
 
@@ -455,7 +455,7 @@
             // showing this folder's children if we are not already
             // looking at the child view for this folder.
             mLastFolderListTransactionId = replaceFragment(FolderListFragment.newInstance(
-                    top, top.childFoldersListUri, SECTIONS_AND_RECENT_FOLDERS_ENABLED),
+                    top, top.childFoldersListUri, SECTIONS_AND_RECENT_FOLDERS_ENABLED, false),
                     FragmentTransaction.TRANSIT_FRAGMENT_OPEN, TAG_FOLDER_LIST,
                     R.id.content_pane);
             // Show the up affordance when digging into child folders.
@@ -496,7 +496,8 @@
             // showing this folder's children if we are not already
             // looking at the child view for this folder.
             mLastFolderListTransactionId = replaceFragment(
-                    FolderListFragment.newInstance(folder, folder.childFoldersListUri, false),
+                    FolderListFragment.newInstance(folder, folder.childFoldersListUri,
+                            SECTIONS_AND_RECENT_FOLDERS_ENABLED, false),
                     FragmentTransaction.TRANSIT_FRAGMENT_OPEN, TAG_FOLDER_LIST, R.id.content_pane);
             // Show the up affordance when digging into child folders.
             mActionBarView.setBackButton();
diff --git a/src/com/android/mail/ui/TwoPaneController.java b/src/com/android/mail/ui/TwoPaneController.java
index 4b44b1c..4b45e3d 100644
--- a/src/com/android/mail/ui/TwoPaneController.java
+++ b/src/com/android/mail/ui/TwoPaneController.java
@@ -105,7 +105,8 @@
     private void createFolderListFragment(Folder parent, Uri uri) {
         setHierarchyFolder(parent);
         // Create a sectioned FolderListFragment.
-        FolderListFragment folderListFragment = FolderListFragment.newInstance(parent, uri, true);
+        FolderListFragment folderListFragment = FolderListFragment.newInstance(parent, uri, true,
+                true);
         FragmentTransaction fragmentTransaction = mActivity.getFragmentManager().beginTransaction();
         if (Utils.useFolderListFragmentTransition(mActivity.getActivityContext())) {
             fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);