diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2012-06-04 12:55:30 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-06-04 12:55:30 -0700 |
commit | b03b434089cf2106c467b2827a65e5c589c91d01 (patch) | |
tree | 9222343e85cac935144cc6bd2320a7ce434620ec /core/java/android/widget | |
parent | c96132ff53e5c26f5b0170edd85072006fb2bc70 (diff) | |
download | frameworks_base-b03b434089cf2106c467b2827a65e5c589c91d01.zip frameworks_base-b03b434089cf2106c467b2827a65e5c589c91d01.tar.gz frameworks_base-b03b434089cf2106c467b2827a65e5c589c91d01.tar.bz2 |
Revert "Revert "Clean up layout direction APIs for Drawable""
This reverts commit c96132ff53e5c26f5b0170edd85072006fb2bc70
Diffstat (limited to 'core/java/android/widget')
-rw-r--r-- | core/java/android/widget/ImageView.java | 7 | ||||
-rw-r--r-- | core/java/android/widget/ProgressBar.java | 10 | ||||
-rw-r--r-- | core/java/android/widget/TextView.java | 41 |
3 files changed, 24 insertions, 34 deletions
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 7593bff..f259597 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -194,12 +194,6 @@ public class ImageView extends View { } @Override - public int getResolvedLayoutDirection(Drawable dr) { - return (dr == mDrawable) ? - getResolvedLayoutDirection() : super.getResolvedLayoutDirection(dr); - } - - @Override public boolean hasOverlappingRendering() { return (getBackground() != null); } @@ -672,6 +666,7 @@ public class ImageView extends View { d.setState(getDrawableState()); } d.setLevel(mLevel); + d.setLayoutDirection(getLayoutDirection()); mDrawableWidth = d.getIntrinsicWidth(); mDrawableHeight = d.getIntrinsicHeight(); applyColorMod(); diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java index e26620f..1c6a406 100644 --- a/core/java/android/widget/ProgressBar.java +++ b/core/java/android/widget/ProgressBar.java @@ -478,6 +478,9 @@ public class ProgressBar extends View { d.setCallback(this); } mIndeterminateDrawable = d; + if (mIndeterminateDrawable != null) { + mIndeterminateDrawable.setLayoutDirection(getLayoutDirection()); + } if (mIndeterminate) { mCurrentDrawable = d; postInvalidate(); @@ -517,6 +520,7 @@ public class ProgressBar extends View { if (d != null) { d.setCallback(this); + d.setLayoutDirection(getLayoutDirection()); // Make sure the ProgressBar is always tall enough int drawableHeight = d.getMinimumHeight(); @@ -976,12 +980,6 @@ public class ProgressBar extends View { } @Override - public int getResolvedLayoutDirection(Drawable who) { - return (who == mProgressDrawable || who == mIndeterminateDrawable) ? - getResolvedLayoutDirection() : super.getResolvedLayoutDirection(who); - } - - @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { updateDrawableBounds(w, h); } diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index d70bfb1..91dd297 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -4579,20 +4579,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } @Override - public int getResolvedLayoutDirection(Drawable who) { - if (who == null) return View.LAYOUT_DIRECTION_LTR; - if (mDrawables != null) { - final Drawables drawables = mDrawables; - if (who == drawables.mDrawableLeft || who == drawables.mDrawableRight || - who == drawables.mDrawableTop || who == drawables.mDrawableBottom || - who == drawables.mDrawableStart || who == drawables.mDrawableEnd) { - return getResolvedLayoutDirection(); - } - } - return super.getResolvedLayoutDirection(who); - } - - @Override public boolean hasOverlappingRendering() { return (getBackground() != null || mText instanceof Spannable || hasSelection()); } @@ -8203,13 +8189,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } - /** - * Subclasses will need to override this method to implement their own way of resolving - * drawables depending on the layout direction. - * - * A call to the super method will be required from the subclasses implementation. - */ - protected void resolveDrawables() { + @Override + public void onResolveDrawables(int layoutDirection) { // No need to resolve twice if (mResolvedDrawables) { return; @@ -8225,7 +8206,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } Drawables dr = mDrawables; - switch(getResolvedLayoutDirection()) { + switch(layoutDirection) { case LAYOUT_DIRECTION_RTL: if (dr.mDrawableStart != null) { dr.mDrawableRight = dr.mDrawableStart; @@ -8257,9 +8238,25 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } break; } + updateDrawablesLayoutDirection(dr, layoutDirection); mResolvedDrawables = true; } + private void updateDrawablesLayoutDirection(Drawables dr, int layoutDirection) { + if (dr.mDrawableLeft != null) { + dr.mDrawableLeft.setLayoutDirection(layoutDirection); + } + if (dr.mDrawableRight != null) { + dr.mDrawableRight.setLayoutDirection(layoutDirection); + } + if (dr.mDrawableTop != null) { + dr.mDrawableTop.setLayoutDirection(layoutDirection); + } + if (dr.mDrawableBottom != null) { + dr.mDrawableBottom.setLayoutDirection(layoutDirection); + } + } + protected void resetResolvedDrawables() { mResolvedDrawables = false; } |