summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2012-10-12 18:25:44 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-12 18:25:55 -0700
commitf9307c5c00bd3e8338bd478fec67a0190d515558 (patch)
tree431840c788a9c19524153ed649c68bc7af76ee6e /core/java
parent59cb2cf15c912280b32292c79c2c0e5bfea49b68 (diff)
parent84ebb35f392478600ddf8f08107fb345f13ef91c (diff)
downloadframeworks_base-f9307c5c00bd3e8338bd478fec67a0190d515558.zip
frameworks_base-f9307c5c00bd3e8338bd478fec67a0190d515558.tar.gz
frameworks_base-f9307c5c00bd3e8338bd478fec67a0190d515558.tar.bz2
Merge "Fix bug #7334966 Padding is still broken in RTL languages" into jb-mr1-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/View.java42
-rw-r--r--core/java/android/view/ViewGroup.java92
-rw-r--r--core/java/android/widget/CheckedTextView.java15
-rw-r--r--core/java/android/widget/TextView.java3
4 files changed, 120 insertions, 32 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 608bdd7..946965b 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -3666,15 +3666,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
// Padding from the background drawable is stored at this point in mUserPaddingLeftInitial
// and mUserPaddingRightInitial) so drawable padding will be used as ultimate default if
// defined.
- if (startPaddingDefined) {
- mUserPaddingLeftInitial = startPadding;
- } else if (leftPaddingDefined) {
+ if (leftPaddingDefined) {
mUserPaddingLeftInitial = leftPadding;
}
- if (endPaddingDefined) {
- mUserPaddingRightInitial = endPadding;
- }
- else if (rightPaddingDefined) {
+ if (rightPaddingDefined) {
mUserPaddingRightInitial = rightPadding;
}
}
@@ -11559,8 +11554,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
/**
* Resolve all RTL related properties.
+ *
+ * @hide
*/
- void resolveRtlPropertiesIfNeeded() {
+ public void resolveRtlPropertiesIfNeeded() {
if (!needRtlPropertiesResolution()) return;
// Order is important here: LayoutDirection MUST be resolved first
@@ -11584,8 +11581,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
onRtlPropertiesChanged(getLayoutDirection());
}
- // Reset resolution of all RTL related properties.
- void resetRtlProperties() {
+ /**
+ * Reset resolution of all RTL related properties.
+ *
+ * @hide
+ */
+ public void resetRtlProperties() {
resetResolvedLayoutDirection();
resetResolvedTextDirection();
resetResolvedTextAlignment();
@@ -14195,7 +14196,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @hide
*/
- public void resolveDrawables() {
+ protected void resolveDrawables() {
if (mBackground != null) {
mBackground.setLayoutDirection(getLayoutDirection());
}
@@ -14218,7 +14219,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
public void onResolveDrawables(int layoutDirection) {
}
- private void resetResolvedDrawables() {
+ /**
+ * @hide
+ */
+ protected void resetResolvedDrawables() {
mPrivateFlags2 &= ~PFLAG2_DRAWABLE_RESOLVED;
}
@@ -14804,14 +14808,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
if (isRtlCompatibilityMode()) {
mPaddingLeft = mUserPaddingLeftInitial;
mPaddingRight = mUserPaddingRightInitial;
+ return;
+ }
+ if (isLayoutRtl()) {
+ mPaddingLeft = (mUserPaddingEnd >= 0) ? mUserPaddingEnd : mUserPaddingLeftInitial;
+ mPaddingRight = (mUserPaddingStart >= 0) ? mUserPaddingStart : mUserPaddingRightInitial;
} else {
- if (isLayoutRtl()) {
- mPaddingLeft = mUserPaddingRightInitial;
- mPaddingRight = mUserPaddingLeftInitial;
- } else {
- mPaddingLeft = mUserPaddingLeftInitial;
- mPaddingRight = mUserPaddingRightInitial;
- }
+ mPaddingLeft = (mUserPaddingStart >= 0) ? mUserPaddingStart : mUserPaddingLeftInitial;
+ mPaddingRight = (mUserPaddingEnd >= 0) ? mUserPaddingEnd : mUserPaddingRightInitial;
}
}
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 0661992..9ce7df9 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -5263,6 +5263,21 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
* @hide
*/
@Override
+ public void resolveRtlPropertiesIfNeeded() {
+ super.resolveRtlPropertiesIfNeeded();
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child.isLayoutDirectionInherited()) {
+ child.resolveRtlPropertiesIfNeeded();
+ }
+ }
+ }
+
+ /**
+ * @hide
+ */
+ @Override
public boolean resolveLayoutDirection() {
final boolean result = super.resolveLayoutDirection();
if (result) {
@@ -5317,6 +5332,51 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
* @hide
*/
@Override
+ public void resolvePadding() {
+ super.resolvePadding();
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child.isLayoutDirectionInherited()) {
+ child.resolvePadding();
+ }
+ }
+ }
+
+ /**
+ * @hide
+ */
+ @Override
+ protected void resolveDrawables() {
+ super.resolveDrawables();
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child.isLayoutDirectionInherited()) {
+ child.resolveDrawables();
+ }
+ }
+ }
+
+ /**
+ * @hide
+ */
+ @Override
+ public void resetRtlProperties() {
+ super.resetRtlProperties();
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child.isLayoutDirectionInherited()) {
+ child.resetRtlProperties();
+ }
+ }
+ }
+
+ /**
+ * @hide
+ */
+ @Override
public void resetResolvedLayoutDirection() {
super.resetResolvedLayoutDirection();
@@ -5362,6 +5422,38 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
}
/**
+ * @hide
+ */
+ @Override
+ public void resetResolvedPadding() {
+ super.resetResolvedPadding();
+
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child.isLayoutDirectionInherited()) {
+ child.resetResolvedPadding();
+ }
+ }
+ }
+
+ /**
+ * @hide
+ */
+ @Override
+ protected void resetResolvedDrawables() {
+ super.resetResolvedDrawables();
+
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child.isLayoutDirectionInherited()) {
+ child.resetResolvedDrawables();
+ }
+ }
+ }
+
+ /**
* Return true if the pressed state should be delayed for children or descendants of this
* ViewGroup. Generally, this should be done for containers that can scroll, such as a List.
* This prevents the pressed state from appearing when the user is actually trying to scroll
diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java
index e74e37c..de8b80d 100644
--- a/core/java/android/widget/CheckedTextView.java
+++ b/core/java/android/widget/CheckedTextView.java
@@ -188,10 +188,11 @@ public class CheckedTextView extends TextView implements Checkable {
resetPaddingToInitialValues();
int newPadding = (mCheckMarkDrawable != null) ?
mCheckMarkWidth + mBasePadding : mBasePadding;
- mNeedRequestlayout |= (mPaddingRight != newPadding);
if (isLayoutRtl()) {
+ mNeedRequestlayout |= (mPaddingLeft != newPadding);
mPaddingLeft = newPadding;
} else {
+ mNeedRequestlayout |= (mPaddingRight != newPadding);
mPaddingRight = newPadding;
}
if (mNeedRequestlayout) {
@@ -200,18 +201,6 @@ public class CheckedTextView extends TextView implements Checkable {
}
}
- @Override
- public void setPadding(int left, int top, int right, int bottom) {
- super.setPadding(left, top, right, bottom);
- setBasePadding(isLayoutRtl());
- }
-
- @Override
- public void setPaddingRelative(int start, int top, int end, int bottom) {
- super.setPaddingRelative(start, top, end, bottom);
- setBasePadding(isLayoutRtl());
- }
-
private void setBasePadding(boolean isLayoutRtl) {
if (isLayoutRtl) {
mBasePadding = mPaddingLeft;
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 958b669..b3c679c 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -8314,6 +8314,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
}
+ /**
+ * @hide
+ */
protected void resetResolvedDrawables() {
mResolvedDrawables = false;
}