Auto commit Sun Mar 22 01:01:14 AM CDT 2026

This commit is contained in:
Tretzi
2026-03-22 01:01:14 -05:00
parent 88723bf214
commit ab5f4d5acf
7 changed files with 200 additions and 92 deletions

View File

@@ -7,7 +7,6 @@ import androidx.datastore.preferences.core.intPreferencesKey
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import com.mindmachine.mvp.domain.AppSettings
import com.mindmachine.mvp.domain.SessionMode
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
@@ -19,8 +18,7 @@ class SettingsRepository(private val context: Context) {
val safetyVersion = intPreferencesKey("safety_version")
val countdownPref = stringPreferencesKey("countdown_pref")
val countdownSeconds = intPreferencesKey("countdown_seconds")
val defaultMode = stringPreferencesKey("default_mode")
val showGuidance = booleanPreferencesKey("show_guidance")
val forceAudioWithoutHeadphones = booleanPreferencesKey("force_audio_without_headphones")
val showImmersiveProgressBar = booleanPreferencesKey("show_immersive_progress_bar")
val lastPresetId = stringPreferencesKey("last_preset")
}
@@ -32,8 +30,7 @@ class SettingsRepository(private val context: Context) {
countdownSeconds = p[Keys.countdownSeconds]
?: legacyCountdownStringToSeconds(p[Keys.countdownPref])
?: 5,
defaultModePreference = runCatching { SessionMode.valueOf(p[Keys.defaultMode] ?: "AUDIO_VISUAL") }.getOrDefault(SessionMode.AUDIO_VISUAL),
showHolderGuidanceBeforeSession = p[Keys.showGuidance] ?: false,
forceAudioWithoutHeadphones = p[Keys.forceAudioWithoutHeadphones] ?: false,
showImmersiveProgressBar = p[Keys.showImmersiveProgressBar] ?: true,
lastPresetId = p[Keys.lastPresetId],
)
@@ -50,9 +47,14 @@ class SettingsRepository(private val context: Context) {
it[Keys.countdownSeconds] = value.coerceIn(0, 10)
}
suspend fun updateDefaultMode(value: SessionMode) = context.dataStore.edit { it[Keys.defaultMode] = value.name }
suspend fun updateGuidance(value: Boolean) = context.dataStore.edit { it[Keys.showGuidance] = value }
suspend fun updateShowImmersiveProgressBar(value: Boolean) = context.dataStore.edit { it[Keys.showImmersiveProgressBar] = value }
suspend fun updateForceAudioWithoutHeadphones(value: Boolean) = context.dataStore.edit {
it[Keys.forceAudioWithoutHeadphones] = value
}
suspend fun updateShowImmersiveProgressBar(value: Boolean) = context.dataStore.edit {
it[Keys.showImmersiveProgressBar] = value
}
suspend fun updateLastPreset(id: String) = context.dataStore.edit { it[Keys.lastPresetId] = id }
private fun legacyCountdownStringToSeconds(raw: String?): Int? = when (raw) {