diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-10-02 09:44:16 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-10-02 09:44:16 -0700 |
commit | 322594c4a40749a7ca193475f17f90319f4f4973 (patch) | |
tree | b07040da9bea8056858a980631b7998ac22de636 /graphics | |
parent | c2baf840d34bd78505c9fa7a32734506e67d8628 (diff) | |
parent | 6d7de848d7c4f8c6556c05dab79eb532874a82b3 (diff) | |
download | frameworks_base-322594c4a40749a7ca193475f17f90319f4f4973.zip frameworks_base-322594c4a40749a7ca193475f17f90319f4f4973.tar.gz frameworks_base-322594c4a40749a7ca193475f17f90319f4f4973.tar.bz2 |
am 6d7de848: am 1fc9eb78: am 16326f70: Merge "Fix animations, padding in RTL mode." into klp-dev
* commit '6d7de848d7c4f8c6556c05dab79eb532874a82b3':
Fix animations, padding in RTL mode.
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/drawable/InsetDrawable.java | 8 | ||||
-rw-r--r-- | graphics/java/android/graphics/drawable/NinePatchDrawable.java | 24 |
2 files changed, 25 insertions, 7 deletions
diff --git a/graphics/java/android/graphics/drawable/InsetDrawable.java b/graphics/java/android/graphics/drawable/InsetDrawable.java index e3a7e2b..8188782 100644 --- a/graphics/java/android/graphics/drawable/InsetDrawable.java +++ b/graphics/java/android/graphics/drawable/InsetDrawable.java @@ -202,7 +202,13 @@ public class InsetDrawable extends Drawable implements Drawable.Callback public void setColorFilter(ColorFilter cf) { mInsetState.mDrawable.setColorFilter(cf); } - + + /** {@hide} */ + @Override + public void setLayoutDirection(int layoutDirection) { + mInsetState.mDrawable.setLayoutDirection(layoutDirection); + } + @Override public int getOpacity() { return mInsetState.mDrawable.getOpacity(); diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java index 720494b..ab34c0f 100644 --- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java +++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java @@ -219,16 +219,15 @@ public class NinePatchDrawable extends Drawable { @Override public void draw(Canvas canvas) { final Rect bounds = getBounds(); - final boolean needMirroring = isAutoMirrored() && - getLayoutDirection() == LayoutDirection.RTL; - if (needMirroring) { + final boolean needsMirroring = needsMirroring(); + if (needsMirroring) { canvas.save(); // Mirror the 9patch canvas.translate(bounds.right - bounds.left, 0); canvas.scale(-1.0f, 1.0f); } mNinePatch.draw(canvas, bounds, mPaint); - if (needMirroring) { + if (needsMirroring) { canvas.restore(); } } @@ -240,7 +239,11 @@ public class NinePatchDrawable extends Drawable { @Override public boolean getPadding(Rect padding) { - padding.set(mPadding); + if (needsMirroring()) { + padding.set(mPadding.right, mPadding.top, mPadding.left, mPadding.bottom); + } else { + padding.set(mPadding); + } return true; } @@ -249,7 +252,12 @@ public class NinePatchDrawable extends Drawable { */ @Override public Insets getOpticalInsets() { - return mOpticalInsets; + if (needsMirroring()) { + return Insets.of(mOpticalInsets.right, mOpticalInsets.top, mOpticalInsets.right, + mOpticalInsets.bottom); + } else { + return mOpticalInsets; + } } @Override @@ -297,6 +305,10 @@ public class NinePatchDrawable extends Drawable { mNinePatchState.mAutoMirrored = mirrored; } + private boolean needsMirroring() { + return isAutoMirrored() && getLayoutDirection() == LayoutDirection.RTL; + } + @Override public boolean isAutoMirrored() { return mNinePatchState.mAutoMirrored; |