diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2013-10-16 13:16:00 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2013-10-18 11:26:48 -0700 |
commit | 600d7dd1c6d9d1ff81b71085eff2a6be50d6f36c (patch) | |
tree | 2282a60fc44a7e6af2460a36b7dea427490d3f6b /graphics/java | |
parent | b5da7b23df5278a5e722b601eb8ef7e98537a51e (diff) | |
download | frameworks_base-600d7dd1c6d9d1ff81b71085eff2a6be50d6f36c.zip frameworks_base-600d7dd1c6d9d1ff81b71085eff2a6be50d6f36c.tar.gz frameworks_base-600d7dd1c6d9d1ff81b71085eff2a6be50d6f36c.tar.bz2 |
Fix bug #11256076 Spinner text is too close from the opening triangle in RTL Locales
Background Drawable padding was not taken into account in RTL Locales
- make sure the Drawables are resolved before resolving padding
- during padding resolution take care about background padding
Change-Id: Ib0c722adf5341ab4fa2182a0d0ac2ca639e85cfc
Diffstat (limited to 'graphics/java')
-rw-r--r-- | graphics/java/android/graphics/drawable/DrawableContainer.java | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java index e350e8d..60e2376 100644 --- a/graphics/java/android/graphics/drawable/DrawableContainer.java +++ b/graphics/java/android/graphics/drawable/DrawableContainer.java @@ -23,6 +23,7 @@ import android.graphics.Insets; import android.graphics.PixelFormat; import android.graphics.Rect; import android.os.SystemClock; +import android.util.LayoutDirection; import android.util.SparseArray; /** @@ -59,6 +60,8 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { private long mExitAnimationEnd; private Drawable mLastDrawable; + private Insets mInsets; + // overrides from Drawable @Override @@ -78,18 +81,30 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { | mDrawableContainerState.mChildrenChangingConfigurations; } + private boolean needsMirroring() { + return isAutoMirrored() && getLayoutDirection() == LayoutDirection.RTL; + } + @Override public boolean getPadding(Rect padding) { final Rect r = mDrawableContainerState.getConstantPadding(); + boolean result = true; if (r != null) { padding.set(r); - return true; - } - if (mCurrDrawable != null) { - return mCurrDrawable.getPadding(padding); } else { - return super.getPadding(padding); + if (mCurrDrawable != null) { + result = mCurrDrawable.getPadding(padding); + } else { + result = super.getPadding(padding); + } } + if (needsMirroring()) { + final int left = padding.left; + final int right = padding.right; + padding.left = right; + padding.right = left; + } + return result; } /** @@ -97,7 +112,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { */ @Override public Insets getOpticalInsets() { - return (mCurrDrawable == null) ? Insets.NONE : mCurrDrawable.getOpticalInsets(); + return mInsets; } @Override @@ -334,6 +349,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { mCurrDrawable = d; mCurIndex = idx; if (d != null) { + mInsets = d.getOpticalInsets(); d.mutate(); if (mDrawableContainerState.mEnterFadeDuration > 0) { mEnterAnimationEnd = now + mDrawableContainerState.mEnterFadeDuration; @@ -348,9 +364,12 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { d.setBounds(getBounds()); d.setLayoutDirection(getLayoutDirection()); d.setAutoMirrored(mDrawableContainerState.mAutoMirrored); + } else { + mInsets = Insets.NONE; } } else { mCurrDrawable = null; + mInsets = Insets.NONE; mCurIndex = -1; } |