diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2011-06-13 12:16:51 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2011-06-14 16:16:39 -0700 |
commit | c0053223bedf33581b0830fb87be32c1f26e5372 (patch) | |
tree | 2ad4905ec68202ba4331f49c0efdb30d966cceeb /graphics | |
parent | f0b517d9d287e86e6e57a372ddcb070cec1fe1c0 (diff) | |
download | frameworks_base-c0053223bedf33581b0830fb87be32c1f26e5372.zip frameworks_base-c0053223bedf33581b0830fb87be32c1f26e5372.tar.gz frameworks_base-c0053223bedf33581b0830fb87be32c1f26e5372.tar.bz2 |
Add View.getResolvedLayoutDirection()
- update Callback2 interface
- update Gravity.getAbsoluteGravity() and Gravity.apply() to be more generic
by changing "boolean isRtl" parameter to "int layoutDirection"
- fix BiDiTests for RTL FrameLayout
Change-Id: I97bb456c22d5fd3ecb34f08564ce4dbed37e7459
Diffstat (limited to 'graphics')
4 files changed, 18 insertions, 11 deletions
diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java index 311f024..a4734ff 100644 --- a/graphics/java/android/graphics/drawable/BitmapDrawable.java +++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java @@ -30,6 +30,7 @@ import android.graphics.BitmapShader; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.view.Gravity; +import android.view.View; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -386,8 +387,9 @@ public class BitmapDrawable extends Drawable { Shader shader = state.mPaint.getShader(); if (shader == null) { if (mApplyGravity) { + final int layoutDirection = getResolvedLayoutDirectionSelf(); Gravity.apply(state.mGravity, mBitmapWidth, mBitmapHeight, - getBounds(), mDstRect, isLayoutRtlSelf()); + getBounds(), mDstRect, layoutDirection); mApplyGravity = false; } canvas.drawBitmap(bitmap, null, mDstRect, state.mPaint); diff --git a/graphics/java/android/graphics/drawable/ClipDrawable.java b/graphics/java/android/graphics/drawable/ClipDrawable.java index 83020aa..29edc04 100644 --- a/graphics/java/android/graphics/drawable/ClipDrawable.java +++ b/graphics/java/android/graphics/drawable/ClipDrawable.java @@ -24,6 +24,7 @@ import android.content.res.TypedArray; import android.graphics.*; import android.view.Gravity; import android.util.AttributeSet; +import android.view.View; import java.io.IOException; @@ -209,7 +210,8 @@ public class ClipDrawable extends Drawable implements Drawable.Callback { if ((mClipState.mOrientation & VERTICAL) != 0) { h -= (h - ih) * (10000 - level) / 10000; } - Gravity.apply(mClipState.mGravity, w, h, bounds, r, isLayoutRtlSelf()); + final int layoutDirection = getResolvedLayoutDirectionSelf(); + Gravity.apply(mClipState.mGravity, w, h, bounds, r, layoutDirection); if (w > 0 && h > 0) { canvas.save(); diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java index 8994efc..72d233a 100644 --- a/graphics/java/android/graphics/drawable/Drawable.java +++ b/graphics/java/android/graphics/drawable/Drawable.java @@ -36,6 +36,7 @@ import android.util.DisplayMetrics; import android.util.StateSet; import android.util.TypedValue; import android.util.Xml; +import android.view.View; import java.io.IOException; import java.io.InputStream; @@ -292,11 +293,11 @@ public abstract class Drawable { */ public static interface Callback2 extends Callback { /** - * A Drawable can call this to know whether the <var>who</var> is in RTL layout direction. + * A Drawable can call this to get the resolved layout direction of the <var>who</var>. * - * @param who The drawable being unscheduled. + * @param who The drawable being queried. */ - public boolean isLayoutRtl(Drawable who); + public int getResolvedLayoutDirection(Drawable who); } /** @@ -376,15 +377,15 @@ public abstract class Drawable { } /** - * Use the current {@link android.graphics.drawable.Drawable.Callback2} implementation to know - * if this Drawable is having a layout in RTL direction. + * Use the current {@link android.graphics.drawable.Drawable.Callback2} implementation to get + * the resolved layout direction of this Drawable. */ - public boolean isLayoutRtlSelf() { + public int getResolvedLayoutDirectionSelf() { final Callback callback = getCallback(); if (callback == null || !(callback instanceof Callback2)) { - return false; + return View.LAYOUT_DIRECTION_LTR; } - return ((Callback2) callback).isLayoutRtl(this); + return ((Callback2) callback).getResolvedLayoutDirection(this); } /** diff --git a/graphics/java/android/graphics/drawable/ScaleDrawable.java b/graphics/java/android/graphics/drawable/ScaleDrawable.java index cbe1f2d..5fd5a16 100644 --- a/graphics/java/android/graphics/drawable/ScaleDrawable.java +++ b/graphics/java/android/graphics/drawable/ScaleDrawable.java @@ -24,6 +24,7 @@ import android.content.res.TypedArray; import android.graphics.*; import android.view.Gravity; import android.util.AttributeSet; +import android.view.View; import java.io.IOException; @@ -221,7 +222,8 @@ public class ScaleDrawable extends Drawable implements Drawable.Callback { final int ih = min ? mScaleState.mDrawable.getIntrinsicHeight() : 0; h -= (int) ((h - ih) * (10000 - level) * mScaleState.mScaleHeight / 10000); } - Gravity.apply(mScaleState.mGravity, w, h, bounds, r, isLayoutRtlSelf()); + final int layoutDirection = getResolvedLayoutDirectionSelf(); + Gravity.apply(mScaleState.mGravity, w, h, bounds, r, layoutDirection); if (w > 0 && h > 0) { mScaleState.mDrawable.setBounds(r.left, r.top, r.right, r.bottom); |