Fix folder items in the folder selection dialog.

Note: it seems like these color blocks may never have worked in Gmail...
Also, checks for empty string before parsing a color.
Change-Id: Ia097a8bc7bc30bfa0bcf507c86f299c4c9a47cd4
diff --git a/res/layout/multi_folders_view.xml b/res/layout/multi_folders_view.xml
index 91f6888..790367f 100644
--- a/res/layout/multi_folders_view.xml
+++ b/res/layout/multi_folders_view.xml
@@ -19,35 +19,18 @@
 
 <!-- Describes an individual toggleable label entry to be displayed in a list of labels in
      a label selection UI. -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/labels"
-    android:orientation="horizontal"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:height="?android:attr/listPreferredItemHeight"
-    android:gravity="center_vertical"
-    android:padding="3dip">
+    android:layout_height="?android:attr/listPreferredItemHeight">
 
     <!-- Note: the checkbox is not focusable because the parent list item itself handles
          the toggling -->
     <CheckBox android:id="@+id/checkbox"
-        android:layout_height="wrap_content"
-        android:layout_width="0dip"
-        android:layout_weight="1"
-        android:layout_margin="4dip"
-        android:singleLine="false"
-        android:maxLines="2"
-        android:ellipsize="end"
-        android:drawablePadding="20dip"
-        android:focusable="false"
-        android:focusableInTouchMode="false"
-        android:textAppearance="?android:attr/textAppearanceLarge"/>
+        style="@style/FolderSelectionItemStyle"/>
 
     <View
         android:id="@+id/color_block"
-        android:layout_height="36dip"
-        android:layout_width="36dip"
-        android:layout_gravity="right|top"
-        android:layout_margin="4dip" />
+        style="@style/FolderColorBoxStyle"/>
 
-</LinearLayout>
+</RelativeLayout>
diff --git a/res/layout/single_folders_view.xml b/res/layout/single_folders_view.xml
index 003f5fa..5499173 100644
--- a/res/layout/single_folders_view.xml
+++ b/res/layout/single_folders_view.xml
@@ -19,35 +19,18 @@
 
 <!-- Describes an individual toggleable label entry to be displayed in a list of labels in
      a label selection UI. -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/labels"
-    android:orientation="horizontal"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:height="?android:attr/listPreferredItemHeight"
-    android:gravity="center_vertical"
-    android:padding="3dip">
+    android:layout_height="?android:attr/listPreferredItemHeight">
 
     <!-- Note: the checkbox is not focusable because the parent list item itself handles
          the toggling -->
     <RadioButton android:id="@+id/checkbox"
-        android:layout_height="wrap_content"
-        android:layout_width="0dip"
-        android:layout_weight="1"
-        android:layout_margin="4dip"
-        android:singleLine="false"
-        android:maxLines="2"
-        android:ellipsize="end"
-        android:drawablePadding="20dip"
-        android:focusable="false"
-        android:focusableInTouchMode="false"
-        android:textAppearance="?android:attr/textAppearanceLarge"/>
+        style="@style/FolderSelectionItemStyle"/>
 
     <View
         android:id="@+id/color_block"
-        android:layout_height="36dip"
-        android:layout_width="36dip"
-        android:layout_gravity="right|top"
-        android:layout_margin="4dip" />
+        style="@style/FolderColorBoxStyle" />
 
-</LinearLayout>
+</RelativeLayout>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 5af79a4..aea2bf7 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -314,6 +314,25 @@
         <item name="android:layout_width">@dimen/folder_list_folder_color_width</item>
     </style>
 
+    <style name="FolderColorBoxStyle" parent="@style/FolderItemIcon">
+        <item name="android:layout_alignParentTop">true</item>
+        <item name="android:layout_alignParentLeft">true</item>
+    </style>
+
+    <style name="FolderSelectionItemStyle">
+        <item name="android:layout_height">match_parent</item>
+        <item name="android:layout_width">match_parent</item>
+        <item name="android:layout_margin">4dip</item>
+        <item name="android:singleLine">false</item>
+        <item name="android:maxLines">2</item>
+        <item name="android:ellipsize">end</item>
+        <item name="android:drawablePadding">20dip</item>
+        <item name="android:focusable">false</item>
+        <item name="android:focusableInTouchMode">false</item>
+        <item name="android:textAppearance">?android:attr/textAppearanceLarge</item>
+        <item name="android:layout_gravity">center_vertical</item>
+    </style>
+
     <!-- Widget styles -->
     <style name="WidgetTitle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
         <item name="android:textColor">#333333</item>
diff --git a/src/com/android/mail/providers/Folder.java b/src/com/android/mail/providers/Folder.java
index 3ee4497..6cc9893 100644
--- a/src/com/android/mail/providers/Folder.java
+++ b/src/com/android/mail/providers/Folder.java
@@ -387,7 +387,7 @@
     // Show black text on a transparent swatch for system labels, effectively hiding the
     // swatch (see bug 2431925).
     public static void setFolderBlockColor(Folder folder, View colorBlock) {
-        boolean showBg = folder.bgColor != null;
+        boolean showBg = !TextUtils.isEmpty(folder.bgColor);
         final int backgroundColor = showBg ? Color.parseColor(folder.bgColor) : 0;
 
         if (!showBg) {