new: add phonetic marker toggle to subtitles preferences

This commit is contained in:
2026-07-06 16:44:18 +02:00
parent 9dc5d27c19
commit 743697202e
11 changed files with 77 additions and 9 deletions
@@ -32,6 +32,10 @@ internal class InMemoryPreferencesRepository : PreferencesRepository {
subtitleState.update { it.copy(textScale = scale) }
}
override suspend fun setShowPhoneticMarkers(enabled: Boolean) {
subtitleState.update { it.copy(showPhoneticMarkers = enabled) }
}
override suspend fun setPlaybackSpeed(speed: Float) {
playbackState.update { it.copy(speed = speed) }
}
@@ -16,6 +16,8 @@ interface PreferencesRepository {
suspend fun setSubtitleTextScale(scale: Float)
suspend fun setShowPhoneticMarkers(enabled: Boolean)
suspend fun setPlaybackSpeed(speed: Float)
suspend fun setBreakBetweenPhrases(duration: Duration)
@@ -1,16 +1,23 @@
package fr.ajaury.gwenedeg.preferences.model
import fr.ajaury.gwenedeg.preferences.model.SubtitlePreferences.Companion.TEXT_SCALE_STEPS
/**
* User preferences controlling the subtitle display on the player.
*
* @property showTranscription whether the Breton (BZH) transcription line is shown.
* @property showTranslation whether the French (FR) translation line is shown.
* @property textScale multiplier applied to the subtitle font size (see [TEXT_SCALE_STEPS]).
* @property showPhoneticMarkers whether the muted `{x}` and liaison `[x]` letters are rendered with
* their pronunciation marks. When off, muted letters read as normal letters and liaison letters are
* replaced by a space.
*/
data class SubtitlePreferences(
val showTranscription: Boolean = true,
val showTranslation: Boolean = true,
val textScale: Float = DEFAULT_TEXT_SCALE,
val showPhoneticMarkers: Boolean = true,
) {
companion object {
const val DEFAULT_TEXT_SCALE = 1f
@@ -20,11 +27,9 @@ data class SubtitlePreferences(
listOf(0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.2f, 1.4f, 1.6f, 1.8f, 2.0f)
/** The next allowed step above [scale], or the maximum when already at the top. */
fun nextTextScale(scale: Float): Float =
TEXT_SCALE_STEPS.firstOrNull { it > scale } ?: TEXT_SCALE_STEPS.last()
fun nextTextScale(scale: Float): Float = TEXT_SCALE_STEPS.firstOrNull { it > scale } ?: TEXT_SCALE_STEPS.last()
/** The previous allowed step below [scale], or the minimum when already at the bottom. */
fun previousTextScale(scale: Float): Float =
TEXT_SCALE_STEPS.lastOrNull { it < scale } ?: TEXT_SCALE_STEPS.first()
fun previousTextScale(scale: Float): Float = TEXT_SCALE_STEPS.lastOrNull { it < scale } ?: TEXT_SCALE_STEPS.first()
}
}
@@ -37,6 +37,8 @@ internal class DataStorePreferencesRepository(
override suspend fun setSubtitleTextScale(scale: Float) = edit { it[SubtitleTextScaleKey] = scale }
override suspend fun setShowPhoneticMarkers(enabled: Boolean) = edit { it[ShowPhoneticMarkersKey] = enabled }
override suspend fun setPlaybackSpeed(speed: Float) = edit { it[PlaybackSpeedKey] = speed }
override suspend fun setBreakBetweenPhrases(duration: Duration) =
@@ -52,6 +54,7 @@ internal class DataStorePreferencesRepository(
showTranscription = this[ShowTranscriptionKey] ?: defaults.showTranscription,
showTranslation = this[ShowTranslationKey] ?: defaults.showTranslation,
textScale = this[SubtitleTextScaleKey] ?: defaults.textScale,
showPhoneticMarkers = this[ShowPhoneticMarkersKey] ?: defaults.showPhoneticMarkers,
)
}
@@ -66,6 +69,7 @@ internal class DataStorePreferencesRepository(
val ShowTranscriptionKey = booleanPreferencesKey("show_transcription")
val ShowTranslationKey = booleanPreferencesKey("show_translation")
val SubtitleTextScaleKey = floatPreferencesKey("subtitle_text_scale")
val ShowPhoneticMarkersKey = booleanPreferencesKey("show_phonetic_marker")
val PlaybackSpeedKey = floatPreferencesKey("playback_speed")
val BreakBetweenPhrasesSecondsKey = intPreferencesKey("break_between_phrases_seconds")
}
@@ -11,6 +11,8 @@
<string name="subtitle_text_size_label">Ment an destenn</string>
<string name="subtitle_text_size_decrease">Bihanaat ment an destenn</string>
<string name="subtitle_text_size_increase">Brasaat ment an destenn</string>
<string name="subtitle_marked_letters_label">Merkoù distagañ</string>
<string name="subtitle_marked_letters_description">Diskouez ar c\'hensonennoù mut ha al liammoù</string>
<string name="playback_speed_title">Tizh al lenn</string>
<string name="playback_settings_action">Arventennoù al lenn</string>
@@ -11,6 +11,8 @@
<string name="subtitle_text_size_label">Taille du texte</string>
<string name="subtitle_text_size_decrease">Réduire la taille du texte</string>
<string name="subtitle_text_size_increase">Augmenter la taille du texte</string>
<string name="subtitle_marked_letters_label">Marques de prononciation</string>
<string name="subtitle_marked_letters_description">Afficher les consonnes muettes et les liaisons</string>
<string name="playback_speed_title">Vitesse de lecture</string>
<string name="playback_settings_action">Réglages de lecture</string>