From aa00c2bde937a418818007dbba7591f6d4ee81f7 Mon Sep 17 00:00:00 2001 From: Dirk Hermanns Date: Sun, 18 Sep 2022 19:43:52 +0200 Subject: [PATCH] #198: Lockscreen Widget and new optimized Watch complications --- .../Base.lproj/Interface.storyboard | 6 +- nightguard WatchKit App/Info.plist | 2 +- .../Assets.xcassets/Contents.json | 6 +- .../ComplicationController.swift | 81 +++-- nightguard WatchKit Extension/Info.plist | 2 +- .../MainViewModel.swift | 6 +- .../UserDefaultsRepository.swift | 20 -- .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 13 + .../Assets.xcassets/Contents.json | 6 + .../WidgetBackground.colorset/Contents.json | 11 + nightguard Widget Extension/Info.plist | 11 + ...ghtguard_Widget_Extension.intentdefinition | 59 ++++ .../nightguard_Widget_Extension.swift | 163 ++++++++++ ...ard Widget ExtensionExtension.entitlements | 10 + nightguard.xcodeproj/project.pbxproj | 279 +++++++++++++++++- ...guard WatchKit App (Complication).xcscheme | 25 +- ...guard WatchKit App (Notification).xcscheme | 25 +- .../nightguard WatchKit App.xcscheme | 25 +- .../xcschemes/xcschememanagement.plist | 10 + nightguard/AlarmNotificationService.swift | 2 +- nightguard/AppDelegate.swift | 12 +- nightguard/Info.plist | 2 +- nightguard/MainViewController.swift | 2 +- nightguard/NightscoutService.swift | 4 +- nightguard/PrefsViewController.swift | 10 +- nightguard/SharedUserDefaultsRepository.swift | 40 +++ nightguard/UIApplicationExtension.swift | 2 +- nightguardTests/Info.plist | 2 +- nightguardUITests/Info.plist | 2 +- 30 files changed, 710 insertions(+), 139 deletions(-) create mode 100644 nightguard Widget Extension/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 nightguard Widget Extension/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 nightguard Widget Extension/Assets.xcassets/Contents.json create mode 100644 nightguard Widget Extension/Assets.xcassets/WidgetBackground.colorset/Contents.json create mode 100644 nightguard Widget Extension/Info.plist create mode 100644 nightguard Widget Extension/nightguard_Widget_Extension.intentdefinition create mode 100644 nightguard Widget Extension/nightguard_Widget_Extension.swift create mode 100644 nightguard Widget ExtensionExtension.entitlements create mode 100644 nightguard/SharedUserDefaultsRepository.swift diff --git a/nightguard WatchKit App/Base.lproj/Interface.storyboard b/nightguard WatchKit App/Base.lproj/Interface.storyboard index 3c18af01..38d37aea 100644 --- a/nightguard WatchKit App/Base.lproj/Interface.storyboard +++ b/nightguard WatchKit App/Base.lproj/Interface.storyboard @@ -1,9 +1,9 @@ - + - - + + diff --git a/nightguard WatchKit App/Info.plist b/nightguard WatchKit App/Info.plist index d5147673..c0e9c0e8 100644 --- a/nightguard WatchKit App/Info.plist +++ b/nightguard WatchKit App/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 779 + 785 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait diff --git a/nightguard WatchKit Extension/Assets.xcassets/Contents.json b/nightguard WatchKit Extension/Assets.xcassets/Contents.json index da4a164c..73c00596 100644 --- a/nightguard WatchKit Extension/Assets.xcassets/Contents.json +++ b/nightguard WatchKit Extension/Assets.xcassets/Contents.json @@ -1,6 +1,6 @@ { "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/nightguard WatchKit Extension/ComplicationController.swift b/nightguard WatchKit Extension/ComplicationController.swift index e70646f4..0915da2e 100644 --- a/nightguard WatchKit Extension/ComplicationController.swift +++ b/nightguard WatchKit Extension/ComplicationController.swift @@ -30,6 +30,26 @@ class ComplicationController: NSObject, CLKComplicationDataSource { handler([]) } + fileprivate func createLine1And2TextProvider(_ currentNightscoutData: NightscoutData) -> (CLKTextProvider, CLKTextProvider) { + + var line1TextProvider : CLKTextProvider + var line2TextProvider : CLKTextProvider + + if useRelativeTimeWhenPossible { + line1TextProvider = CLKSimpleTextProvider(text: getSgvAndArrow(currentNightscoutData, " ")) + line1TextProvider.tintColor = UIColorChanger.getBgColor( + UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv)) + line2TextProvider = getRelativeDateTextProvider(for: currentNightscoutData.time) + } else { + line1TextProvider = CLKSimpleTextProvider(text: "\(currentNightscoutData.hourAndMinutes)") + line1TextProvider.tintColor = UIColorChanger.getBgColor( + UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv)) + line2TextProvider = CLKSimpleTextProvider(text: "\(UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv))\(currentNightscoutData.bgdeltaString)\(currentNightscoutData.bgdeltaArrow)") + } + + return (line1TextProvider, line2TextProvider) + } + func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) { let currentNightscoutData = NightscoutCacheService.singleton.getCurrentNightscoutData() @@ -40,19 +60,7 @@ class ComplicationController: NSObject, CLKComplicationDataSource { switch complication.family { case .modularSmall: - var line1TextProvider : CLKTextProvider - var line2TextProvider : CLKTextProvider - if useRelativeTimeWhenPossible { - line1TextProvider = CLKSimpleTextProvider(text: getSgvAndArrow(currentNightscoutData, " ")) - line1TextProvider.tintColor = UIColorChanger.getBgColor( - UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv)) - line2TextProvider = getRelativeDateTextProvider(for: currentNightscoutData.time) - } else { - line1TextProvider = CLKSimpleTextProvider(text: "\(currentNightscoutData.hourAndMinutes)") - line1TextProvider.tintColor = UIColorChanger.getBgColor( - UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv)) - line2TextProvider = CLKSimpleTextProvider(text: "\(UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv))\(currentNightscoutData.bgdeltaString)\(currentNightscoutData.bgdeltaArrow)") - } + let (line1TextProvider, line2TextProvider) = createLine1And2TextProvider(currentNightscoutData) let modTemplate = CLKComplicationTemplateModularSmallStackText(line1TextProvider: line1TextProvider, line2TextProvider: line2TextProvider) template = modTemplate @@ -110,6 +118,23 @@ class ComplicationController: NSObject, CLKComplicationDataSource { textProvider.tintColor = UIColorChanger.getBgColor( UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv)) template = CLKComplicationTemplateUtilitarianLargeFlat(textProvider: textProvider, imageProvider: imageProvider) + case .extraLarge: + let row1Col1 = CLKSimpleTextProvider(text: getOneLine(currentNightscoutData)) + row1Col1.tintColor = UIColorChanger.getBgColor( + UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv)) + let row1Col2 = getRelativeDateTextProvider(for: currentNightscoutData.time) + var row2Col1 = CLKSimpleTextProvider(text: "") + var row2Col2 = CLKSimpleTextProvider(text: "") + if self.oldNightscoutData.count > 1 { + let nightscoutData = self.oldNightscoutData[1] + row2Col1 = CLKSimpleTextProvider(text: getOneLine(nightscoutData)) + row2Col2 = getRelativeDateTextProvider(for: nightscoutData.time) as? CLKSimpleTextProvider ?? row2Col2 + } + + template = CLKComplicationTemplateExtraLargeColumnsText( + row1Column1TextProvider: row1Col1, row1Column2TextProvider: row1Col2, + row2Column1TextProvider: row2Col1, row2Column2TextProvider: row2Col2) + case .circularSmall: let textProvider = CLKSimpleTextProvider(text: @@ -136,13 +161,15 @@ class ComplicationController: NSObject, CLKComplicationDataSource { case .graphicCircular: if #available(watchOSApplicationExtension 5.0, *) { - let sgvLong = "\(UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv))" - let sgvShort = "\(UnitsConverter.mgdlToShortDisplayUnits(currentNightscoutData.sgv))" - let centerTextProvider = CLKSimpleTextProvider(text: sgvLong, shortText: sgvShort) - centerTextProvider.tintColor = UIColorChanger.getBgColor( + let line2TextProvider = CLKSimpleTextProvider(text: "\(UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv))") + line2TextProvider.tintColor = UIColorChanger.getBgColor( + UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv)) + + let line1TextProvider = CLKSimpleTextProvider(text: "\(currentNightscoutData.hourAndMinutes)") + line1TextProvider.tintColor = UIColorChanger.getBgColor( UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv)) - let gaugeProvider = CLKSimpleGaugeProvider(style: .fill, gaugeColor: UIColor.black, fillFraction: CLKSimpleGaugeProviderFillFractionEmpty) - template = CLKComplicationTemplateGraphicCircularClosedGaugeText(gaugeProvider: gaugeProvider, centerTextProvider: centerTextProvider) + + template = CLKComplicationTemplateGraphicCircularStackText(line1TextProvider: line1TextProvider, line2TextProvider: line2TextProvider) } else { abort() } @@ -157,6 +184,14 @@ class ComplicationController: NSObject, CLKComplicationDataSource { } else { abort() } + case .graphicExtraLarge: + + let (line1TextProvider, line2TextProvider) = createLine1And2TextProvider(currentNightscoutData) + + let modTemplate = CLKComplicationTemplateGraphicExtraLargeCircularStackText( + line1TextProvider: line1TextProvider, line2TextProvider: line2TextProvider) + + template = modTemplate default: break } @@ -242,10 +277,14 @@ class ComplicationController: NSObject, CLKComplicationDataSource { func getPlaceholderTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) { var template: CLKComplicationTemplate? = nil switch complication.family { + case .graphicExtraLarge: + template = nil case .modularSmall: template = nil case .modularLarge: template = nil + case .extraLarge: + template = nil case .utilitarianSmall: template = nil case .utilitarianLarge: @@ -260,13 +299,15 @@ class ComplicationController: NSObject, CLKComplicationDataSource { func getComplicationDescriptors(handler: @escaping ([CLKComplicationDescriptor]) -> Void) { let descriptors = [ - CLKComplicationDescriptor(identifier: "nightguardComplication", displayName: "Nightguard", + CLKComplicationDescriptor(identifier: "nightguardComplication", displayName: "BG Values", supportedFamilies: [CLKComplicationFamily.circularSmall, CLKComplicationFamily.graphicBezel, CLKComplicationFamily.graphicCorner, CLKComplicationFamily.graphicCircular, + CLKComplicationFamily.graphicExtraLarge, CLKComplicationFamily.modularLarge, CLKComplicationFamily.modularSmall, + CLKComplicationFamily.extraLarge, CLKComplicationFamily.utilitarianLarge, CLKComplicationFamily.utilitarianSmall]) ] diff --git a/nightguard WatchKit Extension/Info.plist b/nightguard WatchKit Extension/Info.plist index ad2f8921..9218feba 100644 --- a/nightguard WatchKit Extension/Info.plist +++ b/nightguard WatchKit Extension/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 779 + $(CURRENT_PROJECT_VERSION) CLKComplicationPrincipalClass $(PRODUCT_MODULE_NAME).ComplicationController NSAppTransportSecurity diff --git a/nightguard WatchKit Extension/MainViewModel.swift b/nightguard WatchKit Extension/MainViewModel.swift index 235af59e..7dc048b8 100644 --- a/nightguard WatchKit Extension/MainViewModel.swift +++ b/nightguard WatchKit Extension/MainViewModel.swift @@ -206,8 +206,10 @@ class MainViewModel: ObservableObject, Identifiable { fileprivate func updateComplication() { let complicationServer = CLKComplicationServer.sharedInstance() - for complication in complicationServer.activeComplications! { - complicationServer.reloadTimeline(for: complication) + if complicationServer.activeComplications != nil { + for complication in complicationServer.activeComplications! { + complicationServer.reloadTimeline(for: complication) + } } } diff --git a/nightguard WatchKit Extension/UserDefaultsRepository.swift b/nightguard WatchKit Extension/UserDefaultsRepository.swift index 9eeb0816..867b3565 100644 --- a/nightguard WatchKit Extension/UserDefaultsRepository.swift +++ b/nightguard WatchKit Extension/UserDefaultsRepository.swift @@ -62,19 +62,6 @@ class UserDefaultsRepository { key: "alarmSoundFileName", default: "") - static let showBGOnAppBadge = UserDefaultsValue( - key: "showBGOnAppBadge", - default: false, - onChange: { show in - #if os(iOS) - if show { - UIApplication.shared.setCurrentBGValueOnAppBadge() - } else { - UIApplication.shared.clearAppBadge() - } - #endif - }) - static let alarmNotificationState = UserDefaultsValue(key: "alarmNotificationState", default: false) // If this is set to true, you can override the default units setting from your backend @@ -101,13 +88,6 @@ class UserDefaultsRepository { static let maximumBloodGlucoseDisplayed = UserDefaultsValue(key: "maximumBloodGlucoseDisplayed", default: 350) #if os(iOS) - static let screenlockSwitchState = UserDefaultsValue( - key: "screenlockSwitchState", - default: UIApplication.shared.isIdleTimerDisabled, - onChange: { screenlock in - UIApplication.shared.isIdleTimerDisabled = screenlock - }) - static let nightscoutUris = UserDefaultsValue<[String]>(key: "nightscoutUris", default: []) // minutes of idle (user inactivity) before dimming the screen (0 means never) diff --git a/nightguard Widget Extension/Assets.xcassets/AccentColor.colorset/Contents.json b/nightguard Widget Extension/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/nightguard Widget Extension/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/nightguard Widget Extension/Assets.xcassets/AppIcon.appiconset/Contents.json b/nightguard Widget Extension/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..13613e3e --- /dev/null +++ b/nightguard Widget Extension/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/nightguard Widget Extension/Assets.xcassets/Contents.json b/nightguard Widget Extension/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/nightguard Widget Extension/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/nightguard Widget Extension/Assets.xcassets/WidgetBackground.colorset/Contents.json b/nightguard Widget Extension/Assets.xcassets/WidgetBackground.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/nightguard Widget Extension/Assets.xcassets/WidgetBackground.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/nightguard Widget Extension/Info.plist b/nightguard Widget Extension/Info.plist new file mode 100644 index 00000000..0f118fb7 --- /dev/null +++ b/nightguard Widget Extension/Info.plist @@ -0,0 +1,11 @@ + + + + + NSExtension + + NSExtensionPointIdentifier + com.apple.widgetkit-extension + + + diff --git a/nightguard Widget Extension/nightguard_Widget_Extension.intentdefinition b/nightguard Widget Extension/nightguard_Widget_Extension.intentdefinition new file mode 100644 index 00000000..bdb40455 --- /dev/null +++ b/nightguard Widget Extension/nightguard_Widget_Extension.intentdefinition @@ -0,0 +1,59 @@ + + + + + INEnums + + INIntentDefinitionModelVersion + 1.2 + INIntentDefinitionNamespace + 88xZPY + INIntentDefinitionSystemVersion + 20A294 + INIntentDefinitionToolsBuildVersion + 12A6144 + INIntentDefinitionToolsVersion + 12.0 + INIntents + + + INIntentCategory + information + INIntentDescriptionID + tVvJ9c + INIntentEligibleForWidgets + + INIntentIneligibleForSuggestions + + INIntentName + Configuration + INIntentResponse + + INIntentResponseCodes + + + INIntentResponseCodeName + success + INIntentResponseCodeSuccess + + + + INIntentResponseCodeName + failure + + + + INIntentTitle + Configuration + INIntentTitleID + gpCwrM + INIntentType + Custom + INIntentVerb + View + + + INTypes + + + diff --git a/nightguard Widget Extension/nightguard_Widget_Extension.swift b/nightguard Widget Extension/nightguard_Widget_Extension.swift new file mode 100644 index 00000000..9016330f --- /dev/null +++ b/nightguard Widget Extension/nightguard_Widget_Extension.swift @@ -0,0 +1,163 @@ +// +// nightguard_Widget_Extension.swift +// nightguard Widget Extension +// +// Created by Dirk Hermanns on 14.09.22. +// Copyright © 2022 private. All rights reserved. +// + +import WidgetKit +import SwiftUI +import Intents + +struct Provider: IntentTimelineProvider { + + func placeholder(in context: Context) -> NightscoutDataEntry { + + NightscoutDataEntry(configuration: ConfigurationIntent()) + } + + func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (NightscoutDataEntry) -> ()) { + + completion(getTimelineData(configuration: configuration)) + } + + func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline) -> ()) { + + var entries: [NightscoutDataEntry] = [] + + entries.append(getTimelineData(configuration: configuration)) + + let timeline = Timeline(entries: entries, policy: .atEnd) + completion(timeline) + } + + private func getTimelineData(configuration: ConfigurationIntent) -> NightscoutDataEntry { + let data = NightscoutDataRepository.singleton.loadCurrentNightscoutData() + + let entry = NightscoutDataEntry( + date: Date(timeIntervalSince1970: data.time.doubleValue / 1000), + sgv: data.sgv, + bgdeltaString: data.bgdeltaString, + bgdeltaArrow: data.bgdeltaArrow, + bgdelta: data.bgdelta, + time: data.time, + battery: data.battery, + iob: data.iob, + cob: data.cob, + configuration: configuration) + + return entry + } +} + +struct NightscoutDataEntry: TimelineEntry { + + var date: Date = Date() + + var sgv : String = "---" + // the delta Value in Display Units + var bgdeltaString : String = "---" + var bgdeltaArrow : String = "-" + // the delta value in mgdl + var bgdelta : Float = 0.0 + var hourAndMinutes : String { + get { + if time == 0 { + return "??:??" + } + let formatter = DateFormatter() + formatter.dateFormat = "HH:mm" + + let date = Date.init(timeIntervalSince1970: Double(time.int64Value / 1000)) + return formatter.string(from: date) + } + } + var timeString : String { + get { + if time == 0 { + return "-min" + } + + // trick: when displaying the time, we'll add 30 seconds to current time for showing the difference like Nightscout does (0-30 seconds: "0 mins", 31-90 seconds: "1 min", ...) + let thirtySeconds = Int64(30 * 1000) + + // calculate how old the current data is + let currentTime = Int64(Date().timeIntervalSince1970 * 1000) + thirtySeconds + let difference = (currentTime - time.int64Value) / 60000 + if difference > 59 { + return ">1Hr" + } + return String(difference) + "min" + } + } + var time : NSNumber = 0 + var battery : String = "---" + var iob : String = "" + var cob : String = "" + let configuration: ConfigurationIntent +} + +struct nightguard_Widget_ExtensionEntryView : View { + + @Environment(\.widgetFamily) + var widgetFamily + var entry: Provider.Entry + + var body: some View { + + switch widgetFamily { + case .accessoryInline: + Text("| \(entry.hourAndMinutes) \(UnitsConverter.mgdlToDisplayUnits(entry.sgv))\(UnitsConverter.mgdlToDisplayUnits(entry.bgdeltaString))\(entry.bgdeltaArrow)") + case .accessoryRectangular: + VStack(alignment: .leading) { + Text(Date(timeIntervalSince1970: entry.time.doubleValue / 1000), style: .relative) + Text("\(UnitsConverter.mgdlToDisplayUnits(entry.sgv))\(UnitsConverter.mgdlToDisplayUnits(entry.bgdeltaString))\(entry.bgdeltaArrow)") + Text("\(entry.cob) \(entry.iob)") + } + case .accessoryCircular: + VStack { + Text(entry.hourAndMinutes) + Text("\(UnitsConverter.mgdlToDisplayUnits(entry.sgv))\(UnitsConverter.mgdlToDisplayUnits(entry.bgdeltaString))") + Text("\(entry.bgdeltaArrow)") + } + + default: + Text("Not implemented.") + } + } +} + +@main +struct nightguard_Widget_Extension: Widget { + let kind: String = "nightguard_Widget_Extension" + + var body: some WidgetConfiguration { + IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in + nightguard_Widget_ExtensionEntryView(entry: entry) + } + .configurationDisplayName("nightguard widgets") + .description("Nightguard lockscreen widgets.") + .supportedFamilies( + [.accessoryInline, + .accessoryCircular, + .accessoryRectangular]) + } +} + +struct nightguard_Widget_Extension_Previews: PreviewProvider { + static var previews: some View { + + nightguard_Widget_ExtensionEntryView(entry: NightscoutDataEntry(date: Date(), configuration: ConfigurationIntent())) + .previewContext(WidgetPreviewContext(family: .accessoryInline)) + .previewDisplayName("Inline") + + nightguard_Widget_ExtensionEntryView(entry: NightscoutDataEntry(date: Date(), configuration: ConfigurationIntent())) + .previewContext(WidgetPreviewContext(family: .accessoryCircular)) + .previewDisplayName("Circular") + + nightguard_Widget_ExtensionEntryView(entry: NightscoutDataEntry(date: Date(), configuration: ConfigurationIntent())) + .previewContext(WidgetPreviewContext(family: .accessoryRectangular)) + .previewDisplayName("Rectangular") + } +} diff --git a/nightguard Widget ExtensionExtension.entitlements b/nightguard Widget ExtensionExtension.entitlements new file mode 100644 index 00000000..46693896 --- /dev/null +++ b/nightguard Widget ExtensionExtension.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.de.my-wan.dhe.nightguard + + + diff --git a/nightguard.xcodeproj/project.pbxproj b/nightguard.xcodeproj/project.pbxproj index 2f40e5dd..d50a586d 100644 --- a/nightguard.xcodeproj/project.pbxproj +++ b/nightguard.xcodeproj/project.pbxproj @@ -181,6 +181,38 @@ 438C55A2253C807B0002E109 /* CarbsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 438C55A1253C807B0002E109 /* CarbsController.swift */; }; 438C55A9253C81370002E109 /* CarbsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 438C55A8253C81370002E109 /* CarbsView.swift */; }; 438C55B0253CB0090002E109 /* AddCarbsPopupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 438C55AF253CB0090002E109 /* AddCarbsPopupView.swift */; }; + 438DAC7D28D2356800FBF520 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 438DAC7C28D2356800FBF520 /* WidgetKit.framework */; }; + 438DAC7F28D2356800FBF520 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 438DAC7E28D2356800FBF520 /* SwiftUI.framework */; }; + 438DAC8228D2356800FBF520 /* nightguard_Widget_Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 438DAC8128D2356800FBF520 /* nightguard_Widget_Extension.swift */; }; + 438DAC8528D2356A00FBF520 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 438DAC8428D2356A00FBF520 /* Assets.xcassets */; }; + 438DAC8728D2356A00FBF520 /* nightguard_Widget_Extension.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 438DAC8328D2356800FBF520 /* nightguard_Widget_Extension.intentdefinition */; }; + 438DAC8828D2356A00FBF520 /* nightguard_Widget_Extension.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 438DAC8328D2356800FBF520 /* nightguard_Widget_Extension.intentdefinition */; }; + 438DAC8B28D2356A00FBF520 /* nightguard Widget Extension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 438DAC7B28D2356800FBF520 /* nightguard Widget Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 438DAC9128D253BC00FBF520 /* NightscoutData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F1E0FA1D07698000C329A2 /* NightscoutData.swift */; }; + 438DAC9228D2593700FBF520 /* BloodSugar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F1E0EC1D07693300C329A2 /* BloodSugar.swift */; }; + 438DAC9328D2594D00FBF520 /* TemporaryTargetData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43BB4B0424CF5DBA00DE96BB /* TemporaryTargetData.swift */; }; + 438DAC9628D259AD00FBF520 /* NightscoutDataRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43794F451C303E4200DB8B58 /* NightscoutDataRepository.swift */; }; + 438DAC9728D259F800FBF520 /* UserDefaultsValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1D96CB021F85BC70035A60E /* UserDefaultsValue.swift */; }; + 438DAC9828D25A1600FBF520 /* UserDefaultsValueGroups.swift in Sources */ = {isa = PBXBuildFile; fileRef = D15055AB2200CD6500F31C1F /* UserDefaultsValueGroups.swift */; }; + 438DAC9928D25A2D00FBF520 /* DeviceStatusData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4303406824C9FF330088AB9A /* DeviceStatusData.swift */; }; + 438DAC9A28D25A3D00FBF520 /* AppConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43794F411C2F435A00DB8B58 /* AppConstants.swift */; }; + 438DAC9B28D25A8000FBF520 /* ObservationToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1ECDA1E2201075B002BE6F9 /* ObservationToken.swift */; }; + 438DAC9C28D25A8D00FBF520 /* TimeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F1E11A1D076D9700C329A2 /* TimeService.swift */; }; + 438DAC9D28D25AA200FBF520 /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1E6B896219C69D9007ED4FE /* Helpers.swift */; }; + 438DAC9E28D25AFF00FBF520 /* Units.swift in Sources */ = {isa = PBXBuildFile; fileRef = 432E62DE1D10ACD200DD7978 /* Units.swift */; }; + 438DAC9F28D25B2400FBF520 /* Treatment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4302C65625D9C7080052777F /* Treatment.swift */; }; + 438DACA028D25B3E00FBF520 /* AnyConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1AEFED721FE00A200821DF6 /* AnyConvertible.swift */; }; + 438DACA228D25B7B00FBF520 /* DoubleExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43288A6F1D20284600EE3999 /* DoubleExtension.swift */; }; + 438DACA428D25B8D00FBF520 /* DateExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4334D97F24C32B6D00652D87 /* DateExtension.swift */; }; + 438DACA528D25BA700FBF520 /* UIColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1ECDA252202C8F0002BE6F9 /* UIColorExtension.swift */; }; + 438DACA728D25BF400FBF520 /* FloatExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 432E62EA1D15EFC600DD7978 /* FloatExtension.swift */; }; + 438DACAB28D25CB000FBF520 /* QuickSnoozeOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = D16C8EDC22106C9300192117 /* QuickSnoozeOption.swift */; }; + 438DACAC28D25CC200FBF520 /* SnoozeMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1D96CC221FB0FA80035A60E /* SnoozeMessage.swift */; }; + 438DACAE28D25CDC00FBF520 /* VolumeChangeDetector.swift in Sources */ = {isa = PBXBuildFile; fileRef = D16C8EDA221068F000192117 /* VolumeChangeDetector.swift */; }; + 438DACAF28D25D0A00FBF520 /* MPVolumeViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D16C8ED82210687200192117 /* MPVolumeViewExtension.swift */; }; + 438DACB028D25D1400FBF520 /* TimerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D112DD3321E9E2DF00ECFB5E /* TimerExtension.swift */; }; + 438DACB128D25D2600FBF520 /* WatchMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1D96CB521FAF6890035A60E /* WatchMessage.swift */; }; + 438DACB528D25DB800FBF520 /* WatchMessageService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1D96CB921FB0E910035A60E /* WatchMessageService.swift */; }; 43961F4A2533598400B1492B /* ActivateTemporaryTargetPopupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43961F492533598400B1492B /* ActivateTemporaryTargetPopupView.swift */; }; 43961F6E25336F0600B1492B /* TemporaryTargetController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43961F6D25336F0600B1492B /* TemporaryTargetController.swift */; }; 43961F752533708D00B1492B /* TemporaryTargetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43961F742533708D00B1492B /* TemporaryTargetView.swift */; }; @@ -202,6 +234,9 @@ 43BB4B0624CF5DBA00DE96BB /* TemporaryTargetData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43BB4B0424CF5DBA00DE96BB /* TemporaryTargetData.swift */; }; 43BB4B0724CF5DBA00DE96BB /* TemporaryTargetData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43BB4B0424CF5DBA00DE96BB /* TemporaryTargetData.swift */; }; 43BB4B0824CF5DBA00DE96BB /* TemporaryTargetData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43BB4B0424CF5DBA00DE96BB /* TemporaryTargetData.swift */; }; + 43BE674428D78B9B00285798 /* UnitsConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 432E62E81D143CF900DD7978 /* UnitsConverter.swift */; }; + 43BE674528D78C0B00285798 /* UserDefaultsRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43794F4E1C343B9800DB8B58 /* UserDefaultsRepository.swift */; }; + 43BE674728D78C8C00285798 /* SharedUserDefaultsRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43BE674628D78C8C00285798 /* SharedUserDefaultsRepository.swift */; }; 43C87AF8202F21F10000F5F6 /* SnoozeInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C87AF7202F21F10000F5F6 /* SnoozeInterfaceController.swift */; }; 43CC9DF924E818BF0008F397 /* CareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43CC9DF824E818BF0008F397 /* CareViewController.swift */; }; 43CC9DFB24E819C60008F397 /* Care.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 43CC9DFD24E819C60008F397 /* Care.storyboard */; }; @@ -387,6 +422,13 @@ remoteGlobalIDString = 43647C001BFF6435004389F9; remoteInfo = "scoutwatch WatchKit Extension"; }; + 438DAC8928D2356A00FBF520 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 43647BC21BFF6435004389F9 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 438DAC7A28D2356800FBF520; + remoteInfo = "nightguard Widget ExtensionExtension"; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -412,6 +454,17 @@ name = "Embed Watch Content"; runOnlyForDeploymentPostprocessing = 0; }; + 438DAC8C28D2356A00FBF520 /* Embed Foundation Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 438DAC8B28D2356A00FBF520 /* nightguard Widget Extension.appex in Embed Foundation Extensions */, + ); + name = "Embed Foundation Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -503,6 +556,13 @@ 438C55A1253C807B0002E109 /* CarbsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarbsController.swift; sourceTree = ""; }; 438C55A8253C81370002E109 /* CarbsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarbsView.swift; sourceTree = ""; }; 438C55AF253CB0090002E109 /* AddCarbsPopupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddCarbsPopupView.swift; sourceTree = ""; }; + 438DAC7B28D2356800FBF520 /* nightguard Widget Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "nightguard Widget Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; + 438DAC7C28D2356800FBF520 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; + 438DAC7E28D2356800FBF520 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; + 438DAC8128D2356800FBF520 /* nightguard_Widget_Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = nightguard_Widget_Extension.swift; sourceTree = ""; }; + 438DAC8328D2356800FBF520 /* nightguard_Widget_Extension.intentdefinition */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; path = nightguard_Widget_Extension.intentdefinition; sourceTree = ""; }; + 438DAC8428D2356A00FBF520 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 438DAC8628D2356A00FBF520 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43961F492533598400B1492B /* ActivateTemporaryTargetPopupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivateTemporaryTargetPopupView.swift; sourceTree = ""; }; 43961F6D25336F0600B1492B /* TemporaryTargetController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemporaryTargetController.swift; sourceTree = ""; }; 43961F742533708D00B1492B /* TemporaryTargetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemporaryTargetView.swift; sourceTree = ""; }; @@ -516,6 +576,7 @@ 439FCEB71FD5E97F009D18FD /* BackgroundUrlSessionWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundUrlSessionWrapper.swift; sourceTree = ""; }; 43A0476A24D2023C0040D853 /* WKInterfaceLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WKInterfaceLabel.swift; sourceTree = ""; }; 43BB4B0424CF5DBA00DE96BB /* TemporaryTargetData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemporaryTargetData.swift; sourceTree = ""; }; + 43BE674628D78C8C00285798 /* SharedUserDefaultsRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedUserDefaultsRepository.swift; sourceTree = ""; }; 43C5DE9B24522F3B00BB41D9 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Main.strings; sourceTree = ""; }; 43C5DE9C24522F3D00BB41D9 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Alarm.strings; sourceTree = ""; }; 43C5DE9D24522F3E00BB41D9 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Stats.strings; sourceTree = ""; }; @@ -526,6 +587,7 @@ 43C5DEA224522F3F00BB41D9 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Interface.strings; sourceTree = ""; }; 43C5DEA324522F4000BB41D9 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = ""; }; 43C87AF7202F21F10000F5F6 /* SnoozeInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnoozeInterfaceController.swift; sourceTree = ""; }; + 43CB358D28D71F79002AF707 /* nightguard Widget ExtensionExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "nightguard Widget ExtensionExtension.entitlements"; sourceTree = ""; }; 43CC9DF824E818BF0008F397 /* CareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CareViewController.swift; sourceTree = ""; }; 43CC9DFC24E819C60008F397 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Care.storyboard; sourceTree = ""; }; 43CC9DFF24E819D20008F397 /* fi-FI */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "fi-FI"; path = "fi-FI.lproj/Care.strings"; sourceTree = ""; }; @@ -669,6 +731,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 438DAC7828D2356800FBF520 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 438DAC7F28D2356800FBF520 /* SwiftUI.framework in Frameworks */, + 438DAC7D28D2356800FBF520 /* WidgetKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 81615C31F20A3DB028BE7BC8 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -708,6 +779,8 @@ 648BD28BCECC705FD0778C58 /* Pods_nightguard_WatchKit_Extension.framework */, 7DF919C3CB4ABA9B339F76C9 /* Pods_nightguardTests.framework */, FD2A0D1B01CFED46A2591694 /* Pods_nightguardUITests.framework */, + 438DAC7C28D2356800FBF520 /* WidgetKit.framework */, + 438DAC7E28D2356800FBF520 /* SwiftUI.framework */, ); name = Frameworks; sourceTree = ""; @@ -773,11 +846,13 @@ 43647BC11BFF6435004389F9 = { isa = PBXGroup; children = ( + 43CB358D28D71F79002AF707 /* nightguard Widget ExtensionExtension.entitlements */, 43647BCC1BFF6435004389F9 /* nightguard */, 43647BE11BFF6435004389F9 /* nightguardTests */, 43647BEC1BFF6435004389F9 /* nightguardUITests */, 43647BF61BFF6435004389F9 /* nightguard WatchKit App */, 43647C051BFF6435004389F9 /* nightguard WatchKit Extension */, + 438DAC8028D2356800FBF520 /* nightguard Widget Extension */, 43647BCB1BFF6435004389F9 /* Products */, 0CC6802B2D6E9F7675874CD7 /* Pods */, 23C80CA818186A7AFE1C1929 /* Frameworks */, @@ -792,6 +867,7 @@ 43647BE91BFF6435004389F9 /* nightguard_uitests.xctest */, 43647BF21BFF6435004389F9 /* nightguard.app */, 43647C011BFF6435004389F9 /* nightguard.appex */, + 438DAC7B28D2356800FBF520 /* nightguard Widget Extension.appex */, ); name = Products; sourceTree = ""; @@ -894,6 +970,7 @@ 43794F451C303E4200DB8B58 /* NightscoutDataRepository.swift */, 43794F4E1C343B9800DB8B58 /* UserDefaultsRepository.swift */, 4351E6AF1D2EFA8C001E4AE4 /* StatisticsRepository.swift */, + 43BE674628D78C8C00285798 /* SharedUserDefaultsRepository.swift */, ); name = repository; sourceTree = ""; @@ -914,6 +991,17 @@ name = model; sourceTree = ""; }; + 438DAC8028D2356800FBF520 /* nightguard Widget Extension */ = { + isa = PBXGroup; + children = ( + 438DAC8128D2356800FBF520 /* nightguard_Widget_Extension.swift */, + 438DAC8328D2356800FBF520 /* nightguard_Widget_Extension.intentdefinition */, + 438DAC8428D2356A00FBF520 /* Assets.xcassets */, + 438DAC8628D2356A00FBF520 /* Info.plist */, + ); + path = "nightguard Widget Extension"; + sourceTree = ""; + }; 4398937A252BBF88007A252F /* controllers */ = { isa = PBXGroup; children = ( @@ -1143,11 +1231,13 @@ 43647BC81BFF6435004389F9 /* Resources */, 43647C1C1BFF6435004389F9 /* Embed Watch Content */, B558B068A5B821E9E0E607D5 /* [CP] Embed Pods Frameworks */, + 438DAC8C28D2356A00FBF520 /* Embed Foundation Extensions */, ); buildRules = ( ); dependencies = ( 43647BF51BFF6435004389F9 /* PBXTargetDependency */, + 438DAC8A28D2356A00FBF520 /* PBXTargetDependency */, ); name = nightguard; productName = scoutwatch; @@ -1230,13 +1320,30 @@ productReference = 43647C011BFF6435004389F9 /* nightguard.appex */; productType = "com.apple.product-type.watchkit2-extension"; }; + 438DAC7A28D2356800FBF520 /* nightguard Widget Extension */ = { + isa = PBXNativeTarget; + buildConfigurationList = 438DAC8F28D2356A00FBF520 /* Build configuration list for PBXNativeTarget "nightguard Widget Extension" */; + buildPhases = ( + 438DAC7728D2356800FBF520 /* Sources */, + 438DAC7828D2356800FBF520 /* Frameworks */, + 438DAC7928D2356800FBF520 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "nightguard Widget Extension"; + productName = "nightguard Widget ExtensionExtension"; + productReference = 438DAC7B28D2356800FBF520 /* nightguard Widget Extension.appex */; + productType = "com.apple.product-type.app-extension"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 43647BC21BFF6435004389F9 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 0710; + LastSwiftUpdateCheck = 1400; LastUpgradeCheck = 1200; ORGANIZATIONNAME = private; TargetAttributes = { @@ -1282,6 +1389,9 @@ }; }; }; + 438DAC7A28D2356800FBF520 = { + CreatedOnToolsVersion = 14.0; + }; }; }; buildConfigurationList = 43647BC51BFF6435004389F9 /* Build configuration list for PBXProject "nightguard" */; @@ -1304,6 +1414,7 @@ 43647BE81BFF6435004389F9 /* nightguardUITests */, 43647BF11BFF6435004389F9 /* nightguard WatchKit App */, 43647C001BFF6435004389F9 /* nightguard WatchKit Extension */, + 438DAC7A28D2356800FBF520 /* nightguard Widget Extension */, ); }; /* End PBXProject section */ @@ -1364,6 +1475,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 438DAC7928D2356800FBF520 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 438DAC8528D2356A00FBF520 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -1596,6 +1715,7 @@ 43119B941C3AAE6600DD6D35 /* UIColorChanger.swift in Sources */, D1D96CC021FB0F2E0035A60E /* UserDefaultsSyncMessage.swift in Sources */, D1AEFED821FE00A200821DF6 /* AnyConvertible.swift in Sources */, + 438DAC8828D2356A00FBF520 /* nightguard_Widget_Extension.intentdefinition in Sources */, D133079221C85FAE00DC6879 /* RegressionHelper.swift in Sources */, 4302C65725D9C7080052777F /* Treatment.swift in Sources */, D123EFE821FB643D00CE8718 /* EmptyWatchMessage.swift in Sources */, @@ -1616,6 +1736,7 @@ 4302C69125DC4F530052777F /* CorrectionBolusTreatment.swift in Sources */, 434982352534DE4F00CF0014 /* DictionaryExtension.swift in Sources */, D160D092220E4249002B4633 /* AlertVolumeViewController.swift in Sources */, + 43BE674728D78C8C00285798 /* SharedUserDefaultsRepository.swift in Sources */, D133078421C424A800DC6879 /* ArrayExtension.swift in Sources */, D1DA7C6C21BE810900B39675 /* UIApplicationExtension.swift in Sources */, 4302C65E25D9C7A80052777F /* MealBolusTreatment.swift in Sources */, @@ -1863,6 +1984,42 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 438DAC7728D2356800FBF520 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 438DACAB28D25CB000FBF520 /* QuickSnoozeOption.swift in Sources */, + 438DAC9E28D25AFF00FBF520 /* Units.swift in Sources */, + 438DAC9828D25A1600FBF520 /* UserDefaultsValueGroups.swift in Sources */, + 438DAC9C28D25A8D00FBF520 /* TimeService.swift in Sources */, + 438DAC9328D2594D00FBF520 /* TemporaryTargetData.swift in Sources */, + 438DAC8228D2356800FBF520 /* nightguard_Widget_Extension.swift in Sources */, + 438DAC9228D2593700FBF520 /* BloodSugar.swift in Sources */, + 438DAC9B28D25A8000FBF520 /* ObservationToken.swift in Sources */, + 438DAC9628D259AD00FBF520 /* NightscoutDataRepository.swift in Sources */, + 43BE674528D78C0B00285798 /* UserDefaultsRepository.swift in Sources */, + 438DACB128D25D2600FBF520 /* WatchMessage.swift in Sources */, + 438DACB528D25DB800FBF520 /* WatchMessageService.swift in Sources */, + 438DAC9128D253BC00FBF520 /* NightscoutData.swift in Sources */, + 438DACAC28D25CC200FBF520 /* SnoozeMessage.swift in Sources */, + 438DACA528D25BA700FBF520 /* UIColorExtension.swift in Sources */, + 438DACB028D25D1400FBF520 /* TimerExtension.swift in Sources */, + 438DACAE28D25CDC00FBF520 /* VolumeChangeDetector.swift in Sources */, + 438DAC9728D259F800FBF520 /* UserDefaultsValue.swift in Sources */, + 438DACA228D25B7B00FBF520 /* DoubleExtension.swift in Sources */, + 438DAC8728D2356A00FBF520 /* nightguard_Widget_Extension.intentdefinition in Sources */, + 438DACA428D25B8D00FBF520 /* DateExtension.swift in Sources */, + 438DAC9D28D25AA200FBF520 /* Helpers.swift in Sources */, + 438DAC9F28D25B2400FBF520 /* Treatment.swift in Sources */, + 438DAC9A28D25A3D00FBF520 /* AppConstants.swift in Sources */, + 438DACA728D25BF400FBF520 /* FloatExtension.swift in Sources */, + 438DACAF28D25D0A00FBF520 /* MPVolumeViewExtension.swift in Sources */, + 438DAC9928D25A2D00FBF520 /* DeviceStatusData.swift in Sources */, + 438DACA028D25B3E00FBF520 /* AnyConvertible.swift in Sources */, + 43BE674428D78B9B00285798 /* UnitsConverter.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -1886,6 +2043,11 @@ target = 43647C001BFF6435004389F9 /* nightguard WatchKit Extension */; targetProxy = 43647C031BFF6435004389F9 /* PBXContainerItemProxy */; }; + 438DAC8A28D2356A00FBF520 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 438DAC7A28D2356800FBF520 /* nightguard Widget Extension */; + targetProxy = 438DAC8928D2356A00FBF520 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -2119,7 +2281,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 779; + CURRENT_PROJECT_VERSION = 785; DEVELOPMENT_TEAM = BSAVUVP8PV; INFOPLIST_FILE = "nightguard WatchKit Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( @@ -2127,7 +2289,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 3.7.1; + MARKETING_VERSION = 3.7.2; PRODUCT_BUNDLE_IDENTIFIER = "de.my-wan.dhe.nightguard.watchkitapp.watchkitextension"; PRODUCT_NAME = nightguard; PROVISIONING_PROFILE = ""; @@ -2150,7 +2312,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 779; + CURRENT_PROJECT_VERSION = 785; DEVELOPMENT_TEAM = BSAVUVP8PV; INFOPLIST_FILE = "nightguard WatchKit Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( @@ -2158,7 +2320,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 3.7.1; + MARKETING_VERSION = 3.7.2; PRODUCT_BUNDLE_IDENTIFIER = "de.my-wan.dhe.nightguard.watchkitapp.watchkitextension"; PRODUCT_NAME = nightguard; PROVISIONING_PROFILE = ""; @@ -2182,7 +2344,7 @@ CODE_SIGN_ENTITLEMENTS = "nightguard WatchKit App/nightguard.entitlements"; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 779; + CURRENT_PROJECT_VERSION = 785; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = BSAVUVP8PV; IBSC_MODULE = scoutwatch_WatchKit_Extension; @@ -2192,7 +2354,7 @@ "@executable_path/../Frameworks", "@loader_path/../Frameworks", ); - MARKETING_VERSION = 3.7.1; + MARKETING_VERSION = 3.7.2; PRODUCT_BUNDLE_IDENTIFIER = "de.my-wan.dhe.nightguard.watchkitapp"; PRODUCT_NAME = nightguard; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2215,7 +2377,7 @@ CODE_SIGN_ENTITLEMENTS = "nightguard WatchKit App/nightguard.entitlements"; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 779; + CURRENT_PROJECT_VERSION = 785; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = BSAVUVP8PV; IBSC_MODULE = scoutwatch_WatchKit_Extension; @@ -2225,7 +2387,7 @@ "@executable_path/../Frameworks", "@loader_path/../Frameworks", ); - MARKETING_VERSION = 3.7.1; + MARKETING_VERSION = 3.7.2; PRODUCT_BUNDLE_IDENTIFIER = "de.my-wan.dhe.nightguard.watchkitapp"; PRODUCT_NAME = nightguard; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2241,11 +2403,12 @@ isa = XCBuildConfiguration; baseConfigurationReference = 69F9AFF1EF78A172349B22B6 /* Pods-nightguard.debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = nightguard/scoutwatch.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 779; + CURRENT_PROJECT_VERSION = 785; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = BSAVUVP8PV; ENABLE_BITCODE = NO; @@ -2254,7 +2417,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.7.1; + MARKETING_VERSION = 3.7.2; PRODUCT_BUNDLE_IDENTIFIER = "de.my-wan.dhe.nightguard"; PRODUCT_NAME = nightguard; PROVISIONING_PROFILE = ""; @@ -2269,11 +2432,12 @@ isa = XCBuildConfiguration; baseConfigurationReference = 0BC4D92A1BF3678D2BB7E48B /* Pods-nightguard.release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = nightguard/scoutwatch.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 779; + CURRENT_PROJECT_VERSION = 785; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = BSAVUVP8PV; ENABLE_BITCODE = NO; @@ -2282,7 +2446,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.7.1; + MARKETING_VERSION = 3.7.2; PRODUCT_BUNDLE_IDENTIFIER = "de.my-wan.dhe.nightguard"; PRODUCT_NAME = nightguard; PROVISIONING_PROFILE = ""; @@ -2374,6 +2538,86 @@ }; name = Release; }; + 438DAC8D28D2356A00FBF520 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = "nightguard Widget ExtensionExtension.entitlements"; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = BSAVUVP8PV; + GCC_C_LANGUAGE_STANDARD = gnu11; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "nightguard Widget Extension/Info.plist"; + INFOPLIST_KEY_CFBundleDisplayName = "nightguard Widget Extension"; + INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2022 private. All rights reserved."; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "de.my-wan.dhe.nightguard.widgetextension"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 438DAC8E28D2356A00FBF520 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = "nightguard Widget ExtensionExtension.entitlements"; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = BSAVUVP8PV; + GCC_C_LANGUAGE_STANDARD = gnu11; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "nightguard Widget Extension/Info.plist"; + INFOPLIST_KEY_CFBundleDisplayName = "nightguard Widget Extension"; + INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2022 private. All rights reserved."; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "de.my-wan.dhe.nightguard.widgetextension"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -2431,6 +2675,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 438DAC8F28D2356A00FBF520 /* Build configuration list for PBXNativeTarget "nightguard Widget Extension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 438DAC8D28D2356A00FBF520 /* Debug */, + 438DAC8E28D2356A00FBF520 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 43647BC21BFF6435004389F9 /* Project object */; diff --git a/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/nightguard WatchKit App (Complication).xcscheme b/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/nightguard WatchKit App (Complication).xcscheme index 5f14617f..665aa055 100644 --- a/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/nightguard WatchKit App (Complication).xcscheme +++ b/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/nightguard WatchKit App (Complication).xcscheme @@ -78,10 +78,8 @@ debugServiceExtension = "internal" allowLocationSimulation = "YES" launchAutomaticallySubstyle = "32"> - + - + - + - - - - - + diff --git a/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/nightguard WatchKit App (Notification).xcscheme b/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/nightguard WatchKit App (Notification).xcscheme index 3b5cb990..96aa4853 100644 --- a/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/nightguard WatchKit App (Notification).xcscheme +++ b/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/nightguard WatchKit App (Notification).xcscheme @@ -79,10 +79,8 @@ allowLocationSimulation = "YES" launchAutomaticallySubstyle = "8" notificationPayloadFile = "nightguard WatchKit Extension/PushNotificationPayload.apns"> - + - + - + - - - - - + diff --git a/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/nightguard WatchKit App.xcscheme b/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/nightguard WatchKit App.xcscheme index dbe6f48a..16192b98 100644 --- a/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/nightguard WatchKit App.xcscheme +++ b/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/nightguard WatchKit App.xcscheme @@ -79,10 +79,8 @@ allowLocationSimulation = "YES" launchAutomaticallySubstyle = "32" notificationPayloadFile = "nightguard WatchKit Extension/PushNotificationPayload.apns"> - + - + - + - - - - - + diff --git a/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/xcschememanagement.plist b/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/xcschememanagement.plist index 0c85b4e1..fdb7b1a3 100644 --- a/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/nightguard.xcodeproj/xcuserdata/dirk.xcuserdatad/xcschemes/xcschememanagement.plist @@ -19,6 +19,16 @@ orderHint 1 + nightguard Widget Extension.xcscheme_^#shared#^_ + + orderHint + 11 + + nightguard Widget ExtensionExtension.xcscheme_^#shared#^_ + + orderHint + 11 + nightguard.xcscheme_^#shared#^_ orderHint diff --git a/nightguard/AlarmNotificationService.swift b/nightguard/AlarmNotificationService.swift index 4b45baa6..bb1c95f1 100644 --- a/nightguard/AlarmNotificationService.swift +++ b/nightguard/AlarmNotificationService.swift @@ -81,7 +81,7 @@ class AlarmNotificationService { content.body = "\(alarmActivationReason)" if let sgv = Float(UnitsConverter.mgdlToDisplayUnits(nightscoutData.sgv)) { // display the current sgv on appbadge only if the user actived it: - if UserDefaultsRepository.showBGOnAppBadge.value { + if SharedUserDefaultsRepository.showBGOnAppBadge.value { content.badge = NSNumber(value: sgv) } } diff --git a/nightguard/AppDelegate.swift b/nightguard/AppDelegate.swift index 37dc5785..d95e57eb 100644 --- a/nightguard/AppDelegate.swift +++ b/nightguard/AppDelegate.swift @@ -42,12 +42,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ) // set "prevent screen lock" to ON when the app is started for the first time - if !UserDefaultsRepository.screenlockSwitchState.exists { - UserDefaultsRepository.screenlockSwitchState.value = true + if !SharedUserDefaultsRepository.screenlockSwitchState.exists { + SharedUserDefaultsRepository.screenlockSwitchState.value = true } // set the "prevent screen lock" option when the app is started - UIApplication.shared.isIdleTimerDisabled = UserDefaultsRepository.screenlockSwitchState.value + UIApplication.shared.isIdleTimerDisabled = SharedUserDefaultsRepository.screenlockSwitchState.value AlarmSound.volumeChangeDetector.onVolumeChange = { [weak self] in self?.window?.rootViewController?.handleQuickSnooze(option: UserDefaultsRepository.volumeKeysOnAlertSnoozeOption.value) @@ -89,7 +89,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } let updateWindowUserInteractionTimeout = { - if UserDefaultsRepository.screenlockSwitchState.value { + if SharedUserDefaultsRepository.screenlockSwitchState.value { window.timeout = TimeInterval(UserDefaultsRepository.dimScreenWhenIdle.value * 60) } else { window.timeout = nil @@ -100,7 +100,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { UserDefaultsRepository.dimScreenWhenIdle.observeChanges { _ in updateWindowUserInteractionTimeout() } - UserDefaultsRepository.screenlockSwitchState.observeChanges { _ in + SharedUserDefaultsRepository.screenlockSwitchState.observeChanges { _ in updateWindowUserInteractionTimeout() } @@ -217,7 +217,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } // update app badge - if UserDefaultsRepository.showBGOnAppBadge.value { + if SharedUserDefaultsRepository.showBGOnAppBadge.value { UIApplication.shared.setCurrentBGValueOnAppBadge() } diff --git a/nightguard/Info.plist b/nightguard/Info.plist index d30e8354..7e192f9b 100644 --- a/nightguard/Info.plist +++ b/nightguard/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 779 + 785 ITSAppUsesNonExemptEncryption LSApplicationCategoryType diff --git a/nightguard/MainViewController.swift b/nightguard/MainViewController.swift index 81879df6..06a0dbae 100644 --- a/nightguard/MainViewController.swift +++ b/nightguard/MainViewController.swift @@ -457,7 +457,7 @@ class MainViewController: UIViewController, SlideToSnoozeDelegate { self.evaluateAlarmActivationState() // update app badge - if UserDefaultsRepository.showBGOnAppBadge.value { + if SharedUserDefaultsRepository.showBGOnAppBadge.value { UIApplication.shared.setCurrentBGValueOnAppBadge() } diff --git a/nightguard/NightscoutService.swift b/nightguard/NightscoutService.swift index 11d1eb10..67d77620 100644 --- a/nightguard/NightscoutService.swift +++ b/nightguard/NightscoutService.swift @@ -141,7 +141,7 @@ class NightscoutService { } } - /* Reads all data between two timestamps and limits the maximum return values to 400. */ + /* Reads all data between two timestamps and limits the maximum return values to 1440. */ @discardableResult func readChartDataWithinPeriodOfTime(oldValues : [BloodSugar], _ timestamp1 : Date, timestamp2 : Date, resultHandler : @escaping (NightscoutRequestResult<[BloodSugar]>) -> Void) -> URLSessionTask? { @@ -158,7 +158,7 @@ class NightscoutService { let chartDataWithinPeriodOfTimeQueryParams = [ "find[date][$gt]" : "\(unixTimestamp1)", "find[date][$lte]" : "\(unixTimestamp2)", - "count" : "400", + "count" : "1440", ] let url = UserDefaultsRepository.getUrlWithPathAndQueryParameters(path: "api/v1/entries.json", queryParams: chartDataWithinPeriodOfTimeQueryParams) diff --git a/nightguard/PrefsViewController.swift b/nightguard/PrefsViewController.swift index f6f3d43e..243c6198 100644 --- a/nightguard/PrefsViewController.swift +++ b/nightguard/PrefsViewController.swift @@ -138,18 +138,18 @@ class PrefsViewController: CustomFormViewController { +++ Section(footer: NSLocalizedString("Keeping the screen active is of paramount importance if using the app as a night guard. We suggest leaving it ALWAYS ON.", comment: "Footer for Dim Screen")) <<< SwitchRow("KeepScreenActive") { row in row.title = NSLocalizedString("Keep the Screen Active", comment: "Label for Keep the Screen Active") - row.value = UserDefaultsRepository.screenlockSwitchState.value + row.value = SharedUserDefaultsRepository.screenlockSwitchState.value }.onChange { [weak self] row in guard let value = row.value else { return } if value { - UserDefaultsRepository.screenlockSwitchState.value = value + SharedUserDefaultsRepository.screenlockSwitchState.value = value } else { self?.showYesNoAlert( title: NSLocalizedString("ARE YOU SURE?", comment: "Title for confirmation"), message: NSLocalizedString("Keep this switch ON to disable the screenlock and prevent the app to get stopped!", comment: "Message for confirmation"), yesHandler: { - UserDefaultsRepository.screenlockSwitchState.value = value + SharedUserDefaultsRepository.screenlockSwitchState.value = value }, noHandler: { row.value = true @@ -198,10 +198,10 @@ class PrefsViewController: CustomFormViewController { <<< SwitchRow() { row in row.title = NSLocalizedString("Show BG on App Badge", comment: "Label for Show BG on Badge") - row.value = UserDefaultsRepository.showBGOnAppBadge.value + row.value = SharedUserDefaultsRepository.showBGOnAppBadge.value }.onChange { row in guard let value = row.value else { return } - UserDefaultsRepository.showBGOnAppBadge.value = value + SharedUserDefaultsRepository.showBGOnAppBadge.value = value } <<< SwitchRow() { row in diff --git a/nightguard/SharedUserDefaultsRepository.swift b/nightguard/SharedUserDefaultsRepository.swift new file mode 100644 index 00000000..257249ee --- /dev/null +++ b/nightguard/SharedUserDefaultsRepository.swift @@ -0,0 +1,40 @@ +// +// SharedUserDefaultsRepository.swift +// nightguard +// +// Created by Dirk Hermanns on 18.09.22. +// Copyright © 2022 private. All rights reserved. +// + +import Foundation +import UIKit + +/* + * UserDefaults that need access to a shared reference. + * This is separated from the UserDefaultsRepository, since it can't be used + * from a Widget. + */ +class SharedUserDefaultsRepository { + + static let showBGOnAppBadge = UserDefaultsValue( + key: "showBGOnAppBadge", + default: false, + onChange: { show in + #if os(iOS) + if show { + UIApplication.shared.setCurrentBGValueOnAppBadge() + } else { + UIApplication.shared.clearAppBadge() + } + #endif + }) + + #if os(iOS) + static let screenlockSwitchState = UserDefaultsValue( + key: "screenlockSwitchState", + default: UIApplication.shared.isIdleTimerDisabled, + onChange: { screenlock in + UIApplication.shared.isIdleTimerDisabled = screenlock + }) + #endif +} diff --git a/nightguard/UIApplicationExtension.swift b/nightguard/UIApplicationExtension.swift index 3cfd8954..7a4b6cf1 100644 --- a/nightguard/UIApplicationExtension.swift +++ b/nightguard/UIApplicationExtension.swift @@ -22,7 +22,7 @@ extension UIApplication { } let sgvAsInt = Int(sgvAsDouble.rounded()) - UNUserNotificationCenter.current().requestAuthorization(options: .badge) { (granted, error) in + UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .alert, .sound, .criticalAlert]) { (granted, error) in if granted && error == nil { // success! diff --git a/nightguardTests/Info.plist b/nightguardTests/Info.plist index c73b31a9..fa399202 100644 --- a/nightguardTests/Info.plist +++ b/nightguardTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 779 + 785 diff --git a/nightguardUITests/Info.plist b/nightguardUITests/Info.plist index c73b31a9..fa399202 100644 --- a/nightguardUITests/Info.plist +++ b/nightguardUITests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 779 + 785