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:
Reactorcoremeltdown
2026-11-17 20:15:46 +01:00
co-authored by Claude Opus 5.5
parent 6939dccbf0
commit cdabf3018b
10 changed files with 64 additions and 4 deletions
+17 -2
View File
@@ -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