Move hard-coded string to “strings.xml”
This commit is contained in:
1 parent
97ac0b8a5c
commit
aaa9caad50
2 files changed
+7
-1
No files matched your search
@@ -163,4 +163,5 @@
|
||||
<string name="enable_colorful_theme">Also Apply to Background</string>
|
||||
<string name="force_rounded_widgets">Round Corners</string>
|
||||
<string name="suggestion_pref_screen_title">Suggestions</string>
|
||||
<string name="n_percent">%1$d%%</string>
|
||||
</resources>
|
||||
@@ -21,9 +21,11 @@ import androidx.compose.material.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import app.lawnchair.preferences.PreferenceAdapter
|
||||
import app.lawnchair.preferences.rememberTransformAdapter
|
||||
import com.android.launcher3.R
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@Composable
|
||||
@@ -86,7 +88,10 @@ fun SliderPreference(
|
||||
) {
|
||||
val value = snapSliderValue(valueRange.start, sliderValue, step)
|
||||
Text(
|
||||
text = if (showAsPercentage) "${(value * 100).roundToInt()}%" else "${value.roundToInt()}"
|
||||
text = if (showAsPercentage) stringResource(
|
||||
id = R.string.n_percent,
|
||||
(value * 100).roundToInt()
|
||||
) else value.roundToInt().toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user