0.41.0 (76): Keep screen on toggle (Android and iOS)
Settings › Interface: Android sets FLAG_KEEP_SCREEN_ON on the window, iOS turns the idle timer off; persisted (and in iOS backups). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6939dccbf0
commit
cdabf3018b
@@ -83,6 +83,12 @@ class MainActivity : ComponentActivity() {
|
||||
SizzleTheme(palette = viewModel.palette) {
|
||||
SizzleAppUi(viewModel)
|
||||
}
|
||||
// "Keep screen on" (Settings › Interface): the window's flag follows the setting.
|
||||
val keepOn = viewModel.keepScreenOn
|
||||
androidx.compose.runtime.LaunchedEffect(keepOn) {
|
||||
if (keepOn) window.addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
else window.clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
}
|
||||
|
||||
// Hold the MIDI ports (USB, Bluetooth, other apps' virtual devices) for the
|
||||
|
||||
@@ -30,6 +30,8 @@ data class AppSettings(
|
||||
val kbdOctave: Int = 3,
|
||||
/** Show the live VU meters inside the mixer volume faders. */
|
||||
val vuMeters: Boolean = true,
|
||||
/** Keep the screen on while Sizzle is in front. */
|
||||
val keepScreenOn: Boolean = false,
|
||||
/** Send MIDI clock + start/stop to attached MIDI devices (drive external gear). */
|
||||
val sendMidiClock: Boolean = false,
|
||||
/** Follow an external MIDI clock's tempo + start/stop. */
|
||||
@@ -63,6 +65,7 @@ class SettingsStore(private val context: Context) {
|
||||
kbdChannel = prefs[KBD_CHANNEL] ?: 0,
|
||||
kbdOctave = prefs[KBD_OCTAVE] ?: 3,
|
||||
vuMeters = prefs[VU_METERS] ?: true,
|
||||
keepScreenOn = prefs[KEEP_SCREEN_ON] ?: false,
|
||||
sendMidiClock = prefs[MIDI_CLOCK_SEND] ?: false,
|
||||
receiveMidiClock = prefs[MIDI_CLOCK_RECV] ?: false,
|
||||
soundModule = prefs[SOUND_MODULE] ?: false,
|
||||
@@ -102,6 +105,11 @@ class SettingsStore(private val context: Context) {
|
||||
context.settingsDataStore.edit { prefs -> prefs[VU_METERS] = enabled }
|
||||
}
|
||||
|
||||
/** Persist "Keep screen on". */
|
||||
suspend fun saveKeepScreenOn(enabled: Boolean) {
|
||||
context.settingsDataStore.edit { prefs -> prefs[KEEP_SCREEN_ON] = enabled }
|
||||
}
|
||||
|
||||
/** Persist the MIDI-clock send / receive toggles. */
|
||||
suspend fun saveMidiClock(send: Boolean, receive: Boolean) {
|
||||
context.settingsDataStore.edit { prefs ->
|
||||
@@ -132,6 +140,7 @@ class SettingsStore(private val context: Context) {
|
||||
val KBD_CHANNEL = intPreferencesKey("kbdChannel")
|
||||
val KBD_OCTAVE = intPreferencesKey("kbdOctave")
|
||||
val VU_METERS = booleanPreferencesKey("vuMeters")
|
||||
val KEEP_SCREEN_ON = booleanPreferencesKey("keepScreenOn")
|
||||
val MIDI_CLOCK_SEND = booleanPreferencesKey("midiClockSend")
|
||||
val MIDI_CLOCK_RECV = booleanPreferencesKey("midiClockRecv")
|
||||
val SOUND_MODULE = booleanPreferencesKey("soundModule")
|
||||
|
||||
@@ -117,6 +117,15 @@ class AppViewModel(
|
||||
/** Whether the mixer's fader VU meters are shown (Settings toggle). */
|
||||
var vuMeters by mutableStateOf(true); private set
|
||||
|
||||
/** Keep the screen on while Sizzle is in front (Settings toggle). */
|
||||
var keepScreenOn by mutableStateOf(false); private set
|
||||
|
||||
fun updateKeepScreenOn(enabled: Boolean) {
|
||||
keepScreenOn = enabled
|
||||
viewModelScope.launch { settingsStore.saveKeepScreenOn(enabled) }
|
||||
touched()
|
||||
}
|
||||
|
||||
/** Enable/disable the mixer fader VU meters and persist the choice. */
|
||||
fun updateVuMeters(enabled: Boolean) {
|
||||
vuMeters = enabled
|
||||
@@ -1098,6 +1107,7 @@ class AppViewModel(
|
||||
kbdChannel = s.kbdChannel.coerceIn(0, Cell.MAX_CHANNEL)
|
||||
kbdOctave = s.kbdOctave.coerceIn(0, 8)
|
||||
vuMeters = s.vuMeters
|
||||
keepScreenOn = s.keepScreenOn
|
||||
|
||||
// MIDI clock sync: the transport/tempo follow and the send thread's
|
||||
// providers are wired in SizzleApp (they must work with no UI); here we
|
||||
|
||||
@@ -685,6 +685,12 @@ private fun InterfaceCard(vm: AppViewModel) {
|
||||
"Show live level meters inside the mixer volume faders.",
|
||||
vm.vuMeters,
|
||||
) { vm.updateVuMeters(it) }
|
||||
HorizontalDivider()
|
||||
ToggleRow(
|
||||
"Keep screen on",
|
||||
"Don't let the screen dim or lock while Sizzle is open.",
|
||||
vm.keepScreenOn,
|
||||
) { vm.updateKeepScreenOn(it) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user