summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2012-06-04 12:55:30 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-06-04 12:55:30 -0700
commitb03b434089cf2106c467b2827a65e5c589c91d01 (patch)
tree9222343e85cac935144cc6bd2320a7ce434620ec /graphics
parentc96132ff53e5c26f5b0170edd85072006fb2bc70 (diff)
downloadframeworks_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 '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.java40
-rw-r--r--graphics/java/android/graphics/drawable/ScaleDrawable.java2
4 files changed, 24 insertions, 22 deletions
diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java
index 87421b1..e82ccd4 100644
--- a/graphics/java/android/graphics/drawable/BitmapDrawable.java
+++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java
@@ -385,7 +385,7 @@ public class BitmapDrawable extends Drawable {
Shader shader = state.mPaint.getShader();
if (shader == null) {
if (mApplyGravity) {
- final int layoutDirection = getResolvedLayoutDirectionSelf();
+ final int layoutDirection = getLayoutDirection();
Gravity.apply(state.mGravity, mBitmapWidth, mBitmapHeight,
getBounds(), mDstRect, layoutDirection);
mApplyGravity = false;
diff --git a/graphics/java/android/graphics/drawable/ClipDrawable.java b/graphics/java/android/graphics/drawable/ClipDrawable.java
index c41dd07..bade9b4 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;
}
- final int layoutDirection = getResolvedLayoutDirectionSelf();
+ final int layoutDirection = getLayoutDirection();
Gravity.apply(mClipState.mGravity, w, h, bounds, r, layoutDirection);
if (w > 0 && h > 0) {
diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java
index 6193ca7..07bcbdc 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -124,6 +124,8 @@ public abstract class Drawable {
private WeakReference<Callback> mCallback = null;
private boolean mVisible = true;
+ private int mLayoutDirection;
+
/**
* Draw in its bounds (set via setBounds) respecting optional effects such
* as alpha (set via setAlpha) and color filter (set via setColorFilter).
@@ -296,18 +298,6 @@ 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 get the resolved layout direction of the <var>who</var>.
- *
- * @param who The drawable being queried.
- */
- public int getResolvedLayoutDirection(Drawable who);
- }
-
- /**
* Bind a {@link Callback} object to this Drawable. Required for clients
* that want to support animated drawables.
*
@@ -384,15 +374,27 @@ public abstract class Drawable {
}
/**
- * Use the current {@link android.graphics.drawable.Drawable.Callback2} implementation to get
- * the resolved layout direction of this Drawable.
+ * Returns the resolved layout direction for this Drawable.
+ *
+ * @return One of {@link View#LAYOUT_DIRECTION_LTR},
+ * {@link View#LAYOUT_DIRECTION_RTL}
*/
- public int getResolvedLayoutDirectionSelf() {
- final Callback callback = getCallback();
- if (callback == null || !(callback instanceof Callback2)) {
- return View.LAYOUT_DIRECTION_LTR;
+ public int getLayoutDirection() {
+ return mLayoutDirection;
+ }
+
+ /**
+ * Set the layout direction for this drawable. Should be a resolved direction as the
+ * Drawable as no capacity to do the resolution on his own.
+ *
+ * @param layoutDirection One of {@link View#LAYOUT_DIRECTION_LTR},
+ * {@link View#LAYOUT_DIRECTION_RTL},
+ *
+ */
+ public void setLayoutDirection(int layoutDirection) {
+ if (getLayoutDirection() != layoutDirection) {
+ mLayoutDirection = layoutDirection;
}
- return ((Callback2) callback).getResolvedLayoutDirection(this);
}
/**
diff --git a/graphics/java/android/graphics/drawable/ScaleDrawable.java b/graphics/java/android/graphics/drawable/ScaleDrawable.java
index ccad250..bd2b2f0 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);
}
- final int layoutDirection = getResolvedLayoutDirectionSelf();
+ final int layoutDirection = getLayoutDirection();
Gravity.apply(mScaleState.mGravity, w, h, bounds, r, layoutDirection);
if (w > 0 && h > 0) {