mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 07:29:14 +01:00
settings: add the replay gain controls
Final slice: the screen that drives the mode and preamp preferences the playback side already reads. Until now `setReplayGainMode` and `setReplayGainPreampDb` had no production caller, so Off and the preamp were unreachable. - `SettingsViewModel` exposes both preferences and writes them back. - The Playback section gains a "Replay gain" row opening an Off / Track / Album choice, and a "Preamp" row opening a slider across the +-15 dB range in 0.5 dB steps. - `ReplayGainMode` is ordered Off, Track, Album so the choice list reads that way; the stored value is the name, so the order is not persisted and the default is still Track. - The labels live in their own file so the signed decibel formatting can be tested, as `formatTrackTime` does.
This commit is contained in:
@@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope
|
||||
import com.subtracks.data.model.Source
|
||||
import com.subtracks.data.net.NetworkMode
|
||||
import com.subtracks.data.prefs.DEFAULT_SYNC_INTERVAL_MINUTES
|
||||
import com.subtracks.data.prefs.ReplayGainMode
|
||||
import com.subtracks.data.prefs.StreamQuality
|
||||
import com.subtracks.data.prefs.SyncMode
|
||||
import com.subtracks.data.prefs.UserPreferences
|
||||
@@ -65,6 +66,16 @@ class SettingsViewModel(
|
||||
.scrobbling()
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), true)
|
||||
|
||||
val replayGainMode: StateFlow<ReplayGainMode> =
|
||||
userPreferences
|
||||
.replayGainMode()
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), ReplayGainMode.Track)
|
||||
|
||||
val replayGainPreamp: StateFlow<Float> =
|
||||
userPreferences
|
||||
.replayGainPreampDb()
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), 0f)
|
||||
|
||||
val offline: StateFlow<Boolean> = sourceRepository.offline
|
||||
|
||||
val verboseLogging: StateFlow<Boolean> =
|
||||
@@ -115,4 +126,12 @@ class SettingsViewModel(
|
||||
fun setScrobbling(enabled: Boolean) {
|
||||
viewModelScope.launch { userPreferences.setScrobbling(enabled) }
|
||||
}
|
||||
|
||||
fun setReplayGainMode(mode: ReplayGainMode) {
|
||||
viewModelScope.launch { userPreferences.setReplayGainMode(mode) }
|
||||
}
|
||||
|
||||
fun setReplayGainPreamp(value: Float) {
|
||||
viewModelScope.launch { userPreferences.setReplayGainPreampDb(value) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user