summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2011-05-23 14:43:23 -0700
committerFabrice Di Meglio <fdimeglio@google.com>2011-05-27 11:23:15 -0700
commit6a03640539405afbdefe72894759281b98aa6e6f (patch)
treeb3326ddd1c7ab343f55de949f6d4a34fa2accc4e /graphics
parent4c74c03fd19cfd151eafabb8da653d943af96abb (diff)
downloadframeworks_base-6a03640539405afbdefe72894759281b98aa6e6f.zip
frameworks_base-6a03640539405afbdefe72894759281b98aa6e6f.tar.gz
frameworks_base-6a03640539405afbdefe72894759281b98aa6e6f.tar.bz2
Add support for Gravity BEFORE and AFTER
- update layouts - add Callback2 for RTL aware Drawable - add unit tests Change-Id: Ic64d0291e262170aff7297c6580b0b422eaa8d89
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/BitmapDrawable.java2
-rw-r--r--graphics/java/android/graphics/drawable/ClipDrawable.java2
-rw-r--r--graphics/java/android/graphics/drawable/Drawable.java24
-rw-r--r--graphics/java/android/graphics/drawable/ScaleDrawable.java2
4 files changed, 27 insertions, 3 deletions
diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java
index c9c9fd7..311f024 100644
--- a/graphics/java/android/graphics/drawable/BitmapDrawable.java
+++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java
@@ -387,7 +387,7 @@ public class BitmapDrawable extends Drawable {
if (shader == null) {
if (mApplyGravity) {
Gravity.apply(state.mGravity, mBitmapWidth, mBitmapHeight,
- getBounds(), mDstRect);
+ getBounds(), mDstRect, isLayoutRtlSelf());
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 b333e01..83020aa 100644
--- a/graphics/java/android/graphics/drawable/ClipDrawable.java
+++ b/graphics/java/android/graphics/drawable/ClipDrawable.java
@@ -209,7 +209,7 @@ 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);
+ Gravity.apply(mClipState.mGravity, w, h, bounds, r, isLayoutRtlSelf());
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 159f371e..8994efc 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -288,6 +288,18 @@ public abstract class Drawable {
}
/**
+ * Implement this interface if you want to create an drawable that is RTL aware
+ */
+ public static interface Callback2 extends Callback {
+ /**
+ * A Drawable can call this to know whether the <var>who</var> is in RTL layout direction.
+ *
+ * @param who The drawable being unscheduled.
+ */
+ public boolean isLayoutRtl(Drawable who);
+ }
+
+ /**
* Bind a {@link Callback} object to this Drawable. Required for clients
* that want to support animated drawables.
*
@@ -364,6 +376,18 @@ 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.
+ */
+ public boolean isLayoutRtlSelf() {
+ final Callback callback = getCallback();
+ if (callback == null || !(callback instanceof Callback2)) {
+ return false;
+ }
+ return ((Callback2) callback).isLayoutRtl(this);
+ }
+
+ /**
* Specify an alpha value for the drawable. 0 means fully transparent, and
* 255 means fully opaque.
*/
diff --git a/graphics/java/android/graphics/drawable/ScaleDrawable.java b/graphics/java/android/graphics/drawable/ScaleDrawable.java
index a7ed0d0..cbe1f2d 100644
--- a/graphics/java/android/graphics/drawable/ScaleDrawable.java
+++ b/graphics/java/android/graphics/drawable/ScaleDrawable.java
@@ -221,7 +221,7 @@ 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);
+ Gravity.apply(mScaleState.mGravity, w, h, bounds, r, isLayoutRtlSelf());
if (w > 0 && h > 0) {
mScaleState.mDrawable.setBounds(r.left, r.top, r.right, r.bottom);