Properly getLayoutDirection in RTL.

Fixes b/11973362. Apparently View.getLayoutDirection
is not valid until measure has been called at least once.
Thus calling it in onFinishInflate wasn't working reliably.

Change-Id: I1651d21438e8fe03a0b063b65833708bbc1139f6
diff --git a/src/com/android/mail/ui/ActionableToastBar.java b/src/com/android/mail/ui/ActionableToastBar.java
index dbccf33..ae2199b 100644
--- a/src/com/android/mail/ui/ActionableToastBar.java
+++ b/src/com/android/mail/ui/ActionableToastBar.java
@@ -63,8 +63,6 @@
     private TextView mActionText;
     private ToastBarOperation mOperation;
 
-    private boolean mRtl;
-
     private ClipBoundsDrawable mButtonDrawable;
 
     public ActionableToastBar(Context context) {
@@ -102,8 +100,6 @@
         mActionText = (TextView) findViewById(R.id.action_text);
 
         if (Utils.isRunningKitkatOrLater()) {
-            mRtl = Utils.isLayoutRtl(this);
-
             // Wrap the drawable so we can clip the bounds (see explanation in onLayout).
             final Drawable buttonToastBackground = mActionButton.getBackground();
             mActionButton.setBackground(null);
@@ -120,9 +116,10 @@
         // on both the right edge. We clip the background before the divider to remove the
         // rounded edge there, creating a split-pill button effect.
         if (mButtonDrawable != null) {
+            final boolean isRtl = Utils.isLayoutRtl(this);
             mButtonDrawable.setClipBounds(
-                    (mRtl ? 0 : mDivider.getLeft()), 0,
-                    (mRtl ? mDivider.getRight() : mActionButton.getWidth()),
+                    (isRtl ? 0 : mDivider.getLeft()), 0,
+                    (isRtl ? mDivider.getRight() : mActionButton.getWidth()),
                     mActionButton.getHeight());
         }
     }
diff --git a/src/com/android/mail/utils/Utils.java b/src/com/android/mail/utils/Utils.java
index 755914d..459e090 100644
--- a/src/com/android/mail/utils/Utils.java
+++ b/src/com/android/mail/utils/Utils.java
@@ -1173,7 +1173,9 @@
     }
 
     /**
-     * Determines whether the given view has RTL layout.
+     * Determines whether the given view has RTL layout. NOTE: do not call this
+     * on a view until it has been measured. This value is not guaranteed to be
+     * accurate until then.
      */
     public static boolean isLayoutRtl(View view) {
         return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) ?