From 8775596a822e8de217a07ed82d1ac49e552607d1 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 11 Jul 2023 22:32:20 -0400 Subject: [PATCH] Use system APIs to localize percentage numbers --- .../more/settings/screen/SettingsReaderScreen.kt | 5 ++++- .../kanade/presentation/reader/settings/ReadingModePage.kt | 6 +++++- i18n/src/main/res/values/strings.xml | 2 -- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt index 05ffec8f89..31f60acfdb 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt @@ -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 = { diff --git a/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt b/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt index e330b99449..ff710a76d0 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt @@ -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) }, diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index fdb075c62a..aed9b32eea 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -434,8 +434,6 @@ Reading mode Reading Side padding - - %1$d\%% Sensitivity for hiding menu on scroll Highest High