summaryrefslogtreecommitdiff
path: root/core/java/android/view/View.java
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2013-08-08 16:28:07 -0700
committerFabrice Di Meglio <fdimeglio@google.com>2013-08-08 18:22:08 -0700
commit4155e2e175d73bb98b13ecb2fbbe6a6dffe28fe5 (patch)
treec17767e9aa9f7e33c57851ddd23b9e7d6110461a /core/java/android/view/View.java
parent89d16f7597d9e03bf3cf9eb1ba91b590ab1ac892 (diff)
Fix bug #10210182 CTS: android.widget.cts.TextViewTest#testDrawableResolution is failing on KLP
This issue has been actually revealed by a fix for bug #7034321 (Need Drawable RTL support) where I identified an issue with Drawables resolution in TextView (was missing a call to resetResolvedDrawables() and resolveDrawables()). - add missing resetResolvedDrawables() and resolveDrawables() in TextView.setRelativeDrawablesIfNeeded() - fix View.resolveDrawables(): this was a bit trycky as View.resolveDrawables() was wrongly supposing that the layout direction was resolved and it could access View.getLayoutDirection() and could position the PFLAG2_DRAWABLE_RESOLVED bit. Dont forget that resolution of RTL properties (layoutDirection, Drawables ...) is happening in View.measure() but in our case (TexView constructor) we still need to resolve the Drawables. So now, be sure that we cannot resolve the Drawable if layout direction has not being resolved and the raw layout direction is LAYOUT_DIRECTION_INHERIT. But we can also "cheat" if the raw layout direction is LAYOUT_DIRECTION_LTR or LAYOUT_DIRECTION_RTL or LAYOUT_DIRECTION_LOCALE as its resolution will give the same value :-) Change-Id: I7a242d918697e1e1c2febf229e8edf1866b855be
Diffstat (limited to 'core/java/android/view/View.java')
-rw-r--r--core/java/android/view/View.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 20938f512733..019d871f9d5b 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -14659,13 +14659,26 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @hide
*/
protected void resolveDrawables() {
- if (canResolveLayoutDirection()) {
- if (mBackground != null) {
- mBackground.setLayoutDirection(getLayoutDirection());
- }
- mPrivateFlags2 |= PFLAG2_DRAWABLE_RESOLVED;
- onResolveDrawables(getLayoutDirection());
+ // Drawables resolution may need to happen before resolving the layout direction (which is
+ // done only during the measure() call).
+ // If the layout direction is not resolved yet, we cannot resolve the Drawables except in
+ // one case: when the raw layout direction has not been defined as LAYOUT_DIRECTION_INHERIT.
+ // So, if the raw layout direction is LAYOUT_DIRECTION_LTR or LAYOUT_DIRECTION_RTL or
+ // LAYOUT_DIRECTION_LOCALE, we can "cheat" and we don't need to wait for the layout
+ // direction to be resolved as its resolved value will be the same as its raw value.
+ if (!isLayoutDirectionResolved() &&
+ getRawLayoutDirection() == View.LAYOUT_DIRECTION_INHERIT) {
+ return;
+ }
+
+ final int layoutDirection = isLayoutDirectionResolved() ?
+ getLayoutDirection() : getRawLayoutDirection();
+
+ if (mBackground != null) {
+ mBackground.setLayoutDirection(layoutDirection);
}
+ mPrivateFlags2 |= PFLAG2_DRAWABLE_RESOLVED;
+ onResolveDrawables(layoutDirection);
}
/**