Skip to content

Commit e3ae8e1

Browse files
committed
[Slider] Use the locale from the context for formatting
1 parent 4b26950 commit e3ae8e1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/java/com/google/android/material/slider/BaseSlider.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ abstract class BaseSlider<
305305
@NonNull private final Paint inactiveTicksPaint;
306306
@NonNull private final Paint activeTicksPaint;
307307
@NonNull private final Paint stopIndicatorPaint;
308+
@NonNull private final Locale locale;
308309
@NonNull private final AccessibilityHelper accessibilityHelper;
309310
private final AccessibilityManager accessibilityManager;
310311
private AccessibilityEventSender accessibilityEventSender;
@@ -476,6 +477,8 @@ public BaseSlider(
476477
// Initialize with just this view's visibility.
477478
thisAndAncestorsVisible = isShown();
478479

480+
locale = context.getResources().getConfiguration().locale;
481+
479482
inactiveTrackPaint = new Paint();
480483
activeTrackPaint = new Paint();
481484

@@ -3762,7 +3765,7 @@ private String formatValue(float value) {
37623765
return formatter.getFormattedValue(value);
37633766
}
37643767

3765-
return String.format((int) value == value ? "%.0f" : "%.2f", value);
3768+
return String.format(locale, (int) value == value ? "%.0f" : "%.2f", value);
37663769
}
37673770

37683771
private void setValueForLabel(TooltipDrawable label, float value) {
@@ -4334,7 +4337,7 @@ protected void onPopulateNodeForVirtualView(
43344337
info.setStateDescription(stateDescription);
43354338
} else {
43364339
contentDescription.append(
4337-
String.format(Locale.getDefault(), "%s, %s", verbalValueType, verbalValue));
4340+
String.format(slider.locale, "%s, %s", verbalValueType, verbalValue));
43384341
}
43394342
info.setContentDescription(contentDescription.toString());
43404343

0 commit comments

Comments
 (0)