Fix progress bar and spinner in RTL mode
Add "mirrorForRtl" property for ProgressBar (default is "false") and use it accordingly to the following RTL rules: - time still goes from left to right - clocks still rotate clockwise Change-Id: Ib91ce6ab341aa6097c0f43b13703174a2ee9ec70
This commit is contained in:
@@ -725,6 +725,7 @@ package android {
|
||||
field public static final int minSdkVersion = 16843276; // 0x101020c
|
||||
field public static final int minWidth = 16843071; // 0x101013f
|
||||
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 moreIcon = 16843061; // 0x1010135
|
||||
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
|
||||
final int left = isLayoutRtl() ? available - thumbPos : thumbPos;
|
||||
final int left = (isLayoutRtl() && mMirrorForRtl) ? available - thumbPos : thumbPos;
|
||||
thumb.setBounds(left, topBound, left + thumbWidth, bottomBound);
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ public abstract class AbsSeekBar extends ProgressBar {
|
||||
int x = (int)event.getX();
|
||||
float scale;
|
||||
float progress = 0;
|
||||
if (isLayoutRtl()) {
|
||||
if (isLayoutRtl() && mMirrorForRtl) {
|
||||
if (x > width - mPaddingRight) {
|
||||
scale = 0.0f;
|
||||
} else if (x < mPaddingLeft) {
|
||||
|
||||
@@ -223,6 +223,8 @@ public class ProgressBar extends View {
|
||||
private boolean mAttached;
|
||||
private boolean mRefreshIsPosted;
|
||||
|
||||
boolean mMirrorForRtl = false;
|
||||
|
||||
private final ArrayList<RefreshData> mRefreshData = new ArrayList<RefreshData>();
|
||||
|
||||
private AccessibilityEventSender mAccessibilityEventSender;
|
||||
@@ -302,6 +304,8 @@ public class ProgressBar extends View {
|
||||
setIndeterminate(mOnlyIndeterminate || a.getBoolean(
|
||||
R.styleable.ProgressBar_indeterminate, mIndeterminate));
|
||||
|
||||
mMirrorForRtl = a.getBoolean(R.styleable.ProgressBar_mirrorForRtl, mMirrorForRtl);
|
||||
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@@ -1004,7 +1008,7 @@ public class ProgressBar extends View {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isLayoutRtl()) {
|
||||
if (isLayoutRtl() && mMirrorForRtl) {
|
||||
int tempLeft = left;
|
||||
left = w - right;
|
||||
right = w - tempLeft;
|
||||
@@ -1026,7 +1030,7 @@ public class ProgressBar extends View {
|
||||
// Translate canvas so a indeterminate circular progress bar with padding
|
||||
// rotates properly in its animation
|
||||
canvas.save();
|
||||
if(isLayoutRtl()) {
|
||||
if(isLayoutRtl() && mMirrorForRtl) {
|
||||
canvas.translate(getWidth() - mPaddingRight, mPaddingTop);
|
||||
canvas.scale(-1.0f, 1.0f);
|
||||
} else {
|
||||
|
||||
@@ -2960,6 +2960,9 @@
|
||||
<!-- Timeout between frames of animation in milliseconds
|
||||
{@deprecated Not used by the framework.} -->
|
||||
<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 name="SeekBar">
|
||||
|
||||
@@ -2034,5 +2034,6 @@
|
||||
<eat-comment />
|
||||
|
||||
<public type="attr" name="mipMap" id="0x010103cd" />
|
||||
<public type="attr" name="mirrorForRtl" id="0x010103ce" />
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -370,6 +370,7 @@ please see styles_device_defaults.xml.
|
||||
<item name="android:maxWidth">48dip</item>
|
||||
<item name="android:minHeight">48dip</item>
|
||||
<item name="android:maxHeight">48dip</item>
|
||||
<item name="android:mirrorForRtl">false</item>
|
||||
</style>
|
||||
|
||||
<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:minHeight">20dip</item>
|
||||
<item name="android:maxHeight">20dip</item>
|
||||
<item name="android:mirrorForRtl">true</item>
|
||||
</style>
|
||||
|
||||
<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:thumbOffset">8dip</item>
|
||||
<item name="android:focusable">true</item>
|
||||
<item name="android:mirrorForRtl">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.RatingBar">
|
||||
@@ -430,6 +433,7 @@ please see styles_device_defaults.xml.
|
||||
<item name="android:minHeight">57dip</item>
|
||||
<item name="android:maxHeight">57dip</item>
|
||||
<item name="android:thumb">@null</item>
|
||||
<item name="android:mirrorForRtl">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.RatingBar.Indicator">
|
||||
@@ -1745,6 +1749,7 @@ please see styles_device_defaults.xml.
|
||||
<item name="android:focusable">true</item>
|
||||
<item name="android:paddingStart">16dip</item>
|
||||
<item name="android:paddingEnd">16dip</item>
|
||||
<item name="android:mirrorForRtl">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Holo.RatingBar" parent="Widget.RatingBar">
|
||||
|
||||
Reference in New Issue
Block a user