diff --git a/Common/HKUnit.swift b/Common/HKUnit.swift deleted file mode 100644 index 719502d..0000000 --- a/Common/HKUnit.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// HKUnit.swift -// xDripG5 -// -// Created by Nate Racklyeft on 8/6/16. -// Copyright © 2016 Nathan Racklyeft. All rights reserved. -// - -import HealthKit - -extension HKUnit { - static let milligramsPerDeciliter: HKUnit = { - HKUnit.gramUnit(with: .milli).unitDivided(by: .literUnit(with: .deci)) - }() - - static let millimolesPerLiter: HKUnit = { - HKUnit.moleUnit(with: .milli, molarMass: HKUnitMolarMassBloodGlucose).unitDivided(by: .liter()) - }() - - var localizedShortUnitString: String { - if self == HKUnit.millimolesPerLiter { - return NSLocalizedString("mmol/L", comment: "The short unit display string for millimoles of glucose per liter") - } else if self == .milligramsPerDeciliter { - return NSLocalizedString("mg/dL", comment: "The short unit display string for milligrams of glucose per decilter") - } else if self == .internationalUnit() { - return NSLocalizedString("U", comment: "The short unit display string for international units of insulin") - } else if self == .gram() { - return NSLocalizedString("g", comment: "The short unit display string for grams") - } else { - return String(describing: self) - } - } -} diff --git a/Common/Settings/GlucoseSchedules.swift b/Common/Settings/GlucoseSchedules.swift index 528d31a..7d317fb 100644 --- a/Common/Settings/GlucoseSchedules.swift +++ b/Common/Settings/GlucoseSchedules.swift @@ -7,8 +7,8 @@ // import Foundation -import HealthKit -// import MiaomiaoClient +import LoopAlgorithm + public enum GlucoseScheduleAlarmResult: Int, CaseIterable { case none = 0 case low @@ -175,8 +175,8 @@ class GlucoseSchedule: Codable, CustomStringConvertible { } // stores the alarm. It does not synhronize the value with the underlaying userdefaults // that is up to the caller of this class - public func storeLowAlarm(forUnit unit: HKUnit, lowAlarm: Double) { - if unit == HKUnit.millimolesPerLiter { + public func storeLowAlarm(forUnit unit: LoopUnit, lowAlarm: Double) { + if unit == LoopUnit.millimolesPerLiter { self.lowAlarm = lowAlarm * 18 return } @@ -184,9 +184,9 @@ class GlucoseSchedule: Codable, CustomStringConvertible { self.lowAlarm = lowAlarm } - public func retrieveLowAlarm(forUnit unit: HKUnit) -> Double? { + public func retrieveLowAlarm(forUnit unit: LoopUnit) -> Double? { if let lowAlarm = self.lowAlarm { - if unit == HKUnit.millimolesPerLiter { + if unit == LoopUnit.millimolesPerLiter { return (lowAlarm / 18).roundTo(places: 1) } else { return lowAlarm @@ -198,17 +198,17 @@ class GlucoseSchedule: Codable, CustomStringConvertible { // stores the alarm. It does not synhronize the value with the underlaying userdefaults // that is up to the caller of this class - public func storeHighAlarm(forUnit unit: HKUnit, highAlarm: Double) { - if unit == HKUnit.millimolesPerLiter { + public func storeHighAlarm(forUnit unit: LoopUnit, highAlarm: Double) { + if unit == .millimolesPerLiter { self.highAlarm = highAlarm * 18 return } self.highAlarm = highAlarm } - public func retrieveHighAlarm(forUnit unit: HKUnit) -> Double? { + public func retrieveHighAlarm(forUnit unit: LoopUnit) -> Double? { if let highAlarm = self.highAlarm { - if unit == HKUnit.millimolesPerLiter { + if unit == .millimolesPerLiter { return (highAlarm / 18).roundTo(places: 1) } return highAlarm diff --git a/Common/Settings/UserDefaults+Alarmsettings.swift b/Common/Settings/UserDefaults+Alarmsettings.swift index a05b78e..e24def8 100644 --- a/Common/Settings/UserDefaults+Alarmsettings.swift +++ b/Common/Settings/UserDefaults+Alarmsettings.swift @@ -7,7 +7,7 @@ // import Foundation -import HealthKit +import LoopAlgorithm extension UserDefaults { private enum Key: String { @@ -135,22 +135,22 @@ extension UserDefaults { } // intentionally only supports mgdl and mmol - var mmGlucoseUnit: HKUnit? { + var mmGlucoseUnit: LoopUnit? { get { if let textUnit = string(forKey: Key.mmGlucoseUnit.rawValue) { if textUnit == "mmol" { - return HKUnit.millimolesPerLiter + return LoopUnit.millimolesPerLiter } else if textUnit == "mgdl" { - return HKUnit.milligramsPerDeciliter + return LoopUnit.milligramsPerDeciliter } } return nil } set { - if newValue == HKUnit.milligramsPerDeciliter { + if newValue == LoopUnit.milligramsPerDeciliter { set("mgdl", forKey: Key.mmGlucoseUnit.rawValue) - } else if newValue == HKUnit.millimolesPerLiter { + } else if newValue == LoopUnit.millimolesPerLiter { set("mmol", forKey: Key.mmGlucoseUnit.rawValue) } } diff --git a/Common/Settings/UserDefaults+GlucoseSettings.swift b/Common/Settings/UserDefaults+GlucoseSettings.swift index d18e4d7..39d4020 100644 --- a/Common/Settings/UserDefaults+GlucoseSettings.swift +++ b/Common/Settings/UserDefaults+GlucoseSettings.swift @@ -7,7 +7,6 @@ // import Foundation -import HealthKit extension UserDefaults { private enum Key: String { diff --git a/LibreDemoPlugin/Extensions/HKUnit.swift b/LibreDemoPlugin/Extensions/HKUnit.swift deleted file mode 100644 index 9d0432f..0000000 --- a/LibreDemoPlugin/Extensions/HKUnit.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// HKUnit.swift -// LibreDemoPlugin -// -// Created by Pete Schwamb on 6/24/23. -// Copyright © 2023 LoopKit Authors. All rights reserved. -// - -import Foundation - - -import HealthKit - -extension HKUnit { - static let milligramsPerDeciliter: HKUnit = { - HKUnit.gramUnit(with: .milli).unitDivided(by: .literUnit(with: .deci)) - }() -} diff --git a/LibreDemoPlugin/LibreDemoCGMManager.swift b/LibreDemoPlugin/LibreDemoCGMManager.swift index 5be397a..d253677 100644 --- a/LibreDemoPlugin/LibreDemoCGMManager.swift +++ b/LibreDemoPlugin/LibreDemoCGMManager.swift @@ -7,11 +7,12 @@ // import Foundation +import HealthKit import LibreTransmitter import LibreTransmitterUI import LoopKit import LoopKitUI -import HealthKit +import LoopAlgorithm import os.log import LoopTestingKit @@ -22,6 +23,8 @@ class LibreDemoCGMManager: LibreTransmitterManagerV3 { override var localizedTitle: String { "Libre Demo" } + + public var autoStartTrace: Bool = false public var managerIdentifier: String { "LibreDemoCGMManager" @@ -60,7 +63,7 @@ class LibreDemoCGMManager: LibreTransmitterManagerV3 { private func reportMockSample() { let date = Date() let value = 110.0 + sin(date.timeIntervalSinceReferenceDate.truncatingRemainder(dividingBy: 3600 * 5) / (3600*5) * Double.pi * 2) * 60 - let quantity = HKQuantity(unit: .milligramsPerDeciliter, doubleValue: value) + let quantity = LoopQuantity(unit: .milligramsPerDeciliter, doubleValue: value) let newSample = NewGlucoseSample( date: date, quantity: quantity, diff --git a/LibreTransmitter.xcodeproj/project.pbxproj b/LibreTransmitter.xcodeproj/project.pbxproj index 7be9de6..e9e7be4 100644 --- a/LibreTransmitter.xcodeproj/project.pbxproj +++ b/LibreTransmitter.xcodeproj/project.pbxproj @@ -53,8 +53,6 @@ 27850CFA25672C0C0020D109 /* UIApplication+metadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27850CE325672C0C0020D109 /* UIApplication+metadata.swift */; }; 27850CFB25672C0C0020D109 /* GlucoseSchedules.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27850CE425672C0C0020D109 /* GlucoseSchedules.swift */; }; 27850CFC25672C0C0020D109 /* GlucoseSchedules.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27850CE425672C0C0020D109 /* GlucoseSchedules.swift */; }; - 27850CFD25672C0C0020D109 /* HKUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27850CE525672C0C0020D109 /* HKUnit.swift */; }; - 27850CFE25672C0C0020D109 /* HKUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27850CE525672C0C0020D109 /* HKUnit.swift */; }; 27850D0E25672CA60020D109 /* ConcreteGlucoseDisplayable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27850D0B25672CA60020D109 /* ConcreteGlucoseDisplayable.swift */; }; 27850D1025672CA60020D109 /* LibreGlucose.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27850D0C25672CA60020D109 /* LibreGlucose.swift */; }; 27850D1225672CA60020D109 /* NotificationHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27850D0D25672CA60020D109 /* NotificationHelper.swift */; }; @@ -255,7 +253,6 @@ 27850CE225672C0C0020D109 /* UserDefaults+Bluetooth.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UserDefaults+Bluetooth.swift"; sourceTree = ""; }; 27850CE325672C0C0020D109 /* UIApplication+metadata.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIApplication+metadata.swift"; sourceTree = ""; }; 27850CE425672C0C0020D109 /* GlucoseSchedules.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GlucoseSchedules.swift; sourceTree = ""; }; - 27850CE525672C0C0020D109 /* HKUnit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HKUnit.swift; sourceTree = ""; }; 27850D0B25672CA60020D109 /* ConcreteGlucoseDisplayable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConcreteGlucoseDisplayable.swift; sourceTree = ""; }; 27850D0C25672CA60020D109 /* LibreGlucose.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LibreGlucose.swift; sourceTree = ""; }; 27850D0D25672CA60020D109 /* NotificationHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationHelper.swift; sourceTree = ""; }; @@ -312,7 +309,6 @@ C1BDBAFD2A43992A00A787D1 /* LibreDemoCGMManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibreDemoCGMManager.swift; sourceTree = ""; }; C1BDBAFE2A44FFD800A787D1 /* MockSensorPairingService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockSensorPairingService.swift; sourceTree = ""; }; C1C318CF2A4748A100C6F29F /* MockBluetoothSearcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockBluetoothSearcher.swift; sourceTree = ""; }; - C1C318D82A478E0000C6F29F /* HKUnit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HKUnit.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -649,7 +645,6 @@ isa = PBXGroup; children = ( 27850CD825672C0C0020D109 /* Extensions */, - 27850CE525672C0C0020D109 /* HKUnit.swift */, 27850CDE25672C0C0020D109 /* LocalizedString.swift */, 27850CDF25672C0C0020D109 /* Settings */, ); @@ -669,7 +664,6 @@ C1AF1D132A4BC22A00F46A26 /* Extensions */ = { isa = PBXGroup; children = ( - C1C318D82A478E0000C6F29F /* HKUnit.swift */, C1AF1D142A4BC23D00F46A26 /* TimeInterval.swift */, ); path = Extensions; @@ -990,7 +984,6 @@ 27850DCF25672F780020D109 /* CRC.swift in Sources */, 2764E86126FC6DC10016A585 /* Features.swift in Sources */, 27ED67B82698EF38003E5DAB /* AlarmStatus.swift in Sources */, - 27850CFD25672C0C0020D109 /* HKUnit.swift in Sources */, 27850CF925672C0C0020D109 /* UIApplication+metadata.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1002,7 +995,6 @@ 274E71D52986D4A600FCFECD /* CriticalAlarmsVolumeView.swift in Sources */, 2746C74226DD0F8800E31BD9 /* Libre2DirectSetup.swift in Sources */, 27ED67BA26990D6B003E5DAB /* GenericObservableObject.swift in Sources */, - 27850CFE25672C0C0020D109 /* HKUnit.swift in Sources */, 27850D4E25672DFB0020D109 /* LibreTransmitterSetupViewController.swift in Sources */, 276EF5F22652F84F00571021 /* HashableClass.swift in Sources */, 27850CF825672C0C0020D109 /* UserDefaults+Bluetooth.swift in Sources */, @@ -1049,7 +1041,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - C1C318D92A478E0000C6F29F /* HKUnit.swift in Sources */, C1AF1D152A4BC23D00F46A26 /* TimeInterval.swift in Sources */, C1BDBAED2A4397E200A787D1 /* OSLog.swift in Sources */, C1BDBB002A45051B00A787D1 /* LibreDemoPlugin.swift in Sources */, @@ -1141,7 +1132,7 @@ GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; + IPHONEOS_DEPLOYMENT_TARGET = 17.6; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; LOCALIZED_STRING_MACRO_NAMES = ( NSLocalizedString, @@ -1207,7 +1198,7 @@ GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; + IPHONEOS_DEPLOYMENT_TARGET = 17.6; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; LOCALIZED_STRING_MACRO_NAMES = ( NSLocalizedString, @@ -1242,7 +1233,6 @@ FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = LibreTransmitter/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1275,7 +1265,6 @@ FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = LibreTransmitter/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1315,7 +1304,6 @@ GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = LibreTransmitterUI/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1356,7 +1344,6 @@ GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = LibreTransmitterUI/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1389,7 +1376,6 @@ GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = LibreTransmitterPlugin/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1427,7 +1413,6 @@ GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = LibreTransmitterPlugin/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1464,7 +1449,6 @@ INFOPLIST_FILE = Info.plist; INFOPLIST_KEY_NSPrincipalClass = LibreDemoPlugin; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1503,7 +1487,6 @@ INFOPLIST_FILE = Info.plist; INFOPLIST_KEY_NSPrincipalClass = LibreDemoPlugin; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/LibreTransmitter/ConcreteGlucoseDisplayable.swift b/LibreTransmitter/ConcreteGlucoseDisplayable.swift index e3d049b..64790aa 100644 --- a/LibreTransmitter/ConcreteGlucoseDisplayable.swift +++ b/LibreTransmitter/ConcreteGlucoseDisplayable.swift @@ -7,7 +7,7 @@ // import Foundation -import HealthKit +import LoopAlgorithm import LoopKit public struct ConcreteGlucoseDisplayable: GlucoseDisplayable { @@ -21,5 +21,5 @@ public struct ConcreteGlucoseDisplayable: GlucoseDisplayable { // public var batteries : [(name: String, percentage: Int)]? - public var trendRate: HKQuantity? { nil } + public var trendRate: LoopQuantity? { nil } } diff --git a/LibreTransmitter/LibreGlucose.swift b/LibreTransmitter/LibreGlucose.swift index 43ec73c..be15a04 100644 --- a/LibreTransmitter/LibreGlucose.swift +++ b/LibreTransmitter/LibreGlucose.swift @@ -4,9 +4,9 @@ // import Foundation -import HealthKit import LoopKit import os.log +import LoopAlgorithm private var logger = Logger(forType: "LibreGlucose") @@ -51,7 +51,7 @@ extension LibreGlucose: GlucoseValue { timestamp } - public var quantity: HKQuantity { + public var quantity: LoopQuantity { .init(unit: .milligramsPerDeciliter, doubleValue: glucoseDouble) } } diff --git a/LibreTransmitter/LibreTransmitterManagerV3.swift b/LibreTransmitter/LibreTransmitterManagerV3.swift index 93973a3..7ed581c 100644 --- a/LibreTransmitter/LibreTransmitterManagerV3.swift +++ b/LibreTransmitter/LibreTransmitterManagerV3.swift @@ -5,6 +5,7 @@ // import Foundation +import LoopAlgorithm import LoopKit import LoopKitUI import UIKit @@ -12,16 +13,14 @@ import UserNotifications import Combine import CoreBluetooth -import HealthKit import os.log open class LibreTransmitterManagerV3: CGMManager, LibreTransmitterDelegate { + public var inSignalLoss: Bool = false - - - - - + public var isInoperable: Bool { + cgmManagerStatus.isInoperable + } public typealias GlucoseArrayWithPrediction = (trends: [LibreGlucose], historical: [LibreGlucose], prediction: [LibreGlucose]) public lazy var logger = Logger(forType: Self.self) @@ -228,7 +227,7 @@ open class LibreTransmitterManagerV3: CGMManager, LibreTransmitterDelegate { } - static public let pluginIdentifier: String = "LibreTransmitterManagerV3" + public let pluginIdentifier: String = "LibreTransmitterManagerV3" public required convenience init?(rawState: CGMManager.RawStateValue) { @@ -543,7 +542,7 @@ extension LibreTransmitterManagerV3 { extension LibreTransmitterManagerV3: DisplayGlucoseUnitObserver { - public func unitDidChange(to displayGlucoseUnit: HKUnit) { + public func unitDidChange(to displayGlucoseUnit: LoopUnit) { self.alertsUnitPreference.unitDidChange(to: displayGlucoseUnit) } } diff --git a/LibreTransmitter/Localizable.xcstrings b/LibreTransmitter/Localizable.xcstrings index 3cab29c..427a001 100644 --- a/LibreTransmitter/Localizable.xcstrings +++ b/LibreTransmitter/Localizable.xcstrings @@ -731,6 +731,7 @@ }, "g" : { "comment" : "The short unit display string for grams", + "extractionState" : "stale", "localizations" : { "ar" : { "stringUnit" : { @@ -1016,6 +1017,7 @@ }, "mg/dL" : { "comment" : "The short unit display string for milligrams of glucose per decilter", + "extractionState" : "stale", "localizations" : { "ar" : { "stringUnit" : { @@ -1159,6 +1161,7 @@ }, "mmol/L" : { "comment" : "The short unit display string for millimoles of glucose per liter", + "extractionState" : "stale", "localizations" : { "ar" : { "stringUnit" : { @@ -1763,6 +1766,7 @@ }, "U" : { "comment" : "The short unit display string for international units of insulin", + "extractionState" : "stale", "localizations" : { "ar" : { "stringUnit" : { diff --git a/LibreTransmitter/NotificationHelper.swift b/LibreTransmitter/NotificationHelper.swift index 12d9f90..fa52f68 100644 --- a/LibreTransmitter/NotificationHelper.swift +++ b/LibreTransmitter/NotificationHelper.swift @@ -8,7 +8,7 @@ import AudioToolbox import Foundation -import HealthKit +import LoopAlgorithm import LoopKit import UserNotifications import os.log @@ -49,8 +49,8 @@ public enum NotificationHelper { } } - public static func GlucoseUnitIsSupported(unit: HKUnit) -> Bool { - [HKUnit.milligramsPerDeciliter, HKUnit.millimolesPerLiter].contains(unit) + public static func GlucoseUnitIsSupported(unit: LoopUnit) -> Bool { + [LoopUnit.milligramsPerDeciliter, LoopUnit.millimolesPerLiter].contains(unit) } private static func requestCriticalNotificationPermissions() { @@ -412,7 +412,7 @@ public extension NotificationHelper { if diff >= 0 { body.append("+") } - body.append( glucoseFormatter.string(from: HKQuantity(unit: .milligramsPerDeciliter, doubleValue: diff))!) + body.append( glucoseFormatter.string(from: LoopQuantity(unit: .milligramsPerDeciliter, doubleValue: diff))!) } if let trend = trend?.localizedDescription { diff --git a/LibreTransmitter/Observables/GlucoseInfo.swift b/LibreTransmitter/Observables/GlucoseInfo.swift index 2b51dd1..a5baafa 100644 --- a/LibreTransmitter/Observables/GlucoseInfo.swift +++ b/LibreTransmitter/Observables/GlucoseInfo.swift @@ -7,16 +7,16 @@ // import Foundation -import HealthKit +import LoopAlgorithm public class GlucoseInfo: ObservableObject, Equatable, Hashable { - @Published public var glucose: HKQuantity? + @Published public var glucose: LoopQuantity? @Published public var date: Date? @Published public var checksum = "" // @Published var entryErrors = "" - @Published public var prediction: HKQuantity? + @Published public var prediction: LoopQuantity? @Published public var predictionDate: Date? public static func ==(lhs: GlucoseInfo, rhs: GlucoseInfo) -> Bool { diff --git a/LibreTransmitterUI/LibreTransmitterManager+UI.swift b/LibreTransmitterUI/LibreTransmitterManager+UI.swift index aa50375..b0e7337 100644 --- a/LibreTransmitterUI/LibreTransmitterManager+UI.swift +++ b/LibreTransmitterUI/LibreTransmitterManager+UI.swift @@ -8,7 +8,6 @@ import SwiftUI import LoopKit import LoopKitUI -import HealthKit import LibreTransmitter import Combine diff --git a/LibreTransmitterUI/Localizable.xcstrings b/LibreTransmitterUI/Localizable.xcstrings index d2b3829..38c0e8d 100644 --- a/LibreTransmitterUI/Localizable.xcstrings +++ b/LibreTransmitterUI/Localizable.xcstrings @@ -5743,6 +5743,7 @@ }, "g" : { "comment" : "The short unit display string for grams", + "extractionState" : "stale", "localizations" : { "ar" : { "stringUnit" : { @@ -8350,6 +8351,7 @@ }, "mg/dL" : { "comment" : "The short unit display string for milligrams of glucose per decilter", + "extractionState" : "stale", "localizations" : { "ar" : { "stringUnit" : { @@ -8779,6 +8781,7 @@ }, "mmol/L" : { "comment" : "The short unit display string for millimoles of glucose per liter", + "extractionState" : "stale", "localizations" : { "ar" : { "stringUnit" : { @@ -13684,6 +13687,7 @@ }, "U" : { "comment" : "The short unit display string for international units of insulin", + "extractionState" : "stale", "localizations" : { "ar" : { "stringUnit" : { diff --git a/LibreTransmitterUI/Views/Settings/AlarmSettings/AlarmSettingsView.swift b/LibreTransmitterUI/Views/Settings/AlarmSettings/AlarmSettingsView.swift index 0467ba4..8af63cc 100644 --- a/LibreTransmitterUI/Views/Settings/AlarmSettings/AlarmSettingsView.swift +++ b/LibreTransmitterUI/Views/Settings/AlarmSettings/AlarmSettingsView.swift @@ -7,7 +7,7 @@ // import SwiftUI -import HealthKit +import LoopAlgorithm private func systemImage(_ name:String) -> some View { Image(systemName: name) @@ -27,9 +27,9 @@ class AlarmScheduleState: ObservableObject, Identifiable, Hashable { @Published var alarmDateComponents: AlarmTimeCellExternalState = AlarmTimeCellExternalState() - public func setLowAlarm(forUnit unit: HKUnit, lowAlarm: Double) { + public func setLowAlarm(forUnit unit: LoopUnit, lowAlarm: Double) { - if unit == HKUnit.millimolesPerLiter { + if unit == LoopUnit.millimolesPerLiter { self.lowmgdl = lowAlarm * 18 return } @@ -37,9 +37,9 @@ class AlarmScheduleState: ObservableObject, Identifiable, Hashable { self.lowmgdl = lowAlarm } - public func getLowAlarm(forUnit unit: HKUnit) -> Double { + public func getLowAlarm(forUnit unit: LoopUnit) -> Double { - if unit == HKUnit.millimolesPerLiter { + if unit == LoopUnit.millimolesPerLiter { return (lowmgdl / 18).roundTo(places: 1) } @@ -47,9 +47,9 @@ class AlarmScheduleState: ObservableObject, Identifiable, Hashable { } - public func setHighAlarm(forUnit unit: HKUnit, highAlarm: Double) { + public func setHighAlarm(forUnit unit: LoopUnit, highAlarm: Double) { - if unit == HKUnit.millimolesPerLiter { + if unit == LoopUnit.millimolesPerLiter { self.highmgdl = highAlarm * 18 return } @@ -57,9 +57,9 @@ class AlarmScheduleState: ObservableObject, Identifiable, Hashable { self.highmgdl = highAlarm } - public func getHighAlarm(forUnit unit: HKUnit) -> Double { + public func getHighAlarm(forUnit unit: LoopUnit) -> Double { - if unit == HKUnit.millimolesPerLiter { + if unit == LoopUnit.millimolesPerLiter { return (highmgdl / 18).roundTo(places: 1) } return highmgdl @@ -207,7 +207,7 @@ struct AlarmDateRow: View { struct AlarmLowRow: View { @ObservedObject var schedule: AlarmScheduleState - var glucoseUnit: HKUnit + var glucoseUnit: LoopUnit var glucoseUnitDesc: String var errorReporter: FormErrorState @@ -249,7 +249,7 @@ struct AlarmLowRow: View { struct AlarmHighRow: View { @ObservedObject var schedule: AlarmScheduleState - var glucoseUnit: HKUnit + var glucoseUnit: LoopUnit var glucoseUnitDesc: String var errorReporter: FormErrorState @@ -287,7 +287,7 @@ struct AlarmHighRow: View { struct AlarmSettingsView: View { - private(set) var glucoseUnit: HKUnit + private(set) var glucoseUnit: LoopUnit var glucoseUnitDesc: String { // "mmol/L" diff --git a/LibreTransmitterUI/Views/Settings/GlucoseSettingsView.swift b/LibreTransmitterUI/Views/Settings/GlucoseSettingsView.swift index 72d6bd9..031483c 100644 --- a/LibreTransmitterUI/Views/Settings/GlucoseSettingsView.swift +++ b/LibreTransmitterUI/Views/Settings/GlucoseSettingsView.swift @@ -9,7 +9,6 @@ import SwiftUI import Combine import LibreTransmitter -import HealthKit struct GlucoseSettingsView: View { diff --git a/LibreTransmitterUI/Views/Settings/NotificationSettingsView.swift b/LibreTransmitterUI/Views/Settings/NotificationSettingsView.swift index 33c73a6..f9bd382 100644 --- a/LibreTransmitterUI/Views/Settings/NotificationSettingsView.swift +++ b/LibreTransmitterUI/Views/Settings/NotificationSettingsView.swift @@ -9,7 +9,7 @@ import SwiftUI import Combine import LibreTransmitter -import HealthKit +import LoopAlgorithm import LoopKitUI struct NotificationSettingsView: View { @@ -17,7 +17,7 @@ struct NotificationSettingsView: View { @State private var presentableStatus: StatusMessage? - private let glucoseSegments = [HKUnit.millimolesPerLiter, HKUnit.milligramsPerDeciliter] + private let glucoseSegments = [LoopUnit.millimolesPerLiter, LoopUnit.milligramsPerDeciliter] private lazy var glucoseSegmentStrings = self.glucoseSegments.map({ $0.localizedShortUnitString }) private enum Key: String { diff --git a/LibreTransmitterUI/Views/Settings/SettingsView.swift b/LibreTransmitterUI/Views/Settings/SettingsView.swift index ac1b6e1..c782ecb 100644 --- a/LibreTransmitterUI/Views/Settings/SettingsView.swift +++ b/LibreTransmitterUI/Views/Settings/SettingsView.swift @@ -9,7 +9,7 @@ import SwiftUI import LibreTransmitter -import HealthKit +import LoopAlgorithm import LoopKit import LoopKitUI import UniformTypeIdentifiers @@ -102,7 +102,7 @@ struct SettingsView: View { self.bluetoothSearcher = bluetoothSearcher } - private var glucoseUnit: HKUnit { + private var glucoseUnit: LoopUnit { displayGlucosePreference.unit }