Explorar o código

Update: Advanced Settings, BG Update Delay

Jon Fawcett %!s(int64=5) %!d(string=hai) anos
pai
achega
c1a537ea7b

+ 4 - 4
LoopFollow.xcodeproj/project.pbxproj

@@ -14,7 +14,7 @@
 		DDCF979624C1443C002C9752 /* GeneralSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCF979524C1443C002C9752 /* GeneralSettingsViewController.swift */; };
 		DDCF979824C1489C002C9752 /* GraphSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCF979724C1489C002C9752 /* GraphSettingsViewController.swift */; };
 		DDCF979A24C14DB4002C9752 /* WatchSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCF979924C14DB4002C9752 /* WatchSettingsViewController.swift */; };
-		DDCF979C24C14EFB002C9752 /* DebugSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCF979B24C14EFB002C9752 /* DebugSettingsViewController.swift */; };
+		DDCF979C24C14EFB002C9752 /* AdvancedSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCF979B24C14EFB002C9752 /* AdvancedSettingsViewController.swift */; };
 		DDCF979E24C2382A002C9752 /* AppStateController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCF979D24C2382A002C9752 /* AppStateController.swift */; };
 		FC16A97A24996673003D6245 /* NightScout.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC16A97924996673003D6245 /* NightScout.swift */; };
 		FC16A97B249966A3003D6245 /* AlarmSound.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC7CE589248ABEA3001F83B8 /* AlarmSound.swift */; };
@@ -180,7 +180,7 @@
 		DDCF979524C1443C002C9752 /* GeneralSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralSettingsViewController.swift; sourceTree = "<group>"; };
 		DDCF979724C1489C002C9752 /* GraphSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GraphSettingsViewController.swift; sourceTree = "<group>"; };
 		DDCF979924C14DB4002C9752 /* WatchSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WatchSettingsViewController.swift; sourceTree = "<group>"; };
-		DDCF979B24C14EFB002C9752 /* DebugSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugSettingsViewController.swift; sourceTree = "<group>"; };
+		DDCF979B24C14EFB002C9752 /* AdvancedSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedSettingsViewController.swift; sourceTree = "<group>"; };
 		DDCF979D24C2382A002C9752 /* AppStateController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppStateController.swift; sourceTree = "<group>"; };
 		ECA3EFB4037410B4973BB632 /* Pods-LoopFollow.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LoopFollow.debug.xcconfig"; path = "Target Support Files/Pods-LoopFollow/Pods-LoopFollow.debug.xcconfig"; sourceTree = "<group>"; };
 		FC16A97924996673003D6245 /* NightScout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NightScout.swift; sourceTree = "<group>"; };
@@ -620,7 +620,7 @@
 				DDCF979524C1443C002C9752 /* GeneralSettingsViewController.swift */,
 				DDCF979724C1489C002C9752 /* GraphSettingsViewController.swift */,
 				DDCF979924C14DB4002C9752 /* WatchSettingsViewController.swift */,
-				DDCF979B24C14EFB002C9752 /* DebugSettingsViewController.swift */,
+				DDCF979B24C14EFB002C9752 /* AdvancedSettingsViewController.swift */,
 			);
 			path = ViewControllers;
 			sourceTree = "<group>";
@@ -878,7 +878,7 @@
 				FC16A97F249969E2003D6245 /* Graphs.swift in Sources */,
 				FC8589BF252B54F500C8FC73 /* Mobileprovision.swift in Sources */,
 				DD152D3B24C01B2300361FA2 /* InfoDisplaySettingsViewController.swift in Sources */,
-				DDCF979C24C14EFB002C9752 /* DebugSettingsViewController.swift in Sources */,
+				DDCF979C24C14EFB002C9752 /* AdvancedSettingsViewController.swift in Sources */,
 				FC97881C2485969B00A7906C /* MainViewController.swift in Sources */,
 				FC1BB3A8252CA4C5003839C2 /* UIImageExtension.swift in Sources */,
 				DDCF979624C1443C002C9752 /* GeneralSettingsViewController.swift in Sources */,

+ 18 - 11
LoopFollow/ViewControllers/DebugSettingsViewController.swift

@@ -11,7 +11,7 @@ import Eureka
 import EventKit
 import EventKitUI
 
-class DebugSettingsViewController: FormViewController {
+class AdvancedSettingsViewController: FormViewController {
     
     var appStateController: AppStateController?
     
@@ -20,11 +20,11 @@ class DebugSettingsViewController: FormViewController {
         if UserDefaultsRepository.forceDarkMode.value {
             overrideUserInterfaceStyle = .dark
         }
-        buildDebugSettings()
+        buildAdvancedSettings()
     }
-    private func buildDebugSettings() {
+    private func buildAdvancedSettings() {
         form
-            +++ Section("Debug Settings")
+            +++ Section("Advanced Settings")
             
             <<< SwitchRow("onlyDownloadBG"){ row in
                 row.title = "Only Download BG from NS"
@@ -76,16 +76,23 @@ class DebugSettingsViewController: FormViewController {
                 guard let value = row.value else { return }
                 UserDefaultsRepository.graphOtherTreatments.value = value
             }
+            <<< StepperRow("bgUpdateDelay") { row in
+                row.title = "BG Update Delay (Sec)"
+                row.cell.stepper.stepValue = 1
+                row.cell.stepper.minimumValue = 1
+                row.cell.stepper.maximumValue = 30
+                row.value = Double(UserDefaultsRepository.bgUpdateDelay.value)
+                row.displayValueFor = { value in
+                        guard let value = value else { return nil }
+                        return "\(Int(value))"
+                    }
+            }.onChange { [weak self] row in
+                    guard let value = row.value else { return }
+                    UserDefaultsRepository.bgUpdateDelay.value = Int(value)
+            }
             
             
             
-            <<< SwitchRow("debugLog"){ row in
-                row.title = "Show Debug Log"
-                row.value = UserDefaultsRepository.debugLog.value
-            }.onChange { [weak self] row in
-                guard let value = row.value else { return }
-                UserDefaultsRepository.debugLog.value = value
-            }
             
             +++ ButtonRow() {
                 $0.title = "DONE"

+ 3 - 3
LoopFollow/ViewControllers/MainViewController.swift

@@ -528,7 +528,7 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
             })
         }
         
-        self.sendNotification(self, title: "Watch Face Cleanup", subtitle: "", body: "Delete old watch face graph images", timer: 86400)
+        self.sendGeneralNotification(self, title: "Watch Face Cleanup", subtitle: "", body: "Delete old watch face graph images", timer: 86400)
         
         
     }
@@ -715,7 +715,7 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
     
     // General Notifications
     
-    func sendNotification(_ sender: Any, title: String, subtitle: String, body: String, timer: TimeInterval) {
+    func sendGeneralNotification(_ sender: Any, title: String, subtitle: String, body: String, timer: TimeInterval) {
         
         UNUserNotificationCenter.current().delegate = self
         
@@ -723,7 +723,7 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
         content.title = title
         content.subtitle = subtitle
         content.body = body
-        content.categoryIdentifier = "category"
+        content.categoryIdentifier = "noAction"
         content.sound = .default
         
         let trigger = UNTimeIntervalNotificationTrigger(timeInterval: timer, repeats: false)

+ 14 - 13
LoopFollow/ViewControllers/SettingsViewController.swift

@@ -174,19 +174,6 @@ class SettingsViewController: FormViewController {
            ), onDismiss: nil)
             
         }
-        
-       +++ Section("Debug Settings")
-        <<< ButtonRow() {
-           $0.title = "Configure Debug"
-           $0.presentationMode = .show(
-               controllerProvider: .callback(builder: {
-                  let controller = DebugSettingsViewController()
-                  controller.appStateController = self.appStateController
-                  return controller
-               }
-           ), onDismiss: nil)
-            
-        }
             <<< LabelRow("Clear Images"){ row in
                 row.title = "Delete Watch Face Images"
             }.onCellSelection{ cell,row  in
@@ -197,6 +184,20 @@ class SettingsViewController: FormViewController {
                     mainScreen.saveChartImage()
                 }
             }
+        
+       +++ Section("Advanced Settings")
+        <<< ButtonRow() {
+           $0.title = "Advanced Settings"
+           $0.presentationMode = .show(
+               controllerProvider: .callback(builder: {
+                  let controller = AdvancedSettingsViewController()
+                  controller.appStateController = self.appStateController
+                  return controller
+               }
+           ), onDismiss: nil)
+            
+        }
+  
     
             +++ Section(header: "App Expiration", footer: String(expiration.description))
     

+ 10 - 10
LoopFollow/repository/UserDefaults.swift

@@ -74,16 +74,16 @@ class UserDefaultsRepository {
             UIApplication.shared.isIdleTimerDisabled = screenlock
     })
     
-    // Debug Settings
-        static let onlyDownloadBG = UserDefaultsValue<Bool>(key: "onlyDownloadBG", default: false)
-        static let downloadTreatments = UserDefaultsValue<Bool>(key: "downloadTreatments", default: true)
-        static let downloadPrediction = UserDefaultsValue<Bool>(key: "downloadPrediction", default: true)
-        static let graphOtherTreatments = UserDefaultsValue<Bool>(key: "graphOtherTreatments", default: true)
-        static let graphBasal = UserDefaultsValue<Bool>(key: "graphBasal", default: true)
-        static let graphBolus = UserDefaultsValue<Bool>(key: "graphBolus", default: true)
-        static let graphCarbs = UserDefaultsValue<Bool>(key: "graphCarbs", default: true)
-        static let debugLog = UserDefaultsValue<Bool>(key: "debugLog", default: false)
-    
+    // Advanced Settings
+    static let onlyDownloadBG = UserDefaultsValue<Bool>(key: "onlyDownloadBG", default: false)
+    static let downloadTreatments = UserDefaultsValue<Bool>(key: "downloadTreatments", default: true)
+    static let downloadPrediction = UserDefaultsValue<Bool>(key: "downloadPrediction", default: true)
+    static let graphOtherTreatments = UserDefaultsValue<Bool>(key: "graphOtherTreatments", default: true)
+    static let graphBasal = UserDefaultsValue<Bool>(key: "graphBasal", default: true)
+    static let graphBolus = UserDefaultsValue<Bool>(key: "graphBolus", default: true)
+    static let graphCarbs = UserDefaultsValue<Bool>(key: "graphCarbs", default: true)
+    static let debugLog = UserDefaultsValue<Bool>(key: "debugLog", default: false)
+    static let bgUpdateDelay = UserDefaultsValue<Int>(key: "bgUpdateDelay", default: 10)
     
     
     // Watch Calendar Settings