Fix drawer item alignment issues in RTL and LTR.

Fixes b/12552673 and b/12682890.

Change-Id: I4d30ea2238563f866a2c9e1bb6ce3612c68cb750
diff --git a/res/layout-ldrtl/folder_list_header.xml b/res/layout-v17/folder_list_header.xml
similarity index 100%
rename from res/layout-ldrtl/folder_list_header.xml
rename to res/layout-v17/folder_list_header.xml
diff --git a/res/layout/drawer_empty_view.xml b/res/layout/drawer_empty_view.xml
index 788debd..b81d1a5 100644
--- a/res/layout/drawer_empty_view.xml
+++ b/res/layout/drawer_empty_view.xml
@@ -18,7 +18,7 @@
 
 
 <!--Empty view shown in the drawer when we are waiting for folders to initialize. -->
-<RelativeLayout
+<LinearLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/empty_view"
         android:layout_width="match_parent"
@@ -29,16 +29,15 @@
         android:id="@+id/progress"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_centerVertical="true"/>
+        android:layout_gravity="center_vertical" />
 
     <TextView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_toRightOf="@id/progress"
-        android:layout_centerVertical="true"
+        android:layout_gravity="center_vertical"
         android:text="@string/wait_for_sync_title"
         android:textColor="@color/dark_gray_text_color"
         android:textAppearance="?android:attr/textAppearanceMedium"/>
-</RelativeLayout>
+</LinearLayout>
 
 
diff --git a/res/values-ldrtl/styles-ldrtl.xml b/res/values-ldrtl/styles-ldrtl.xml
index c931b7f..bd3a08d 100644
--- a/res/values-ldrtl/styles-ldrtl.xml
+++ b/res/values-ldrtl/styles-ldrtl.xml
@@ -246,6 +246,7 @@
     </style>
 
     <style name="FolderListIconStyle">
+        <item name="android:layout_marginStart">@dimen/folder_list_item_start_margin</item>
         <item name="android:layout_alignParentStart">true</item>
     </style>
 
diff --git a/res/values/styles.xml b/res/values/styles.xml
index b537b92..3445a96 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -578,6 +578,7 @@
     </style>
 
     <style name="FolderListIconStyle">
+        <item name="android:layout_marginLeft">@dimen/folder_list_item_start_margin</item>
         <item name="android:layout_alignParentLeft">true</item>
     </style>
 
diff --git a/src/com/android/mail/adapter/DrawerItem.java b/src/com/android/mail/adapter/DrawerItem.java
index bfb5c01..093bdd3 100644
--- a/src/com/android/mail/adapter/DrawerItem.java
+++ b/src/com/android/mail/adapter/DrawerItem.java
@@ -346,7 +346,7 @@
             accountItemView =
                     (AccountItemView) mInflater.inflate(R.layout.account_item, parent, false);
         }
-        accountItemView.bind(mAccount, mIsSelected, mResource);
+        accountItemView.bind(mAccount, mIsSelected, mResource, mBidiFormatter);
         View v = accountItemView.findViewById(R.id.account_graphic);
         v.setBackgroundColor(mAccount.color);
         return accountItemView;
@@ -364,8 +364,7 @@
         if (convertView != null) {
             headerView = (TextView) convertView;
         } else {
-            headerView = (TextView) mInflater.inflate(
-                    R.layout.folder_list_header, parent, false);
+            headerView = (TextView) mInflater.inflate(R.layout.folder_list_header, parent, false);
         }
         headerView.setText(mResource);
         return headerView;
diff --git a/src/com/android/mail/ui/AccountItemView.java b/src/com/android/mail/ui/AccountItemView.java
index 7e8edee..87f154b 100644
--- a/src/com/android/mail/ui/AccountItemView.java
+++ b/src/com/android/mail/ui/AccountItemView.java
@@ -15,19 +15,17 @@
  */
 package com.android.mail.ui;
 
-import com.android.mail.R;
-
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.android.mail.providers.Account;
-import com.android.mail.utils.Utils;
-
 import android.content.Context;
-
+import android.support.v4.text.BidiFormatter;
 import android.util.AttributeSet;
 import android.view.View;
+import android.widget.ImageView;
 import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.android.mail.R;
+import com.android.mail.providers.Account;
+import com.android.mail.utils.Utils;
 
 /**
  * The view for each account in the folder list/drawer.
@@ -66,8 +64,9 @@
      * @param isCurrentAccount true if the account is the one in use, false otherwise
      * @param count unread count
      */
-    public void bind(final Account account, final boolean isCurrentAccount, final int count) {
-        mAccountTextView.setText(account.name);
+    public void bind(final Account account, final boolean isCurrentAccount,
+            final int count, BidiFormatter bidiFormatter) {
+        mAccountTextView.setText(bidiFormatter.unicodeWrap(account.name));
         setUnreadCount(count);
         mUnreadCountTextView.setSelected(isCurrentAccount);
         mAccountTextView.setSelected(isCurrentAccount);