summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2011-05-17 14:16:43 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-05-17 14:16:43 -0700
commitdff789754865dff19792f0799cce2f76f7d41227 (patch)
tree023628a807836251bc23bc4bff81cd28ea121bab
parent63e2c0888d1a4f91a48874052d13c95291fdfea7 (diff)
parent8666663e6e6dfe615c8e29cae4a42c8f135b7554 (diff)
downloadframeworks_base-dff789754865dff19792f0799cce2f76f7d41227.zip
frameworks_base-dff789754865dff19792f0799cce2f76f7d41227.tar.gz
frameworks_base-dff789754865dff19792f0799cce2f76f7d41227.tar.bz2
Merge "View horizontalDirection public attribute resolution to an internal var."
-rw-r--r--api/current.txt1
-rw-r--r--core/java/android/view/View.java32
2 files changed, 33 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index 5482cb8..b88ef3a 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -21271,6 +21271,7 @@ package android.view {
method public boolean isInEditMode();
method public boolean isInTouchMode();
method public boolean isLayoutRequested();
+ method public boolean isLayoutRtl();
method public boolean isLongClickable();
method public boolean isOpaque();
method protected boolean isPaddingOffsetRequired();
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 1815a3a..68caa53 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -1709,6 +1709,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
*/
static final int DRAG_HOVERED = 0x00000002;
+ /**
+ * Indicates whether the view is drawn in right-to-left direction.
+ *
+ * @hide
+ */
+ static final int RESOLVED_LAYOUT_RTL = 0x00000004;
+
/* End of masks for mPrivateFlags2 */
static final int DRAG_MASK = DRAG_CAN_ACCEPT | DRAG_HOVERED;
@@ -8488,6 +8495,21 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
mPrivateFlags &= ~AWAKEN_SCROLL_BARS_ON_ATTACH;
}
jumpDrawablesToCurrentState();
+
+ // Resolving the layout direction. LTR is set initially.
+ mPrivateFlags2 &= ~RESOLVED_LAYOUT_RTL;
+ switch (getHorizontalDirection()) {
+ case HORIZONTAL_DIRECTION_INHERIT:
+ // If this is root view, no need to look at parent's layout dir.
+ if (mParent != null && mParent instanceof ViewGroup &&
+ ((ViewGroup) mParent).isLayoutRtl()) {
+ mPrivateFlags2 |= RESOLVED_LAYOUT_RTL;
+ }
+ break;
+ case HORIZONTAL_DIRECTION_RTL:
+ mPrivateFlags2 |= RESOLVED_LAYOUT_RTL;
+ break;
+ }
}
/**
@@ -9975,6 +9997,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
}
/**
+ * <p>Indicates whether or not this view's layout is right-to-left. This is resolved from
+ * layout attribute and/or the inherited value from the parent.</p>
+ *
+ * @return true if the layout is right-to-left.
+ */
+ public boolean isLayoutRtl() {
+ return (mPrivateFlags2 & RESOLVED_LAYOUT_RTL) == RESOLVED_LAYOUT_RTL;
+ }
+
+ /**
* Assign a size and position to a view and all of its
* descendants
*