Skip to content

Commit 4f30cb3

Browse files
authored
Merge pull request #868 from LoopKit/dev
Release 1.9.4
2 parents 8f529a4 + 457dd18 commit 4f30cb3

File tree

217 files changed

+4448
-3972
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+4448
-3972
lines changed

Cartfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
github "LoopKit/LoopKit" == 2.1.5
2-
github "LoopKit/CGMBLEKit" == 2.1.1
1+
2+
github "LoopKit/LoopKit" == 2.2.1
3+
github "LoopKit/CGMBLEKit" == 3.0
34
github "i-schuetz/SwiftCharts" == 0.6.2
4-
github "mddub/dexcom-share-client-swift" == 0.4.1
5-
github "mddub/G4ShareSpy" == 0.3.3
6-
github "ps2/rileylink_ios" == 2.0.7
5+
github "LoopKit/dexcom-share-client-swift" == 1.0
6+
github "LoopKit/G4ShareSpy" == 1.0
7+
github "ps2/rileylink_ios" == 2.1.0
78
github "LoopKit/Amplitude-iOS" "decreepify"

Cartfile.resolved

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github "LoopKit/Amplitude-iOS" "2137d5fd44bf630ed33e1e72d7af6d8f8612f270"
2-
github "LoopKit/CGMBLEKit" "v2.1.1"
3-
github "LoopKit/LoopKit" "v2.1.5"
2+
github "LoopKit/CGMBLEKit" "v3.0"
3+
github "LoopKit/G4ShareSpy" "v1.0"
4+
github "LoopKit/LoopKit" "v2.2.1"
5+
github "LoopKit/dexcom-share-client-swift" "v1.0"
46
github "i-schuetz/SwiftCharts" "0.6.2"
5-
github "mddub/G4ShareSpy" "v0.3.3"
6-
github "mddub/dexcom-share-client-swift" "v0.4.1"
7-
github "ps2/rileylink_ios" "v2.0.7"
7+
github "ps2/rileylink_ios" "v2.1.0"
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>INEnums</key>
6+
<array/>
7+
<key>INIntentDefinitionModelVersion</key>
8+
<string>1.0</string>
9+
<key>INIntentDefinitionSystemVersion</key>
10+
<string>17G65</string>
11+
<key>INIntentDefinitionToolsBuildVersion</key>
12+
<string>10L232m</string>
13+
<key>INIntentDefinitionToolsVersion</key>
14+
<string>10.0</string>
15+
<key>INIntents</key>
16+
<array>
17+
<dict>
18+
<key>INIntentCategory</key>
19+
<string>create</string>
20+
<key>INIntentDescriptionID</key>
21+
<string>yc02Yq</string>
22+
<key>INIntentLastParameterTag</key>
23+
<integer>0</integer>
24+
<key>INIntentName</key>
25+
<string>NewCarbEntry</string>
26+
<key>INIntentParameterCombinations</key>
27+
<dict>
28+
<key></key>
29+
<dict>
30+
<key>INIntentParameterCombinationIsPrimary</key>
31+
<true/>
32+
<key>INIntentParameterCombinationSubtitle</key>
33+
<string></string>
34+
<key>INIntentParameterCombinationSubtitleID</key>
35+
<string>bOiZXO</string>
36+
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
37+
<false/>
38+
<key>INIntentParameterCombinationTitle</key>
39+
<string>Add Carb Entry</string>
40+
<key>INIntentParameterCombinationTitleID</key>
41+
<string>OcNxIj</string>
42+
</dict>
43+
</dict>
44+
<key>INIntentParameters</key>
45+
<array/>
46+
<key>INIntentResponse</key>
47+
<dict>
48+
<key>INIntentResponseCodes</key>
49+
<array>
50+
<dict>
51+
<key>INIntentResponseCodeFormatString</key>
52+
<string></string>
53+
<key>INIntentResponseCodeFormatStringID</key>
54+
<string>SP7STY</string>
55+
<key>INIntentResponseCodeName</key>
56+
<string>failure</string>
57+
<key>INIntentResponseCodeSuccess</key>
58+
<false/>
59+
</dict>
60+
<dict>
61+
<key>INIntentResponseCodeFormatString</key>
62+
<string></string>
63+
<key>INIntentResponseCodeFormatStringID</key>
64+
<string>I1DB3p</string>
65+
<key>INIntentResponseCodeName</key>
66+
<string>success</string>
67+
<key>INIntentResponseCodeSuccess</key>
68+
<true/>
69+
</dict>
70+
</array>
71+
<key>INIntentResponseLastParameterTag</key>
72+
<integer>0</integer>
73+
<key>INIntentResponseParameters</key>
74+
<array/>
75+
</dict>
76+
<key>INIntentRestrictions</key>
77+
<integer>0</integer>
78+
<key>INIntentTitle</key>
79+
<string>Add Carb Entry</string>
80+
<key>INIntentTitleID</key>
81+
<string>80eo5o</string>
82+
<key>INIntentType</key>
83+
<string>Custom</string>
84+
<key>INIntentUserConfirmationRequired</key>
85+
<false/>
86+
<key>INIntentVerb</key>
87+
<string>Add</string>
88+
</dict>
89+
</array>
90+
</dict>
91+
</plist>

Common/Extensions/Double.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// Double.swift
3+
// Loop
4+
//
5+
// Copyright © 2018 LoopKit Authors. All rights reserved.
6+
//
7+
8+
import Foundation
9+
10+
11+
extension FloatingPoint {
12+
func floored(to increment: Self) -> Self {
13+
if increment == 0 {
14+
return self
15+
}
16+
17+
return floor(self / increment) * increment
18+
}
19+
20+
func ceiled(to increment: Self) -> Self {
21+
if increment == 0 {
22+
return self
23+
}
24+
25+
return ceil(self / increment) * increment
26+
}
27+
}
28+

Loop/Extensions/GlucoseRangeSchedule.swift renamed to Common/Extensions/GlucoseRangeSchedule.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,26 @@ extension GlucoseRangeSchedule {
2323
return override.isActive()
2424
}
2525

26-
var activeOverrideContext: GlucoseRangeSchedule.Override.Context? {
26+
var activeOverride: GlucoseRangeSchedule.Override? {
2727
guard let override = override, override.isActive() else {
2828
return nil
2929
}
3030

31-
return override.context
31+
return override
32+
}
33+
34+
var activeOverrideContext: GlucoseRangeSchedule.Override.Context? {
35+
return activeOverride?.context
36+
}
37+
38+
var activeOverrideQuantityRange: Range<HKQuantity>? {
39+
guard let activeOverride = activeOverride else {
40+
return nil
41+
}
42+
43+
let lowerBound = HKQuantity(unit: unit, doubleValue: activeOverride.value.minValue)
44+
let upperBound = HKQuantity(unit: unit, doubleValue: activeOverride.value.maxValue)
45+
return lowerBound..<upperBound
3246
}
3347

3448
var configuredOverrideContexts: [GlucoseRangeSchedule.Override.Context] {

Common/Extensions/HKUnit.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import HealthKit
1414
extension HKUnit {
1515
// A formatting helper for determining the preferred decimal style for a given unit
1616
var preferredFractionDigits: Int {
17-
if self.unitString == "mg/dL" {
17+
if self == .milligramsPerDeciliter {
1818
return 0
1919
} else {
2020
return 1
@@ -45,7 +45,7 @@ extension HKUnit {
4545

4646
/// An example value for the "ideal" target
4747
var glucoseExampleTargetValue: Double {
48-
if unitString == "mg/dL" {
48+
if self == .milligramsPerDeciliter {
4949
return 100
5050
} else {
5151
return 5.5
@@ -54,7 +54,7 @@ extension HKUnit {
5454

5555
/// The smallest value expected to be visible on a chart
5656
var chartableIncrement: Double {
57-
if unitString == "mg/dL" {
57+
if self == .milligramsPerDeciliter {
5858
return 1
5959
} else {
6060
return 1 / 25
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// NSUserActivity.swift
3+
// Loop
4+
//
5+
// Copyright © 2018 LoopKit Authors. All rights reserved.
6+
//
7+
8+
import Foundation
9+
10+
11+
extension NSUserActivity {
12+
/// Activity of viewing the current status of the Loop
13+
static let viewLoopStatusActivityType = "ViewLoopStatus"
14+
15+
class func forViewLoopStatus() -> NSUserActivity {
16+
return NSUserActivity(activityType: viewLoopStatusActivityType)
17+
}
18+
19+
static let didAddCarbEntryOnWatchActivityType = "com.loopkit.Loop.AddCarbEntryOnWatch"
20+
21+
class func forDidAddCarbEntryOnWatch() -> NSUserActivity {
22+
let activity = NSUserActivity(activityType: didAddCarbEntryOnWatchActivityType)
23+
activity.isEligibleForSearch = true
24+
activity.isEligibleForHandoff = false
25+
activity.isEligibleForPublicIndexing = false
26+
if #available(iOS 12.0, watchOSApplicationExtension 5.0, *) {
27+
activity.isEligibleForPrediction = true
28+
}
29+
activity.requiredUserInfoKeys = []
30+
activity.title = NSLocalizedString("Add Carb Entry", comment: "Title of the user activity for adding carbs")
31+
return activity
32+
}
33+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//
2+
// NewCarbEntryIntent+Loop.swift
3+
// Loop
4+
//
5+
// Copyright © 2018 LoopKit Authors. All rights reserved.
6+
//
7+
8+
import Foundation
9+
10+
@available(iOS 12.0, watchOSApplicationExtension 5.0, *)
11+
extension NewCarbEntryIntent: IdentifiableClass { }

Common/Extensions/PersistenceController.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,14 @@ extension PersistenceController {
2020

2121
return self.init(directoryURL: directoryURL.appendingPathComponent("com.loopkit.LoopKit", isDirectory: true), isReadOnly: isReadOnly)
2222
}
23+
24+
class func controllerInLocalDirectory() -> PersistenceController {
25+
guard let directoryURL = try? FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true) else {
26+
fatalError("Could not access the document directory of the current process")
27+
}
28+
29+
let isReadOnly = Bundle.main.bundleURL.pathExtension == "appex"
30+
31+
return self.init(directoryURL: directoryURL.appendingPathComponent("com.loopkit.LoopKit"), isReadOnly: isReadOnly)
32+
}
2333
}

Common/Extensions/SampleValue.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// SampleValue.swift
3+
// Loop
4+
//
5+
// Copyright © 2018 LoopKit Authors. All rights reserved.
6+
//
7+
8+
import HealthKit
9+
import LoopKit
10+
11+
12+
extension Collection where Element == SampleValue {
13+
/// O(n)
14+
var quantityRange: Range<HKQuantity>? {
15+
var lowest: HKQuantity?
16+
var highest: HKQuantity?
17+
18+
for sample in self {
19+
if let l = lowest {
20+
lowest = Swift.min(l, sample.quantity)
21+
} else {
22+
lowest = sample.quantity
23+
}
24+
25+
if let h = highest {
26+
highest = Swift.max(h, sample.quantity)
27+
} else {
28+
highest = sample.quantity
29+
}
30+
}
31+
32+
guard let l = lowest, let h = highest else {
33+
return nil
34+
}
35+
36+
return l..<h
37+
}
38+
}

0 commit comments

Comments
 (0)