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

Merge pull request #95 from kylmcw/temp-target-duration-fix

kylmcw 2 лет назад
Родитель
Сommit
2656373b64
26 измененных файлов с 42 добавлено и 31 удалено
  1. 1 1
      FreeAPS/Sources/Localizations/Main/ar.lproj/Localizable.strings
  2. 1 1
      FreeAPS/Sources/Localizations/Main/ca.lproj/Localizable.strings
  3. 1 1
      FreeAPS/Sources/Localizations/Main/da.lproj/Localizable.strings
  4. 1 1
      FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings
  5. 1 1
      FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings
  6. 1 1
      FreeAPS/Sources/Localizations/Main/es.lproj/Localizable.strings
  7. 1 1
      FreeAPS/Sources/Localizations/Main/fi.lproj/Localizable.strings
  8. 1 1
      FreeAPS/Sources/Localizations/Main/fr.lproj/Localizable.strings
  9. 1 1
      FreeAPS/Sources/Localizations/Main/he.lproj/Localizable.strings
  10. 1 1
      FreeAPS/Sources/Localizations/Main/hu.lproj/Localizable.strings
  11. 1 1
      FreeAPS/Sources/Localizations/Main/it.lproj/Localizable.strings
  12. 1 1
      FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings
  13. 1 1
      FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings
  14. 1 1
      FreeAPS/Sources/Localizations/Main/pl.lproj/Localizable.strings
  15. 1 1
      FreeAPS/Sources/Localizations/Main/pt-BR.lproj/Localizable.strings
  16. 1 1
      FreeAPS/Sources/Localizations/Main/pt-PT.lproj/Localizable.strings
  17. 1 1
      FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings
  18. 1 1
      FreeAPS/Sources/Localizations/Main/sk.lproj/Localizable.strings
  19. 1 1
      FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings
  20. 1 1
      FreeAPS/Sources/Localizations/Main/tr.lproj/Localizable.strings
  21. 1 1
      FreeAPS/Sources/Localizations/Main/uk.lproj/Localizable.strings
  22. 1 1
      FreeAPS/Sources/Localizations/Main/vi.lproj/Localizable.strings
  23. 1 1
      FreeAPS/Sources/Localizations/Main/zh-Hans.lproj/Localizable.strings
  24. 2 2
      FreeAPS/Sources/Services/UserNotifiactions/UserNotificationsManager.swift
  25. 1 1
      FreeAPS/Sources/Shortcuts/State/ListStateIntent.swift
  26. 16 5
      FreeAPS/Sources/Shortcuts/TempPresets/ApplyTempPresetIntent.swift

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

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "To prevent LOW required %d g of carbs";
 
 /* */
-"iAPS not active" = "iAPS not active";
+"Open-iAPS Not Active" = "Open-iAPS Not Active";
 
 /* */
 "Last loop was more than %d min ago" = "Last loop was more than %d min ago";

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

@@ -940,7 +940,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "To prevent LOW required %d g of carbs";
 
 /* */
-"iAPS not active" = "iAPS not active";
+"Open-iAPS Not Active" = "Open-iAPS Not Active";
 
 /* */
 "Last loop was more than %d min ago" = "Last loop was more than %d min ago";

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

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "To prevent LOW required %d g of carbs";
 
 /* */
-"iAPS not active" = "iAPS not active";
+"Open-iAPS Not Active" = "Open-iAPS Not Active";
 
 /* */
 "Last loop was more than %d min ago" = "Last loop was more than %d min ago";

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

@@ -1038,7 +1038,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "Um einen NIEDRIGEN BZ zu verhindern, werden %d g Kohlenhydrate benötigt";
 
 /* */
-"iAPS not active" = "iAPS ist nicht aktiv";
+"Open-iAPS Not Active" = "Open-iAPS ist nicht aktiv";
 
 /* */
 "Last loop was more than %d min ago" = "Letzter Loop vor mehr als %d Minuten";

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

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
  "To prevent LOW required %d g of carbs" = "To prevent LOW required %d g of carbs";
 
  /* */
- "iAPS not active" = "iAPS not active";
+ "Open-iAPS Not Active" = "Open-iAPS Not Active";
 
  /* */
  "Last loop was more than %d min ago" = "Last loop was more than %d min ago";

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

@@ -1034,7 +1034,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "To prevent LOW required %d g of carbs";
 
 /* */
-"iAPS not active" = "iAPS not active";
+"Open-iAPS Not Active" = "Open-iAPS Not Active";
 
 /* */
 "Last loop was more than %d min ago" = "Last loop was more than %d min ago";

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

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "To prevent LOW required %d g of carbs";
 
 /* */
-"iAPS not active" = "iAPS not active";
+"Open-iAPS Not Active" = "Open-iAPS Not Active";
 
 /* */
 "Last loop was more than %d min ago" = "Last loop was more than %d min ago";

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

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "Pour éviter BAS %d g de glucides requis";
 
 /* */
-"iAPS not active" = "iAPS pas actif";
+"Open-iAPS Not Active" = "Open-iAPS pas actif";
 
 /* */
 "Last loop was more than %d min ago" = "Dernier bouclage depuis plus de %d min";

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

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "To prevent LOW required %d g of carbs";
 
 /* */
-"iAPS not active" = "iAPS not active";
+"Open-iAPS Not Active" = "Open-iAPS Not Active";
 
 /* */
 "Last loop was more than %d min ago" = "Last loop was more than %d min ago";

+ 1 - 1
FreeAPS/Sources/Localizations/Main/hu.lproj/Localizable.strings

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "To prevent LOW required %d g of carbs";
 
 /* */
-"iAPS not active" = "iAPS not active";
+"Open-iAPS Not Active" = "Open-iAPS Not Active";
 
 /* */
 "Last loop was more than %d min ago" = "Last loop was more than %d min ago";

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

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "Per evitare glicemia BASSA servono %d g di carboidrati";
 
 /* */
-"iAPS not active" = "iAPS non attivo";
+"Open-iAPS Not Active" = "Open-iAPS non attivo";
 
 /* */
 "Last loop was more than %d min ago" = "L'ultimo ciclo è stato più di %d min fa";

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

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "For å forhindre lavt blodsukker: %d g karbo nødvendig";
 
 /* */
-"iAPS not active" = "iAPS ikke aktiv";
+"Open-iAPS Not Active" = "Open-iAPS ikke aktiv";
 
 /* */
 "Last loop was more than %d min ago" = "Siste loop var mer enn %d min siden";

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

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "Om LAAG te voorkomen zijn %d g koolhydraten nodig";
 
 /* */
-"iAPS not active" = "iAPS is niet actief!";
+"Open-iAPS Not Active" = "Open-iAPS is niet actief!";
 
 /* */
 "Last loop was more than %d min ago" = "Laatste loop was meer dan %d min geleden";

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

@@ -1037,7 +1037,7 @@ Połączono z Nightscout!";
 "To prevent LOW required %d g of carbs" = "To prevent LOW required %d g of carbs";
 
 /* */
-"iAPS not active" = "iAPS not active";
+"Open-iAPS Not Active" = "Open-iAPS Not Active";
 
 /* */
 "Last loop was more than %d min ago" = "Last loop was more than %d min ago";

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

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "To prevent LOW required %d g of carbs";
 
 /* */
-"iAPS not active" = "iAPS not active";
+"Open-iAPS Not Active" = "Open-iAPS Not Active";
 
 /* */
 "Last loop was more than %d min ago" = "Last loop was more than %d min ago";

+ 1 - 1
FreeAPS/Sources/Localizations/Main/pt-PT.lproj/Localizable.strings

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "To prevent LOW required %d g of carbs";
 
 /* */
-"iAPS not active" = "iAPS not active";
+"Open-iAPS Not Active" = "Open-iAPS Not Active";
 
 /* */
 "Last loop was more than %d min ago" = "Last loop was more than %d min ago";

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

@@ -1038,7 +1038,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "Для избежания ГИПО необходимо %d г углеводов";
 
 /* */
-"iAPS not active" = "iAPS неактивен";
+"Open-iAPS Not Active" = "Open-iAPS неактивен";
 
 /* */
 "Last loop was more than %d min ago" = "Последний цикл был более %d минут назад";

+ 1 - 1
FreeAPS/Sources/Localizations/Main/sk.lproj/Localizable.strings

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "Na zabránenie NÍZKY potrebných %d g sacharidov";
 
 /* */
-"iAPS not active" = "iAPS nie je aktívny";
+"Open-iAPS Not Active" = "Open-iAPS nie je aktívny";
 
 /* */
 "Last loop was more than %d min ago" = "Posledná slučka bola pred viac ako %d min";

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

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "För att förhindra ett lågt blodsocker krävs uppskattningsvis %d g kolhydrater";
 
 /* */
-"iAPS not active" = "iAPS är inte aktiv";
+"Open-iAPS Not Active" = "Open-iAPS är inte aktiv";
 
 /* */
 "Last loop was more than %d min ago" = "Senaste loop var för mer än %d min sedan";

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

@@ -1039,7 +1039,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "DÜŞÜK KŞ'ini önlemek için gerekli Karbonhidrat %d g";
 
 /* */
-"iAPS not active" = "iAPS etkin değil";
+"Open-iAPS Not Active" = "Open-iAPS etkin değil";
 
 /* */
 "Last loop was more than %d min ago" = "Son döngü %d dak kadar önceydi";

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

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "Для запобігання ГІПО потрібно %d g вуглеводів";
 
 /* */
-"iAPS not active" = "iAPS не активний";
+"Open-iAPS Not Active" = "Open-iAPS не активний";
 
 /* */
 "Last loop was more than %d min ago" = "Останній цикл був більше, ніж %d хв тому";

+ 1 - 1
FreeAPS/Sources/Localizations/Main/vi.lproj/Localizable.strings

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "Để hạn chế LOW yêu cầu %d g carbs";
 
 /* */
-"iAPS not active" = "iAPS chưa hoạt động";
+"Open-iAPS Not Active" = "Open-iAPS chưa hoạt động";
 
 /* */
 "Last loop was more than %d min ago" = "Loop dừng hoạt động hơn %d phút trước";

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

@@ -1035,7 +1035,7 @@ Enact a temp Basal or a temp target */
 "To prevent LOW required %d g of carbs" = "为了防止低血糖, 需要%d 克碳水";
 
 /* */
-"iAPS not active" = "iAPS 未激活";
+"Open-iAPS Not Active" = "Open-iAPS 未激活";
 
 /* */
 "Last loop was more than %d min ago" = "上次闭环成功在 %d 分钟前";

+ 2 - 2
FreeAPS/Sources/Services/UserNotifiactions/UserNotificationsManager.swift

@@ -126,8 +126,8 @@ final class BaseUserNotificationsManager: NSObject, UserNotificationsManager, In
 
     private func scheduleMissingLoopNotifiactions(date _: Date) {
         ensureCanSendNotification {
-            let title = NSLocalizedString("iAPS not active", comment: "iAPS not active")
-            let body = NSLocalizedString("Last loop was more then %d min ago", comment: "Last loop was more then %d min ago")
+            let title = NSLocalizedString("Open-iAPS Not Active", comment: "Open-iAPS Not Active")
+            let body = NSLocalizedString("Last loop was more than %d min ago", comment: "Last loop was more than %d min ago")
 
             let firstInterval = 20 // min
             let secondInterval = 40 // min

+ 1 - 1
FreeAPS/Sources/Shortcuts/State/ListStateIntent.swift

@@ -13,7 +13,7 @@ import Foundation
     )
 
     static var parameterSummary: some ParameterSummary {
-        Summary("List all states of iAPS")
+        Summary("List all states of Open-iAPS")
     }
 
     @MainActor func perform() async throws -> some ReturnsValue<StateiAPSResults> & ShowsSnippetView {

+ 16 - 5
FreeAPS/Sources/Shortcuts/TempPresets/ApplyTempPresetIntent.swift

@@ -3,10 +3,10 @@ import Foundation
 
 @available(iOS 16.0, *) struct ApplyTempPresetIntent: AppIntent {
     // Title of the action in the Shortcuts app
-    static var title: LocalizedStringResource = "Apply a temporary Preset"
+    static var title: LocalizedStringResource = "Apply a temporary target"
 
     // Description of the action in the Shortcuts app
-    static var description = IntentDescription("Allow to apply a specific temporary preset.")
+    static var description = IntentDescription("Enable a temporary target")
 
     internal var intentRequest: TempPresetsIntentRequest
 
@@ -34,6 +34,16 @@ import Foundation
         })
     }
 
+    private func decimalToTimeFormattedString(decimal: Decimal) -> String {
+        let timeInterval = TimeInterval(decimal * 60) // seconds
+
+        let formatter = DateComponentsFormatter()
+        formatter.allowedUnits = [.hour, .minute]
+        formatter.unitsStyle = .brief // example: 1h 10 min
+
+        return formatter.string(from: timeInterval) ?? ""
+    }
+
     @MainActor func perform() async throws -> some ProvidesDialog {
         do {
             let presetToApply: tempPreset
@@ -42,22 +52,23 @@ import Foundation
             } else {
                 presetToApply = try await $preset.requestDisambiguation(
                     among: intentRequest.fetchAll(),
-                    dialog: "What temp preset would you like ?"
+                    dialog: "Select Temporary Target"
                 )
             }
 
             let displayName: String = presetToApply.name
             if confirmBeforeApplying {
                 try await requestConfirmation(
-                    result: .result(dialog: "Are you sure to applying the temp target \(displayName) ?")
+                    result: .result(dialog: "Confirm to apply temporary target '\(displayName)'")
                 )
             }
 
             // TODO: enact the temp target
             let tempTarget = try intentRequest.findTempTarget(presetToApply)
             let finalTempTargetApply = try intentRequest.enactTempTarget(tempTarget)
+            let formattedTime = decimalToTimeFormattedString(decimal: finalTempTargetApply.duration)
             let displayDetail: String =
-                "the target \(finalTempTargetApply.displayName) is applying during \(finalTempTargetApply.duration) mn"
+                "Target '\(finalTempTargetApply.displayName)' applied for \(formattedTime)"
             return .result(
                 dialog: IntentDialog(stringLiteral: displayDetail)
             )