summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2012-09-23 16:19:03 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-23 16:19:03 -0700
commitbe4c5dd9d0b3ec1e020431f0e618a4cf38f9c57d (patch)
tree66ec460a36510b0ed025e0b43e369516eb51ef0a /core
parent9c7b529125380de5721c1d5803d2e626a3e7ac17 (diff)
parent97e146cf02f87b91f81c37d53644e5415efddb72 (diff)
downloadframeworks_base-be4c5dd9d0b3ec1e020431f0e618a4cf38f9c57d.zip
frameworks_base-be4c5dd9d0b3ec1e020431f0e618a4cf38f9c57d.tar.gz
frameworks_base-be4c5dd9d0b3ec1e020431f0e618a4cf38f9c57d.tar.bz2
Merge "Fix bug #6427629 Clean up layout direction APIs" into jb-mr1-dev
Diffstat (limited to 'core')
-rw-r--r--core/java/android/view/View.java31
-rw-r--r--core/java/android/view/ViewGroup.java2
-rw-r--r--core/java/android/widget/TextView.java3
3 files changed, 22 insertions, 14 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 94e26ea..c007142 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -16500,6 +16500,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* {@link #TEXT_DIRECTION_LTR},
* {@link #TEXT_DIRECTION_RTL},
* {@link #TEXT_DIRECTION_LOCALE}
+ *
+ * @hide
*/
@ViewDebug.ExportedProperty(category = "text", mapping = {
@ViewDebug.IntToString(from = TEXT_DIRECTION_INHERIT, to = "INHERIT"),
@@ -16509,7 +16511,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
@ViewDebug.IntToString(from = TEXT_DIRECTION_RTL, to = "RTL"),
@ViewDebug.IntToString(from = TEXT_DIRECTION_LOCALE, to = "LOCALE")
})
- public int getTextDirection() {
+ public int getRawTextDirection() {
return (mPrivateFlags2 & PFLAG2_TEXT_DIRECTION_MASK) >> PFLAG2_TEXT_DIRECTION_MASK_SHIFT;
}
@@ -16526,7 +16528,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* {@link #TEXT_DIRECTION_LOCALE}
*/
public void setTextDirection(int textDirection) {
- if (getTextDirection() != textDirection) {
+ if (getRawTextDirection() != textDirection) {
// Reset the current text direction and the resolved one
mPrivateFlags2 &= ~PFLAG2_TEXT_DIRECTION_MASK;
resetResolvedTextDirection();
@@ -16543,10 +16545,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
/**
* Return the resolved text direction.
*
- * This needs resolution if the value is TEXT_DIRECTION_INHERIT. The resolution matches
- * {@link #getTextDirection()}if it is not TEXT_DIRECTION_INHERIT, otherwise resolution proceeds
- * up the parent chain of the view. if there is no parent, then it will return the default
- * {@link #TEXT_DIRECTION_FIRST_STRONG}.
+ * This needs resolution if the value is TEXT_DIRECTION_INHERIT. The resolution matches what has
+ * been set by {@link #setTextDirection(int)} if it is not TEXT_DIRECTION_INHERIT, otherwise the
+ * resolution proceeds up the parent chain of the view. If there is no parent, then it will
+ * return the default {@link #TEXT_DIRECTION_FIRST_STRONG}.
*
* @return the resolved text direction. Returns one of:
*
@@ -16556,7 +16558,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* {@link #TEXT_DIRECTION_RTL},
* {@link #TEXT_DIRECTION_LOCALE}
*/
- public int getResolvedTextDirection() {
+ public int getTextDirection() {
// The text direction will be resolved only if needed
if ((mPrivateFlags2 & PFLAG2_TEXT_DIRECTION_RESOLVED) != PFLAG2_TEXT_DIRECTION_RESOLVED) {
resolveTextDirection();
@@ -16575,14 +16577,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
if (hasRtlSupport()) {
// Set resolved text direction flag depending on text direction flag
- final int textDirection = getTextDirection();
+ final int textDirection = getRawTextDirection();
switch(textDirection) {
case TEXT_DIRECTION_INHERIT:
if (canResolveTextDirection()) {
ViewGroup viewGroup = ((ViewGroup) mParent);
// Set current resolved direction to the same value as the parent's one
- final int parentResolvedDirection = viewGroup.getResolvedTextDirection();
+ final int parentResolvedDirection = viewGroup.getTextDirection();
switch (parentResolvedDirection) {
case TEXT_DIRECTION_FIRST_STRONG:
case TEXT_DIRECTION_ANY_RTL:
@@ -16628,7 +16630,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @return true if text direction resolution can be done otherwise return false.
*/
private boolean canResolveTextDirection() {
- switch (getTextDirection()) {
+ switch (getRawTextDirection()) {
case TEXT_DIRECTION_INHERIT:
return (mParent != null) && (mParent instanceof ViewGroup);
default:
@@ -16638,7 +16640,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
/**
* Reset resolved text direction. Text direction can be resolved with a call to
- * getResolvedTextDirection().
+ * getTextDirection().
*
* @hide
*/
@@ -16647,6 +16649,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
/**
+ * @hide
+ */
+ public boolean isTextDirectionInherited() {
+ return (getRawTextDirection() == TEXT_DIRECTION_INHERIT);
+ }
+
+ /**
* Return the value specifying the text alignment or policy that was set with
* {@link #setTextAlignment(int)}.
*
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index eed03e0..d40eef9 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -5271,7 +5271,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
if (child.isLayoutDirectionInherited()) {
child.resetResolvedLayoutDirection();
}
- if (child.getTextDirection() == TEXT_DIRECTION_INHERIT) {
+ if (child.isTextDirectionInherited()) {
child.resetResolvedTextDirection();
}
if (child.getTextAlignment() == TEXT_ALIGNMENT_INHERIT) {
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index d8d9b45..e6f643f 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -8192,8 +8192,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
final boolean defaultIsRtl = (getLayoutDirection() == LAYOUT_DIRECTION_RTL);
// Now, we can select the heuristic
- int textDir = getResolvedTextDirection();
- switch (textDir) {
+ switch (getTextDirection()) {
default:
case TEXT_DIRECTION_FIRST_STRONG:
return (defaultIsRtl ? TextDirectionHeuristics.FIRSTSTRONG_RTL :