Merge "Fix bug #11256076 Spinner text is too close from the opening triangle in RTL Locales" into klp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f48bcd5b68
@@ -3102,6 +3102,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
*/
|
||||
private static final int UNDEFINED_PADDING = Integer.MIN_VALUE;
|
||||
|
||||
private boolean mUseBackgroundPadding = false;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@@ -12135,12 +12137,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
if (!isTextAlignmentResolved()) {
|
||||
resolveTextAlignment();
|
||||
}
|
||||
if (!isPaddingResolved()) {
|
||||
resolvePadding();
|
||||
}
|
||||
// Should resolve Drawables before Padding because we need the layout direction of the
|
||||
// Drawable to correctly resolve Padding.
|
||||
if (!isDrawablesResolved()) {
|
||||
resolveDrawables();
|
||||
}
|
||||
if (!isPaddingResolved()) {
|
||||
resolvePadding();
|
||||
}
|
||||
onRtlPropertiesChanged(getLayoutDirection());
|
||||
return true;
|
||||
}
|
||||
@@ -12343,6 +12347,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
// If start / end padding are defined, they will be resolved (hence overriding) to
|
||||
// left / right or right / left depending on the resolved layout direction.
|
||||
// If start / end padding are not defined, use the left / right ones.
|
||||
if (mBackground != null && mUseBackgroundPadding) {
|
||||
Rect padding = sThreadLocal.get();
|
||||
if (padding == null) {
|
||||
padding = new Rect();
|
||||
sThreadLocal.set(padding);
|
||||
}
|
||||
mBackground.getPadding(padding);
|
||||
mUserPaddingLeftInitial = padding.left;
|
||||
mUserPaddingRightInitial = padding.right;
|
||||
}
|
||||
switch (resolvedLayoutDirection) {
|
||||
case LAYOUT_DIRECTION_RTL:
|
||||
if (mUserPaddingStart != UNDEFINED_PADDING) {
|
||||
@@ -15338,6 +15352,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
mUserPaddingRightInitial = padding.right;
|
||||
internalSetPadding(padding.left, padding.top, padding.right, padding.bottom);
|
||||
}
|
||||
mUseBackgroundPadding = true;
|
||||
} else {
|
||||
mUseBackgroundPadding = false;
|
||||
}
|
||||
|
||||
// Compare the minimum sizes of the old Drawable and the new. If there isn't an old or
|
||||
@@ -15363,6 +15380,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
/* Remove the background */
|
||||
mBackground = null;
|
||||
|
||||
mUseBackgroundPadding = false;
|
||||
|
||||
if ((mPrivateFlags & PFLAG_ONLY_DRAWS_BACKGROUND) != 0) {
|
||||
/*
|
||||
* This view ONLY drew the background before and we're removing
|
||||
@@ -15434,6 +15453,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
mUserPaddingLeftInitial = left;
|
||||
mUserPaddingRightInitial = right;
|
||||
|
||||
mUseBackgroundPadding = false;
|
||||
|
||||
internalSetPadding(left, top, right, bottom);
|
||||
}
|
||||
|
||||
@@ -15520,6 +15541,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
mUserPaddingStart = start;
|
||||
mUserPaddingEnd = end;
|
||||
|
||||
mUseBackgroundPadding = false;
|
||||
|
||||
switch(getLayoutDirection()) {
|
||||
case LAYOUT_DIRECTION_RTL:
|
||||
mUserPaddingLeftInitial = end;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user