Procházet zdrojové kódy

Snooze on logh tap on glucose view

Ivan Valkou před 4 roky
rodič
revize
ea4b76de88
21 změnil soubory, kde provedl 145 přidání a 5 odebrání
  1. 7 0
      FreeAPS/Sources/Localizations/Main/ar.lproj/Localizable.strings
  2. 7 0
      FreeAPS/Sources/Localizations/Main/ca.lproj/Localizable.strings
  3. 7 0
      FreeAPS/Sources/Localizations/Main/da.lproj/Localizable.strings
  4. 7 0
      FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings
  5. 6 0
      FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings
  6. 7 0
      FreeAPS/Sources/Localizations/Main/es.lproj/Localizable.strings
  7. 7 0
      FreeAPS/Sources/Localizations/Main/fi.lproj/Localizable.strings
  8. 7 0
      FreeAPS/Sources/Localizations/Main/fr.lproj/Localizable.strings
  9. 7 0
      FreeAPS/Sources/Localizations/Main/he.lproj/Localizable.strings
  10. 6 0
      FreeAPS/Sources/Localizations/Main/it.lproj/Localizable.strings
  11. 5 0
      FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings
  12. 6 0
      FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings
  13. 7 0
      FreeAPS/Sources/Localizations/Main/pl.lproj/Localizable.strings
  14. 7 0
      FreeAPS/Sources/Localizations/Main/pt-BR.lproj/Localizable.strings
  15. 7 0
      FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings
  16. 7 0
      FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings
  17. 7 0
      FreeAPS/Sources/Localizations/Main/tr.lproj/Localizable.strings
  18. 7 0
      FreeAPS/Sources/Localizations/Main/uk.lproj/Localizable.strings
  19. 7 0
      FreeAPS/Sources/Localizations/Main/zh-Hans.lproj/Localizable.strings
  20. 1 1
      FreeAPS/Sources/Modules/Snooze/View/SnoozeRootView.swift
  21. 16 4
      FreeAPS/Sources/Services/UserNotifiactions/UserNotificationsManager.swift

+ 7 - 0
FreeAPS/Sources/Localizations/Main/ar.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/ca.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/da.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

+ 6 - 0
FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings

@@ -818,6 +818,12 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/es.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/fi.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/fr.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/he.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

+ 6 - 0
FreeAPS/Sources/Localizations/Main/it.lproj/Localizable.strings

@@ -817,6 +817,12 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
 
 
 /* Headers for settings ------------------- */

+ 5 - 0
FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings

@@ -817,7 +817,12 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
 
+/* */
+"Also add source info" = "Also add source info";
 
 /* Headers for settings ------------------- */
 

+ 6 - 0
FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings

@@ -817,6 +817,12 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/pl.lproj/Localizable.strings

@@ -819,6 +819,13 @@ Połączono z Nightscout!";
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/pt-BR.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Батарея";
 
+/* */
+
+"Show glucose on the app badge" = "Показывать глюкозу на значке приложения";
+
+/* */
+"Also add source info" = "Дополнительная информация об истонике";
+
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Batteri";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/tr.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Pil";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/uk.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

+ 7 - 0
FreeAPS/Sources/Localizations/Main/zh-Hans.lproj/Localizable.strings

@@ -817,6 +817,13 @@ Enact a temp Basal or a temp target */
 /* */
 "Battery" = "Battery";
 
+/* */
+
+"Show glucose on the app badge" = "Show glucose on the app badge";
+
+/* */
+"Also add source info" = "Also add source info";
+
 
 
 /* Headers for settings ------------------- */

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

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

+ 16 - 4
FreeAPS/Sources/Services/UserNotifiactions/UserNotificationsManager.swift

@@ -71,19 +71,24 @@ final class BaseUserNotificationsManager: NSObject, UserNotificationsManager, In
         ensureCanSendNotification {
             var titles: [String] = []
 
+            var notificationAlarm = false
+
             switch self.glucoseStorage.alarm {
             case .none:
                 titles.append(NSLocalizedString("Glucose", comment: "Glucose"))
             case .low:
                 titles.append(NSLocalizedString("LOWALERT!", comment: "LOWALERT!"))
+                notificationAlarm = true
                 self.playSoundIfNeeded()
             case .high:
                 titles.append(NSLocalizedString("HIGHALERT!", comment: "HIGHALERT!"))
+                notificationAlarm = true
                 self.playSoundIfNeeded()
             }
 
             if self.snoozeUntilDate > Date() {
                 titles.append(NSLocalizedString("(Snoozed)", comment: "(Snoozed)"))
+                notificationAlarm = false
             }
 
             let delta = glucose.count >= 2 ? glucoseValue - (glucose[glucose.count - 2].glucose ?? 0) : nil
@@ -97,6 +102,10 @@ final class BaseUserNotificationsManager: NSObject, UserNotificationsManager, In
             content.title = titles.joined(separator: " ")
             content.body = body
 
+            if notificationAlarm {
+                content.sound = .default
+            }
+
             self.addRequest(identifier: .glucocoseNotification, content: content, deleteOld: true)
         }
     }
@@ -205,22 +214,25 @@ final class BaseUserNotificationsManager: NSObject, UserNotificationsManager, In
 
     private func playSoundIfNeeded() {
         guard settingsManager.settings.useAlarmSound, snoozeUntilDate < Date() else { return }
+        Self.stopPlaying = false
         playSound()
     }
 
-    private let soundID: UInt32 = 1336
+    static let soundID: UInt32 = 1336
+    private static var stopPlaying = false
 
     private func playSound(times: Int = 3) {
-        guard times > 0 else {
+        guard times > 0, !Self.stopPlaying else {
             return
         }
 
-        AudioServicesPlaySystemSoundWithCompletion(soundID) {
+        AudioServicesPlaySystemSoundWithCompletion(Self.soundID) {
             self.playSound(times: times - 1)
         }
     }
 
-    private func stopSound() {
+    static func stopSound() {
+        stopPlaying = true
         AudioServicesDisposeSystemSoundID(soundID)
     }