diff --git a/CHANGELOG.md b/CHANGELOG.md index f9543fa..984a9c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ version in `versions.properties`; versions before 0.28.0 are described in the gi log (one commit per version). Since 0.37.0 Android and iOS share one version and one feature set; the iOS side of each version is in `ios/CHANGELOG.md`. +## 0.41.0 (versionCode 76) + +- **Keep screen on:** a Settings › Interface toggle that stops the screen from + dimming or locking while Sizzle is open (remembered). (iOS has the same in 0.41.0.) + ## 0.40.0 (versionCode 75) - **Sampler One-shot:** a ONE-SHOT toggle at the top of the Sampler editor. On, diff --git a/app/src/main/java/cc/tiredsysadmin/android/sizzle/MainActivity.kt b/app/src/main/java/cc/tiredsysadmin/android/sizzle/MainActivity.kt index f0d0ead..f556d65 100644 --- a/app/src/main/java/cc/tiredsysadmin/android/sizzle/MainActivity.kt +++ b/app/src/main/java/cc/tiredsysadmin/android/sizzle/MainActivity.kt @@ -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 diff --git a/app/src/main/java/cc/tiredsysadmin/android/sizzle/io/SettingsStore.kt b/app/src/main/java/cc/tiredsysadmin/android/sizzle/io/SettingsStore.kt index d342c50..9c62a57 100644 --- a/app/src/main/java/cc/tiredsysadmin/android/sizzle/io/SettingsStore.kt +++ b/app/src/main/java/cc/tiredsysadmin/android/sizzle/io/SettingsStore.kt @@ -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") diff --git a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/AppViewModel.kt b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/AppViewModel.kt index 2c1b948..b0c154c 100644 --- a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/AppViewModel.kt +++ b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/AppViewModel.kt @@ -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 diff --git a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/settings/SettingsScreen.kt b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/settings/SettingsScreen.kt index 0bf5d7e..4ec455f 100644 --- a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/settings/SettingsScreen.kt @@ -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) } } } diff --git a/ios/CHANGELOG.md b/ios/CHANGELOG.md index 4cc534c..bd08ddc 100644 --- a/ios/CHANGELOG.md +++ b/ios/CHANGELOG.md @@ -5,6 +5,11 @@ Sizzle for iOS/iPadOS (`cc.tiredsysadmin.ios.sizzle`). One entry per version in is shared with Android, continuing Android's numbering, and both apps ship the same features; the Android side of each version is in `../CHANGELOG.md`. +## 0.41.0 (build 76) + +- Keep screen on: a Setup › Interface toggle that turns the idle timer off while + Sizzle is open (remembered, and in backups). (Android has the same in 0.41.0.) + ## 0.40.0 (build 75) - Sampler One-shot: a ONE-SHOT toggle above the pad tools (also in the Sampler's diff --git a/ios/app/Host/AppBoot.swift b/ios/app/Host/AppBoot.swift index 19129e5..ca8ae6b 100644 --- a/ios/app/Host/AppBoot.swift +++ b/ios/app/Host/AppBoot.swift @@ -12,6 +12,7 @@ enum AppBoot { let session = SizzleSession.shared session.recordTailBars = settings.recordTailBars ThemeLibrary.shared.select(settings.paletteName) + settings.applyKeepScreenOn() let input = InputController.shared input.app = AppModel.main diff --git a/ios/app/Host/AppSettings.swift b/ios/app/Host/AppSettings.swift index ddd05c4..1249dcb 100644 --- a/ios/app/Host/AppSettings.swift +++ b/ios/app/Host/AppSettings.swift @@ -2,6 +2,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later import Foundation +#if canImport(UIKit) +import UIKit +#endif /// App-level settings that persist across launches (Android's SettingsStore and /// BindingStore). Song, mixer and toolbox settings live in the project instead. @@ -21,6 +24,16 @@ final class AppSettings: ObservableObject { @Published var kbdOctave: Int { didSet { d.set(kbdOctave, forKey: "kbdOctave") } } /// The live meters inside the mixer's volume faders. @Published var vuMeters: Bool { didSet { d.set(vuMeters, forKey: "vuMeters") } } + /// Keep the screen on while Sizzle is in front (the idle timer off). + @Published var keepScreenOn: Bool { + didSet { d.set(keepScreenOn, forKey: "keepScreenOn"); applyKeepScreenOn() } + } + + func applyKeepScreenOn() { + #if canImport(UIKit) + UIApplication.shared.isIdleTimerDisabled = keepScreenOn + #endif + } /// Send MIDI clock, Start/Stop and the sequenced notes to MIDI destinations. @Published var sendMidiClock: Bool { didSet { d.set(sendMidiClock, forKey: "midiClockSend") } } /// Follow an external MIDI clock's tempo and Start/Stop. @@ -45,6 +58,7 @@ final class AppSettings: ObservableObject { kbdChannel = d.object(forKey: "kbdChannel") as? Int ?? 1 kbdOctave = d.object(forKey: "kbdOctave") as? Int ?? 3 vuMeters = d.object(forKey: "vuMeters") as? Bool ?? true + keepScreenOn = d.bool(forKey: "keepScreenOn") sendMidiClock = d.bool(forKey: "midiClockSend") receiveMidiClock = d.bool(forKey: "midiClockRecv") soundModule = d.bool(forKey: "soundModule") @@ -61,7 +75,7 @@ final class AppSettings: ObservableObject { // MARK: Backup text private static let keys = ["palette", "recordTailBars", "kbdChannel", "kbdOctave", "vuMeters", "midiClockSend", - "midiClockRecv", "soundModule", "midiSourcesOff", "bleMidiDevices", "bindKeyboard", + "midiClockRecv", "soundModule", "keepScreenOn", "midiSourcesOff", "bleMidiDevices", "bindKeyboard", "bindGamepad", "bindMidi"] /// Every setting as `key=value` lines; multi-line values (bindings, the source @@ -73,7 +87,7 @@ final class AppSettings: ObservableObject { let text: String switch v { case let a as [String]: text = a.joined(separator: "\n") - case let n as NSNumber where k == "vuMeters" || k.hasPrefix("midiClock") || k == "soundModule": text = n.boolValue ? "true" : "false" + case let n as NSNumber where k == "vuMeters" || k.hasPrefix("midiClock") || k == "soundModule" || k == "keepScreenOn": text = n.boolValue ? "true" : "false" default: text = "\(v)" } lines.append(k + "=" + text.replacingOccurrences(of: "\\", with: "\\\\").replacingOccurrences(of: "\n", with: "\\n")) @@ -100,6 +114,7 @@ final class AppSettings: ObservableObject { if let v = map["midiClockSend"] { sendMidiClock = v == "true" } if let v = map["midiClockRecv"] { receiveMidiClock = v == "true" } if let v = map["soundModule"] { soundModule = v == "true" } + if let v = map["keepScreenOn"] { keepScreenOn = v == "true" } if let v = map["midiSourcesOff"] { midiSourcesOff = Set(v.split(separator: "\n").map(String.init)) } if let v = map["bleMidiDevices"] { bleMidiDevices = Dictionary(v.split(separator: "\n").map { e -> (String, String) in diff --git a/ios/app/Host/Screens/Setup/SetupCards.swift b/ios/app/Host/Screens/Setup/SetupCards.swift index aa252af..6a77629 100644 --- a/ios/app/Host/Screens/Setup/SetupCards.swift +++ b/ios/app/Host/Screens/Setup/SetupCards.swift @@ -62,6 +62,9 @@ struct InterfaceCard: View { SetupCard(title: "Interface", subtitle: "On-screen display options") { SetupToggle(title: "Mixer VU meters", detail: "Show live level meters inside the mixer volume faders.", isOn: settings.vuMeters) { settings.vuMeters = $0 } + SetupDivider() + SetupToggle(title: "Keep screen on", detail: "Don't let the screen dim or lock while Sizzle is open.", + isOn: settings.keepScreenOn) { settings.keepScreenOn = $0 } } } } diff --git a/versions.properties b/versions.properties index b66adfe..1c13e6d 100644 --- a/versions.properties +++ b/versions.properties @@ -12,8 +12,8 @@ # or polish. versionCode is monotonic and bumps by 1 on every release, # because F-Droid and the Android package manager order installs by it alone. -versionName = 0.40.0 -versionCode = 75 +versionName = 0.41.0 +versionCode = 76 # Namespace for every platform: cc.tiredsysadmin..sizzle. Android: # cc.tiredsysadmin.android.sizzle (app/), iOS/iPadOS: cc.tiredsysadmin.ios.sizzle