Просмотр исходного кода

remove playSoundIfNeeded for Low and High Glucose and Low Carb notifications

kskandis 1 год назад
Родитель
Сommit
02fdb71b18

+ 0 - 1
Trio/Resources/json/defaults/freeaps/freeaps_settings.json

@@ -14,7 +14,6 @@
   "displayCalendarIOBandCOB" : false,
   "displayCalendarIOBandCOB" : false,
   "glucoseBadge" : false,
   "glucoseBadge" : false,
   "glucoseNotificationsAlways" : false,
   "glucoseNotificationsAlways" : false,
-  "useAlarmSound" : false,
   "addSourceInfoToGlucoseNotifications" : false,
   "addSourceInfoToGlucoseNotifications" : false,
   "lowGlucose" : 72,
   "lowGlucose" : 72,
   "highGlucose" : 270,
   "highGlucose" : 270,

+ 2 - 3
Trio/Sources/Localizations/Main/Localizable.xcstrings

@@ -25304,9 +25304,6 @@
         }
         }
       }
       }
     },
     },
-    "Alarm with every Trio notification." : {
-
-    },
     "Alarms" : {
     "Alarms" : {
       "extractionState" : "manual",
       "extractionState" : "manual",
       "localizations" : {
       "localizations" : {
@@ -122493,6 +122490,7 @@
 
 
     },
     },
     "Play Alarm Sound" : {
     "Play Alarm Sound" : {
+      "extractionState" : "stale",
       "localizations" : {
       "localizations" : {
         "ar" : {
         "ar" : {
           "stringUnit" : {
           "stringUnit" : {
@@ -161629,6 +161627,7 @@
       }
       }
     },
     },
     "This will cause a sound to be triggered by Trio notifications for Carbs Required, and Glucose Low/High Alarms." : {
     "This will cause a sound to be triggered by Trio notifications for Carbs Required, and Glucose Low/High Alarms." : {
+      "extractionState" : "stale",
       "localizations" : {
       "localizations" : {
         "ar" : {
         "ar" : {
           "stringUnit" : {
           "stringUnit" : {

+ 0 - 5
Trio/Sources/Models/TrioSettings.swift

@@ -35,7 +35,6 @@ struct TrioSettings: JSON, Equatable {
     var notificationsCarb: Bool = true
     var notificationsCarb: Bool = true
     var notificationsAlgorithm: Bool = true
     var notificationsAlgorithm: Bool = true
     var glucoseNotificationsOption: GlucoseNotificationsOption = .onlyAlarmLimits
     var glucoseNotificationsOption: GlucoseNotificationsOption = .onlyAlarmLimits
-    var useAlarmSound: Bool = false
     var addSourceInfoToGlucoseNotifications: Bool = false
     var addSourceInfoToGlucoseNotifications: Bool = false
     var lowGlucose: Decimal = 72
     var lowGlucose: Decimal = 72
     var highGlucose: Decimal = 270
     var highGlucose: Decimal = 270
@@ -207,10 +206,6 @@ extension TrioSettings: Decodable {
             settings.glucoseNotificationsOption = glucoseNotificationsOption
             settings.glucoseNotificationsOption = glucoseNotificationsOption
         }
         }
 
 
-        if let useAlarmSound = try? container.decode(Bool.self, forKey: .useAlarmSound) {
-            settings.useAlarmSound = useAlarmSound
-        }
-
         if let addSourceInfoToGlucoseNotifications = try? container.decode(
         if let addSourceInfoToGlucoseNotifications = try? container.decode(
             Bool.self,
             Bool.self,
             forKey: .addSourceInfoToGlucoseNotifications
             forKey: .addSourceInfoToGlucoseNotifications

+ 0 - 2
Trio/Sources/Modules/GlucoseNotificationSettings/GlucoseNotificationSettingsStateModel.swift

@@ -4,7 +4,6 @@ extension GlucoseNotificationSettings {
     final class StateModel: BaseStateModel<Provider> {
     final class StateModel: BaseStateModel<Provider> {
         @Published var glucoseBadge = false
         @Published var glucoseBadge = false
         @Published var glucoseNotificationsOption: GlucoseNotificationsOption = .onlyAlarmLimits
         @Published var glucoseNotificationsOption: GlucoseNotificationsOption = .onlyAlarmLimits
-        @Published var useAlarmSound = false
         @Published var addSourceInfoToGlucoseNotifications = false
         @Published var addSourceInfoToGlucoseNotifications = false
         @Published var lowGlucose: Decimal = 0
         @Published var lowGlucose: Decimal = 0
         @Published var highGlucose: Decimal = 0
         @Published var highGlucose: Decimal = 0
@@ -27,7 +26,6 @@ extension GlucoseNotificationSettings {
 
 
             subscribeSetting(\.glucoseBadge, on: $glucoseBadge) { glucoseBadge = $0 }
             subscribeSetting(\.glucoseBadge, on: $glucoseBadge) { glucoseBadge = $0 }
             subscribeSetting(\.glucoseNotificationsOption, on: $glucoseNotificationsOption) { glucoseNotificationsOption = $0 }
             subscribeSetting(\.glucoseNotificationsOption, on: $glucoseNotificationsOption) { glucoseNotificationsOption = $0 }
-            subscribeSetting(\.useAlarmSound, on: $useAlarmSound) { useAlarmSound = $0 }
             subscribeSetting(\.addSourceInfoToGlucoseNotifications, on: $addSourceInfoToGlucoseNotifications) {
             subscribeSetting(\.addSourceInfoToGlucoseNotifications, on: $addSourceInfoToGlucoseNotifications) {
                 addSourceInfoToGlucoseNotifications = $0 }
                 addSourceInfoToGlucoseNotifications = $0 }
 
 

+ 0 - 22
Trio/Sources/Modules/GlucoseNotificationSettings/View/GlucoseNotificationSettingsRootView.swift

@@ -42,28 +42,6 @@ extension GlucoseNotificationSettings {
             List {
             List {
                 SettingInputSection(
                 SettingInputSection(
                     decimalValue: $decimalPlaceholder,
                     decimalValue: $decimalPlaceholder,
-                    booleanValue: $state.useAlarmSound,
-                    shouldDisplayHint: $shouldDisplayHint,
-                    selectedVerboseHint: Binding(
-                        get: { selectedVerboseHint },
-                        set: {
-                            selectedVerboseHint = $0.map { AnyView($0) }
-                            hintLabel = String(localized: "Play Alarm Sound")
-                        }
-                    ),
-                    units: state.units,
-                    type: .boolean,
-                    label: String(localized: "Play Alarm Sound"),
-                    miniHint: String(localized: "Alarm with every Trio notification."),
-                    verboseHint: VStack(alignment: .leading, spacing: 10) {
-                        Text("Default: OFF").bold()
-                        Text(
-                            "This will cause a sound to be triggered by Trio notifications for Carbs Required, and Glucose Low/High Alarms."
-                        )
-                    }
-                )
-                SettingInputSection(
-                    decimalValue: $decimalPlaceholder,
                     booleanValue: $state.notificationsPump,
                     booleanValue: $state.notificationsPump,
                     shouldDisplayHint: $shouldDisplayHint,
                     shouldDisplayHint: $shouldDisplayHint,
                     selectedVerboseHint: Binding(
                     selectedVerboseHint: Binding(

+ 0 - 1
Trio/Sources/Modules/Settings/SettingItems.swift

@@ -233,7 +233,6 @@ enum SettingItems {
             title: "Trio Notifications",
             title: "Trio Notifications",
             view: .glucoseNotificationSettings,
             view: .glucoseNotificationSettings,
             searchContents: [
             searchContents: [
-                "Play Alarm Sound",
                 "Always Notify Pump",
                 "Always Notify Pump",
                 "Always Notify CGM",
                 "Always Notify CGM",
                 "Always Notify Carb",
                 "Always Notify Carb",

+ 1 - 1
Trio/Sources/Modules/Snooze/View/SnoozeRootView.swift

@@ -90,7 +90,7 @@ extension Snooze {
                     state.snoozeUntilDate = untilDate < Date() ? .distantPast : untilDate
                     state.snoozeUntilDate = untilDate < Date() ? .distantPast : untilDate
                     debug(.default, "will snooze for \(snoozeFor) until \(dateFormatter.string(from: untilDate))")
                     debug(.default, "will snooze for \(snoozeFor) until \(dateFormatter.string(from: untilDate))")
                     snoozeDescription = getSnoozeDescription()
                     snoozeDescription = getSnoozeDescription()
-                    BaseUserNotificationsManager.stopSound()
+//                    BaseUserNotificationsManager.stopSound()
                     state.hideModal()
                     state.hideModal()
                 } label: {
                 } label: {
                     Text("Click to Snooze Alerts")
                     Text("Click to Snooze Alerts")

+ 0 - 26
Trio/Sources/Services/UserNotifications/UserNotificationsManager.swift

@@ -169,7 +169,6 @@ final class BaseUserNotificationsManager: NSObject, UserNotificationsManager, In
             return
             return
         }
         }
         content.sound = .default
         content.sound = .default
-        playSoundIfNeeded()
 
 
         titles.append(String(format: String(localized: "Carbs required: %d g", comment: "Carbs required"), carbs))
         titles.append(String(format: String(localized: "Carbs required: %d g", comment: "Carbs required"), carbs))
 
 
@@ -309,7 +308,6 @@ final class BaseUserNotificationsManager: NSObject, UserNotificationsManager, In
                 content.body = body
                 content.body = body
 
 
                 if notificationAlarm {
                 if notificationAlarm {
-                    playSoundIfNeeded()
                     content.sound = .default
                     content.sound = .default
                     content.userInfo[NotificationAction.key] = NotificationAction.snooze.rawValue
                     content.userInfo[NotificationAction.key] = NotificationAction.snooze.rawValue
                 }
                 }
@@ -452,30 +450,6 @@ final class BaseUserNotificationsManager: NSObject, UserNotificationsManager, In
         }
         }
     }
     }
 
 
-    private func playSoundIfNeeded() {
-        guard settingsManager.settings.useAlarmSound, snoozeUntilDate < Date() else { return }
-        Self.stopPlaying = false
-        playSound()
-    }
-
-    static let soundID: UInt32 = 1336
-    private static var stopPlaying = false
-
-    private func playSound(times: Int = 1) {
-        guard times > 0, !Self.stopPlaying else {
-            return
-        }
-
-        AudioServicesPlaySystemSoundWithCompletion(Self.soundID) {
-            self.playSound(times: times - 1)
-        }
-    }
-
-    static func stopSound() {
-        stopPlaying = true
-        AudioServicesDisposeSystemSoundID(soundID)
-    }
-
     private var glucoseFormatter: NumberFormatter {
     private var glucoseFormatter: NumberFormatter {
         let formatter = NumberFormatter()
         let formatter = NumberFormatter()
         formatter.numberStyle = .decimal
         formatter.numberStyle = .decimal