android: Use string resource for slider value/units
This commit is contained in:
parent
89a2d308c3
commit
786b609151
|
@ -207,8 +207,11 @@ class SettingsAdapter(
|
||||||
val sliderBinding = DialogSliderBinding.inflate(inflater)
|
val sliderBinding = DialogSliderBinding.inflate(inflater)
|
||||||
|
|
||||||
textSliderValue = sliderBinding.textValue
|
textSliderValue = sliderBinding.textValue
|
||||||
textSliderValue!!.text = sliderProgress.toString()
|
textSliderValue!!.text = String.format(
|
||||||
sliderBinding.textUnits.text = item.units
|
context.getString(R.string.value_with_units),
|
||||||
|
sliderProgress.toString(),
|
||||||
|
item.units
|
||||||
|
)
|
||||||
|
|
||||||
sliderBinding.slider.apply {
|
sliderBinding.slider.apply {
|
||||||
valueFrom = item.min.toFloat()
|
valueFrom = item.min.toFloat()
|
||||||
|
@ -216,7 +219,11 @@ class SettingsAdapter(
|
||||||
value = sliderProgress.toFloat()
|
value = sliderProgress.toFloat()
|
||||||
addOnChangeListener { _: Slider, value: Float, _: Boolean ->
|
addOnChangeListener { _: Slider, value: Float, _: Boolean ->
|
||||||
sliderProgress = value.toInt()
|
sliderProgress = value.toInt()
|
||||||
textSliderValue!!.text = sliderProgress.toString()
|
textSliderValue!!.text = String.format(
|
||||||
|
context.getString(R.string.value_with_units),
|
||||||
|
sliderProgress.toString(),
|
||||||
|
item.units
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,23 +5,16 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/text_value"
|
android:id="@+id/text_value"
|
||||||
|
style="@style/TextAppearance.Material3.LabelMedium"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginBottom="@dimen/spacing_medlarge"
|
android:layout_marginBottom="@dimen/spacing_medlarge"
|
||||||
android:layout_marginTop="@dimen/spacing_medlarge"
|
android:layout_marginTop="@dimen/spacing_medlarge"
|
||||||
tools:text="75" />
|
tools:text="75%" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/text_units"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignTop="@+id/text_value"
|
|
||||||
android:layout_toEndOf="@+id/text_value"
|
|
||||||
tools:text="%" />
|
|
||||||
|
|
||||||
<com.google.android.material.slider.Slider
|
<com.google.android.material.slider.Slider
|
||||||
android:id="@+id/slider"
|
android:id="@+id/slider"
|
||||||
|
|
Reference in New Issue