Files
ReactorcoremeltdownandClaude Opus 5.5 cdabf3018b 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>
2026-11-17 20:15:46 +01:00

43 lines
1.7 KiB
Swift

// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
import SwiftUI
/// Everything that runs once at launch, before any screen (Android's SizzleApp):
/// settings that live outside the song, MIDI, and the hardware input sources.
@MainActor
enum AppBoot {
static func start() {
let settings = AppSettings.shared
let session = SizzleSession.shared
session.recordTailBars = settings.recordTailBars
ThemeLibrary.shared.select(settings.paletteName)
settings.applyKeepScreenOn()
let input = InputController.shared
input.app = AppModel.main
input.start()
HardwareInput.shared.start()
let midi = SizzleMidi.shared
midi.sendClock = settings.sendMidiClock
midi.receiveClock = settings.receiveMidiClock
midi.soundModule = settings.soundModule
midi.onNote = { on, ch, note, vel in input.midiNote(on: on, channel: ch, note: note, velocity: vel) }
midi.onControl = { cc, value in input.midiControl(cc, value) }
midi.start(withDisabledKeys: settings.midiSourcesOff)
BluetoothMidi.shared.reconnectRemembered()
}
/// Leaving the foreground: save, and unless Sizzle stays on as a sound module
/// (or is playing / recording), pause the audio so iOS can suspend the app.
static func background() {
let session = SizzleSession.shared
session.autosave()
let busy = session.isPlaying || session.masterRecording || SampleRecorder.shared.isRecording
if !AppSettings.shared.soundModule && !busy { session.audioSuspended = true }
}
static func foreground() { SizzleSession.shared.audioSuspended = false }
}