Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

refactor: move settings language formatters

David Nashash32e716a6c65d
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsFormatting.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsFormatting.kt
index 73b25c9e..e9ef76a5 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsFormatting.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsFormatting.kt
@@ -3,8 +3,6 @@ package com.streamvault.app.ui.screens.settings
import com.streamvault.feature.settings.presentation.*
import com.streamvault.app.R
-import com.streamvault.core.ui.localization.localeForLanguageTag
-import com.streamvault.core.ui.localization.supportedAppLanguageTags
import com.streamvault.domain.model.LiveTvChannelMode
import com.streamvault.domain.model.LiveTvQuickFilterVisibilityMode
import com.streamvault.domain.model.VodViewMode
@@ -27,41 +25,6 @@ import com.streamvault.domain.model.RemoteShortcutSelectionMode
import java.text.DateFormat
import java.util.Locale
-internal data class AppLanguageOption(
- val tag: String,
- val label: String
-)
-
-internal fun supportedAppLanguages(systemDefaultLabel: String): List<AppLanguageOption> {
- val localeTags = listOf("system") + supportedAppLanguageTags()
-
- return localeTags.map { tag ->
- AppLanguageOption(
- tag = tag,
- label = if (tag == "system") {
- systemDefaultLabel
- } else {
- val locale = localeForLanguageTag(tag)
- locale.getDisplayLanguage(locale)
- .replaceFirstChar { character ->
- if (character.isLowerCase()) {
- character.titlecase(locale)
- } else {
- character.toString()
- }
- }
- }
- )
- }
-}
-
-internal fun supportedAudioLanguages(autoLabel: String): List<AppLanguageOption> {
- return buildList {
- add(AppLanguageOption(tag = "auto", label = autoLabel))
- addAll(supportedAppLanguages(autoLabel).filterNot { it.tag == "system" })
- }
-}
-
internal data class SubtitleScaleOption(
val scale: Float,
val label: (android.content.Context) -> String
@@ -99,20 +62,6 @@ internal fun subtitleBackgroundColorOptions(context: android.content.Context): L
)
}
-internal fun displayLanguageLabel(languageTag: String, defaultLabel: String): String {
- if (languageTag.isBlank() || languageTag == "system" || languageTag == "auto") return defaultLabel
- val locale = localeForLanguageTag(languageTag)
- if (locale.language.isBlank()) return defaultLabel
- return locale.getDisplayLanguage(Locale.getDefault())
- .replaceFirstChar { character ->
- if (character.isLowerCase()) {
- character.titlecase(Locale.getDefault())
- } else {
- character.toString()
- }
- }
-}
-
internal fun formatDecoderModeLabel(mode: DecoderMode, context: android.content.Context): String {
return when (mode) {
DecoderMode.AUTO -> context.getString(R.string.settings_decoder_auto)
diff --git a/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsLanguageFormatting.kt b/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsLanguageFormatting.kt
new file mode 100644
index 00000000..9abae8c8
--- /dev/null
+++ b/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsLanguageFormatting.kt
@@ -0,0 +1,54 @@
+package com.streamvault.feature.settings.presentation
+
+import com.streamvault.core.ui.localization.localeForLanguageTag
+import com.streamvault.core.ui.localization.supportedAppLanguageTags
+import java.util.Locale
+
+public data class AppLanguageOption(
+ val tag: String,
+ val label: String
+)
+
+public fun supportedAppLanguages(systemDefaultLabel: String): List<AppLanguageOption> {
+ val localeTags = listOf("system") + supportedAppLanguageTags()
+
+ return localeTags.map { tag ->
+ AppLanguageOption(
+ tag = tag,
+ label = if (tag == "system") {
+ systemDefaultLabel
+ } else {
+ val locale = localeForLanguageTag(tag)
+ locale.getDisplayLanguage(locale)
+ .replaceFirstChar { character ->
+ if (character.isLowerCase()) {
+ character.titlecase(locale)
+ } else {
+ character.toString()
+ }
+ }
+ }
+ )
+ }
+}
+
+public fun supportedAudioLanguages(autoLabel: String): List<AppLanguageOption> {
+ return buildList {
+ add(AppLanguageOption(tag = "auto", label = autoLabel))
+ addAll(supportedAppLanguages(autoLabel).filterNot { it.tag == "system" })
+ }
+}
+
+public fun displayLanguageLabel(languageTag: String, defaultLabel: String): String {
+ if (languageTag.isBlank() || languageTag == "system" || languageTag == "auto") return defaultLabel
+ val locale = localeForLanguageTag(languageTag)
+ if (locale.language.isBlank()) return defaultLabel
+ return locale.getDisplayLanguage(Locale.getDefault())
+ .replaceFirstChar { character ->
+ if (character.isLowerCase()) {
+ character.titlecase(Locale.getDefault())
+ } else {
+ character.toString()
+ }
+ }
+}