@@ -114,6 +114,26 @@ open class SettingsRepository(
114114 private val SUPER_LYRIC_API_CLEAR_ON_PAUSE =
115115 booleanPreferencesKey(" super_lyric_api_clear_on_pause" )
116116
117+ // Lyricon API keys
118+ private val LYRICON_API_ENABLED = booleanPreferencesKey(" lyricon_api_enabled" )
119+ private val LYRICON_API_ENABLE_WORD_BY_WORD = booleanPreferencesKey(" lyricon_api_enable_word_by_word" )
120+ private val LYRICON_API_SCROLLING_TRUNCATE_ENABLED =
121+ booleanPreferencesKey(" lyricon_api_scrolling_truncate_enabled" )
122+ private val LYRICON_API_MAX_DISPLAY_UNITS =
123+ intPreferencesKey(" lyricon_api_max_display_units" )
124+ private val LYRICON_API_SMART_UNITS_ENABLED =
125+ booleanPreferencesKey(" lyricon_api_smart_units_enabled" )
126+ private val LYRICON_API_SHOW_TIMESTAMP =
127+ booleanPreferencesKey(" lyricon_api_show_timestamp" )
128+ private val LYRICON_API_DISPLAY_STATES =
129+ stringSetPreferencesKey(" lyricon_api_display_states" )
130+ private val LYRICON_API_CLEAR_ON_PAUSE =
131+ booleanPreferencesKey(" lyricon_api_clear_on_pause" )
132+ private val LYRICON_API_DISPLAY_TRANSLATION =
133+ booleanPreferencesKey(" lyricon_api_display_translation" )
134+ private val LYRICON_API_DISPLAY_ROMA =
135+ booleanPreferencesKey(" lyricon_api_display_roma" )
136+
117137 open val activeScriptIdFlow: Flow <String ?> =
118138 context.dataStore.data
119139 .map { preferences -> preferences[ACTIVE_SCRIPT_ID ] }
@@ -384,6 +404,27 @@ open class SettingsRepository(
384404 )
385405 }
386406
407+ open val lyriconApiSettingsFlow:
408+ Flow < org.parallel_sekai.kanade.data.model.LyriconApiSettings > =
409+ context.dataStore.data
410+ .map { preferences ->
411+ org.parallel_sekai.kanade.data.model.LyriconApiSettings (
412+ enabled = preferences[LYRICON_API_ENABLED ] ? : true ,
413+ enableWordByWord = preferences[LYRICON_API_ENABLE_WORD_BY_WORD ] ? : true ,
414+ scrollingTruncateEnabled =
415+ preferences[LYRICON_API_SCROLLING_TRUNCATE_ENABLED ] ? : false ,
416+ maxDisplayUnits = preferences[LYRICON_API_MAX_DISPLAY_UNITS ] ? : 40 ,
417+ smartUnitsEnabled = preferences[LYRICON_API_SMART_UNITS_ENABLED ] ? : true ,
418+ showTimestamp = preferences[LYRICON_API_SHOW_TIMESTAMP ] ? : false ,
419+ displayStates =
420+ preferences[LYRICON_API_DISPLAY_STATES ]?.mapNotNull { it.toIntOrNull() }?.toSet()
421+ ? : setOf (0 , 1 , 2 ),
422+ clearOnPause = preferences[LYRICON_API_CLEAR_ON_PAUSE ] ? : true ,
423+ displayTranslation = preferences[LYRICON_API_DISPLAY_TRANSLATION ] ? : true ,
424+ displayRoma = preferences[LYRICON_API_DISPLAY_ROMA ] ? : false ,
425+ )
426+ }
427+
387428 open suspend fun updateRepeatMode (mode : Int ) {
388429 context.dataStore.edit { preferences ->
389430 preferences[REPEAT_MODE ] = mode
@@ -567,4 +608,67 @@ open class SettingsRepository(
567608 preferences[SUPER_LYRIC_API_CLEAR_ON_PAUSE ] = enabled
568609 }
569610 }
611+
612+ // Lyricon API update methods
613+ open suspend fun updateLyriconApiEnabled (enabled : Boolean ) {
614+ context.dataStore.edit { preferences ->
615+ preferences[LYRICON_API_ENABLED ] = enabled
616+ }
617+ }
618+
619+ open suspend fun updateLyriconApiEnableWordByWord (enabled : Boolean ) {
620+ context.dataStore.edit { preferences ->
621+ preferences[LYRICON_API_ENABLE_WORD_BY_WORD ] = enabled
622+ }
623+ }
624+
625+ open suspend fun updateLyriconApiScrollingTruncateEnabled (enabled : Boolean ) {
626+ context.dataStore.edit { preferences ->
627+ preferences[LYRICON_API_SCROLLING_TRUNCATE_ENABLED ] = enabled
628+ }
629+ }
630+
631+ open suspend fun updateLyriconApiMaxDisplayUnits (units : Int ) {
632+ context.dataStore.edit { preferences ->
633+ preferences[LYRICON_API_MAX_DISPLAY_UNITS ] = units.coerceIn(3 , 120 )
634+ }
635+ }
636+
637+ open suspend fun updateLyriconApiSmartUnitsEnabled (enabled : Boolean ) {
638+ context.dataStore.edit { preferences ->
639+ preferences[LYRICON_API_SMART_UNITS_ENABLED ] = enabled
640+ }
641+ }
642+
643+ open suspend fun updateLyriconApiShowTimestamp (enabled : Boolean ) {
644+ context.dataStore.edit { preferences ->
645+ preferences[LYRICON_API_SHOW_TIMESTAMP ] = enabled
646+ }
647+ }
648+
649+ open suspend fun updateLyriconApiDisplayStates (states : Set <Int >) {
650+ context.dataStore.edit { preferences ->
651+ val validStates = states.filter { it in 0 .. 2 }.toSet()
652+ val finalStates = if (validStates.isEmpty()) setOf (0 ) else validStates
653+ preferences[LYRICON_API_DISPLAY_STATES ] = finalStates.map { it.toString() }.toSet()
654+ }
655+ }
656+
657+ open suspend fun updateLyriconApiClearOnPause (enabled : Boolean ) {
658+ context.dataStore.edit { preferences ->
659+ preferences[LYRICON_API_CLEAR_ON_PAUSE ] = enabled
660+ }
661+ }
662+
663+ open suspend fun updateLyriconApiDisplayTranslation (enabled : Boolean ) {
664+ context.dataStore.edit { preferences ->
665+ preferences[LYRICON_API_DISPLAY_TRANSLATION ] = enabled
666+ }
667+ }
668+
669+ open suspend fun updateLyriconApiDisplayRoma (enabled : Boolean ) {
670+ context.dataStore.edit { preferences ->
671+ preferences[LYRICON_API_DISPLAY_ROMA ] = enabled
672+ }
673+ }
570674}
0 commit comments