Merge "Fix progress bar and spinner in RTL mode"
This commit is contained in:
committed by
Android (Google) Code Review
commit
f8ce2b94df
@@ -728,6 +728,7 @@ package android {
|
|||||||
field public static final int minSdkVersion = 16843276; // 0x101020c
|
field public static final int minSdkVersion = 16843276; // 0x101020c
|
||||||
field public static final int minWidth = 16843071; // 0x101013f
|
field public static final int minWidth = 16843071; // 0x101013f
|
||||||
field public static final int mipMap = 16843725; // 0x10103cd
|
field public static final int mipMap = 16843725; // 0x10103cd
|
||||||
|
field public static final int mirrorForRtl = 16843726; // 0x10103ce
|
||||||
field public static final int mode = 16843134; // 0x101017e
|
field public static final int mode = 16843134; // 0x101017e
|
||||||
field public static final int moreIcon = 16843061; // 0x1010135
|
field public static final int moreIcon = 16843061; // 0x1010135
|
||||||
field public static final int multiprocess = 16842771; // 0x1010013
|
field public static final int multiprocess = 16842771; // 0x1010013
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ public abstract class AbsSeekBar extends ProgressBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Canvas will be translated, so 0,0 is where we start drawing
|
// Canvas will be translated, so 0,0 is where we start drawing
|
||||||
final int left = isLayoutRtl() ? available - thumbPos : thumbPos;
|
final int left = (isLayoutRtl() && mMirrorForRtl) ? available - thumbPos : thumbPos;
|
||||||
thumb.setBounds(left, topBound, left + thumbWidth, bottomBound);
|
thumb.setBounds(left, topBound, left + thumbWidth, bottomBound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +426,7 @@ public abstract class AbsSeekBar extends ProgressBar {
|
|||||||
int x = (int)event.getX();
|
int x = (int)event.getX();
|
||||||
float scale;
|
float scale;
|
||||||
float progress = 0;
|
float progress = 0;
|
||||||
if (isLayoutRtl()) {
|
if (isLayoutRtl() && mMirrorForRtl) {
|
||||||
if (x > width - mPaddingRight) {
|
if (x > width - mPaddingRight) {
|
||||||
scale = 0.0f;
|
scale = 0.0f;
|
||||||
} else if (x < mPaddingLeft) {
|
} else if (x < mPaddingLeft) {
|
||||||
|
|||||||
@@ -223,6 +223,8 @@ public class ProgressBar extends View {
|
|||||||
private boolean mAttached;
|
private boolean mAttached;
|
||||||
private boolean mRefreshIsPosted;
|
private boolean mRefreshIsPosted;
|
||||||
|
|
||||||
|
boolean mMirrorForRtl = false;
|
||||||
|
|
||||||
private final ArrayList<RefreshData> mRefreshData = new ArrayList<RefreshData>();
|
private final ArrayList<RefreshData> mRefreshData = new ArrayList<RefreshData>();
|
||||||
|
|
||||||
private AccessibilityEventSender mAccessibilityEventSender;
|
private AccessibilityEventSender mAccessibilityEventSender;
|
||||||
@@ -302,6 +304,8 @@ public class ProgressBar extends View {
|
|||||||
setIndeterminate(mOnlyIndeterminate || a.getBoolean(
|
setIndeterminate(mOnlyIndeterminate || a.getBoolean(
|
||||||
R.styleable.ProgressBar_indeterminate, mIndeterminate));
|
R.styleable.ProgressBar_indeterminate, mIndeterminate));
|
||||||
|
|
||||||
|
mMirrorForRtl = a.getBoolean(R.styleable.ProgressBar_mirrorForRtl, mMirrorForRtl);
|
||||||
|
|
||||||
a.recycle();
|
a.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1004,7 +1008,7 @@ public class ProgressBar extends View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isLayoutRtl()) {
|
if (isLayoutRtl() && mMirrorForRtl) {
|
||||||
int tempLeft = left;
|
int tempLeft = left;
|
||||||
left = w - right;
|
left = w - right;
|
||||||
right = w - tempLeft;
|
right = w - tempLeft;
|
||||||
@@ -1026,7 +1030,7 @@ public class ProgressBar extends View {
|
|||||||
// Translate canvas so a indeterminate circular progress bar with padding
|
// Translate canvas so a indeterminate circular progress bar with padding
|
||||||
// rotates properly in its animation
|
// rotates properly in its animation
|
||||||
canvas.save();
|
canvas.save();
|
||||||
if(isLayoutRtl()) {
|
if(isLayoutRtl() && mMirrorForRtl) {
|
||||||
canvas.translate(getWidth() - mPaddingRight, mPaddingTop);
|
canvas.translate(getWidth() - mPaddingRight, mPaddingTop);
|
||||||
canvas.scale(-1.0f, 1.0f);
|
canvas.scale(-1.0f, 1.0f);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2962,6 +2962,9 @@
|
|||||||
<!-- Timeout between frames of animation in milliseconds
|
<!-- Timeout between frames of animation in milliseconds
|
||||||
{@deprecated Not used by the framework.} -->
|
{@deprecated Not used by the framework.} -->
|
||||||
<attr name="animationResolution" format="integer" />
|
<attr name="animationResolution" format="integer" />
|
||||||
|
<!-- Defines if the associated drawables need to be mirrored when in RTL mode.
|
||||||
|
Default is false -->
|
||||||
|
<attr name="mirrorForRtl" format="boolean" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="SeekBar">
|
<declare-styleable name="SeekBar">
|
||||||
|
|||||||
@@ -2034,5 +2034,6 @@
|
|||||||
<eat-comment />
|
<eat-comment />
|
||||||
|
|
||||||
<public type="attr" name="mipMap" id="0x010103cd" />
|
<public type="attr" name="mipMap" id="0x010103cd" />
|
||||||
|
<public type="attr" name="mirrorForRtl" id="0x010103ce" />
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -370,6 +370,7 @@ please see styles_device_defaults.xml.
|
|||||||
<item name="android:maxWidth">48dip</item>
|
<item name="android:maxWidth">48dip</item>
|
||||||
<item name="android:minHeight">48dip</item>
|
<item name="android:minHeight">48dip</item>
|
||||||
<item name="android:maxHeight">48dip</item>
|
<item name="android:maxHeight">48dip</item>
|
||||||
|
<item name="android:mirrorForRtl">false</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Widget.ProgressBar.Large">
|
<style name="Widget.ProgressBar.Large">
|
||||||
@@ -410,6 +411,7 @@ please see styles_device_defaults.xml.
|
|||||||
<item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
|
<item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
|
||||||
<item name="android:minHeight">20dip</item>
|
<item name="android:minHeight">20dip</item>
|
||||||
<item name="android:maxHeight">20dip</item>
|
<item name="android:maxHeight">20dip</item>
|
||||||
|
<item name="android:mirrorForRtl">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Widget.SeekBar">
|
<style name="Widget.SeekBar">
|
||||||
@@ -421,6 +423,7 @@ please see styles_device_defaults.xml.
|
|||||||
<item name="android:thumb">@android:drawable/seek_thumb</item>
|
<item name="android:thumb">@android:drawable/seek_thumb</item>
|
||||||
<item name="android:thumbOffset">8dip</item>
|
<item name="android:thumbOffset">8dip</item>
|
||||||
<item name="android:focusable">true</item>
|
<item name="android:focusable">true</item>
|
||||||
|
<item name="android:mirrorForRtl">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Widget.RatingBar">
|
<style name="Widget.RatingBar">
|
||||||
@@ -430,6 +433,7 @@ please see styles_device_defaults.xml.
|
|||||||
<item name="android:minHeight">57dip</item>
|
<item name="android:minHeight">57dip</item>
|
||||||
<item name="android:maxHeight">57dip</item>
|
<item name="android:maxHeight">57dip</item>
|
||||||
<item name="android:thumb">@null</item>
|
<item name="android:thumb">@null</item>
|
||||||
|
<item name="android:mirrorForRtl">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Widget.RatingBar.Indicator">
|
<style name="Widget.RatingBar.Indicator">
|
||||||
@@ -1745,6 +1749,7 @@ please see styles_device_defaults.xml.
|
|||||||
<item name="android:focusable">true</item>
|
<item name="android:focusable">true</item>
|
||||||
<item name="android:paddingStart">16dip</item>
|
<item name="android:paddingStart">16dip</item>
|
||||||
<item name="android:paddingEnd">16dip</item>
|
<item name="android:paddingEnd">16dip</item>
|
||||||
|
<item name="android:mirrorForRtl">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Widget.Holo.RatingBar" parent="Widget.RatingBar">
|
<style name="Widget.Holo.RatingBar" parent="Widget.RatingBar">
|
||||||
|
|||||||
Reference in New Issue
Block a user