taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit eb9f01ffd059c91e2b3ce4e2443c38c52f53aa32
parent d8d53cb97bc7569a025fa57210bd9107fda1f7c0
Author: Marc Stibane <marc@taler.net>
Date:   Wed,  3 Jan 2024 17:38:02 +0100

remove Apple Sounds

Diffstat:
MTalerWallet1/Controllers/Controller.swift | 3++-
MTalerWallet1/Helper/Controller+playSound.swift | 4++--
MTalerWallet1/Views/Main/MainView.swift | 7+++++--
MTalerWallet1/Views/Settings/SettingsView.swift | 14++++++++++++--
4 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/TalerWallet1/Controllers/Controller.swift b/TalerWallet1/Controllers/Controller.swift @@ -37,7 +37,8 @@ class Controller: ObservableObject { @Published var backendState: BackendState = .none // only used for launch animation @Published var currencyTicker: Int = 0 // updates whenever a new currency is added @AppStorage("useHaptics") var useHaptics: Bool = true // extension mustn't define this, so it must be here - @AppStorage("playSounds") var playSounds: Int = 1 // extension mustn't define this, so it must be here + @AppStorage("playSoundsI") var playSoundsI: Int = 1 // extension mustn't define this, so it must be here + @AppStorage("playSoundsB") var playSoundsB: Bool = true @AppStorage("talerFont") var talerFont: Int = 0 // extension mustn't define this, so it must be here let hapticCapability = CHHapticEngine.capabilitiesForHardware() let logger = Logger(subsystem: "net.taler.gnu", category: "Controller") diff --git a/TalerWallet1/Helper/Controller+playSound.swift b/TalerWallet1/Helper/Controller+playSound.swift @@ -55,9 +55,9 @@ extension Controller { AudioServicesCreateSystemSoundID(fileURL as CFURL, &soundID) logger.log("\(sound, privacy: .public) \(soundID)") } - if number == 0 || number > 9 || playSounds < 0 { + if number == 0 || number > 9 || playSoundsI < 0 { AudioServicesPlaySystemSound(soundID); - } else if playSounds > 0 { + } else if playSoundsI > 0 && playSoundsB { if let url = Bundle.main.url(forResource: (number == 1) ? "payment_sent" : "payment_received", withExtension: "m4a") { diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -23,7 +23,8 @@ struct MainView: View { @EnvironmentObject private var viewState: ViewState // popToRootView() @EnvironmentObject private var controller: Controller @AppStorage("talerFont") var talerFont: Int = 0 // extension mustn't define this, so it must be here - @AppStorage("playSounds") var playSounds: Int = 1 // extension mustn't define this, so it must be here + @AppStorage("playSoundsI") var playSoundsI: Int = 1 // extension mustn't define this, so it must be here + @AppStorage("playSoundsB") var playSoundsB: Bool = true @State private var sheetPresented = false @State private var urlToOpen: URL? = nil @@ -42,9 +43,11 @@ struct MainView: View { // any change to rootViewId triggers popToRootView behaviour .id(viewState.rootViewId) .onAppear() { - if playSounds != 0 && !soundPlayed { +#if DEBUG + if playSoundsI != 0 && playSoundsB && !soundPlayed { controller.playSound(1008) // Startup chime } +#endif soundPlayed = true } } else if controller.backendState == .error { diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift @@ -29,7 +29,8 @@ struct SettingsView: View { @AppStorage("developerMode") var developerMode: Bool = false #endif @AppStorage("useHaptics") var useHaptics: Bool = true - @AppStorage("playSounds") var playSounds: Int = 1 + @AppStorage("playSoundsI") var playSoundsI: Int = 1 + @AppStorage("playSoundsB") var playSoundsB: Bool = true @AppStorage("talerFont") var talerFont: Int = 0 @AppStorage("developDelay") var developDelay: Bool = false @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic @@ -113,11 +114,20 @@ struct SettingsView: View { description: hideDescriptions ? nil : String(localized: "Vibration Feedback")) .id("playHaptics") } - SettingsSpeaker(name: String(localized: "Play Payment Sounds"), value: $playSounds, + let playToggle = SettingsToggle(name: String(localized: "Play Payment Sounds"), value: $playSoundsB, + description: hideDescriptions ? nil : String(localized: "When a transaction finished")) + .id("playSounds") +#if DEBUG + if Double.random(in: -100.0...100.0) > 0 { + SettingsSpeaker(name: String(localized: "Play Payment Sounds"), value: $playSoundsI, description: hideDescriptions ? nil : String(localized: "When a transaction finished")) .id("playSounds") SettingsFont(title: String(localized: "Font:"), value: talerFont, action: redraw) .id("font") + } else { playToggle } +#else + playToggle +#endif SettingsStyle(title: String(localized: "Liststyle:"), myListStyle: $myListStyle) .id("liststyle") SettingsToggle(name: String(localized: "Minimalistic"), value: $iconOnly, id1: "minimal",