Use system APIs to localize percentage numbers

This commit is contained in:
arkon 2023-07-11 22:32:20 -04:00
parent 2f0133986a
commit 8775596a82
3 changed files with 9 additions and 4 deletions

View file

@ -18,6 +18,7 @@ import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.text.NumberFormat
object SettingsReaderScreen : SearchableSettings {
@ -248,6 +249,8 @@ object SettingsReaderScreen : SearchableSettings {
@Composable
private fun getWebtoonGroup(readerPreferences: ReaderPreferences): Preference.PreferenceGroup {
val numberFormat = remember { NumberFormat.getPercentInstance() }
val navModePref = readerPreferences.navigationModeWebtoon()
val dualPageSplitPref = readerPreferences.dualPageSplitWebtoon()
val webtoonSidePaddingPref = readerPreferences.webtoonSidePadding()
@ -280,7 +283,7 @@ object SettingsReaderScreen : SearchableSettings {
Preference.PreferenceItem.SliderPreference(
value = webtoonSidePadding,
title = stringResource(R.string.pref_webtoon_side_padding),
subtitle = stringResource(R.string.percentage, webtoonSidePadding),
subtitle = numberFormat.format(webtoonSidePadding / 100f),
min = ReaderPreferences.WEBTOON_PADDING_MIN,
max = ReaderPreferences.WEBTOON_PADDING_MAX,
onValueChanged = {

View file

@ -3,6 +3,7 @@ package eu.kanade.presentation.reader.settings
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.res.stringResource
import eu.kanade.presentation.util.collectAsState
import eu.kanade.tachiyomi.R
@ -12,6 +13,7 @@ import eu.kanade.tachiyomi.util.system.isReleaseBuildType
import tachiyomi.presentation.core.components.CheckboxItem
import tachiyomi.presentation.core.components.HeadingItem
import tachiyomi.presentation.core.components.SliderItem
import java.text.NumberFormat
@Composable
internal fun ColumnScope.ReadingModePage(screenModel: ReaderSettingsScreenModel) {
@ -105,6 +107,8 @@ private fun ColumnScope.PagerViewerSettings(screenModel: ReaderSettingsScreenMod
@Composable
private fun ColumnScope.WebtoonViewerSettings(screenModel: ReaderSettingsScreenModel) {
val numberFormat = remember { NumberFormat.getPercentInstance() }
HeadingItem(R.string.webtoon_viewer)
// TODO: Tap zones
@ -116,7 +120,7 @@ private fun ColumnScope.WebtoonViewerSettings(screenModel: ReaderSettingsScreenM
min = ReaderPreferences.WEBTOON_PADDING_MIN,
max = ReaderPreferences.WEBTOON_PADDING_MAX,
value = webtoonSidePadding,
valueText = stringResource(R.string.percentage, webtoonSidePadding),
valueText = numberFormat.format(webtoonSidePadding / 100f),
onChange = {
screenModel.preferences.webtoonSidePadding().set(it)
},

View file

@ -434,8 +434,6 @@
<string name="pref_category_reading_mode">Reading mode</string>
<string name="pref_category_reading">Reading</string>
<string name="pref_webtoon_side_padding">Side padding</string>
<!-- A percentage amount like "12%". "%1$d" is the number and "\%%" is the "%" sign. -->
<string name="percentage">%1$d\%%</string>
<string name="pref_hide_threshold">Sensitivity for hiding menu on scroll</string>
<string name="pref_highest">Highest</string>
<string name="pref_high">High</string>