Skip to content

Commit f11abde

Browse files
authored
Merge pull request #3 from loopandlearn/enable_appName
Parallel PR to LoopKit LoopKit#14, Enable app name instead of hardcoded Loop
2 parents a079b53 + 0b485db commit f11abde

File tree

6 files changed

+32
-5
lines changed

6 files changed

+32
-5
lines changed

MinimedKit.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
B69083572BCC35A000F26B88 /* Bundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B69083552BCC359800F26B88 /* Bundle.swift */; };
1011
C1229C2229C7ECA70066A89C /* TimeInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1229C2129C7ECA70066A89C /* TimeInterval.swift */; };
1112
C1229C2429C7ECEB0066A89C /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1229C2329C7ECEB0066A89C /* Data.swift */; };
1213
C13CC33529C7B6A9007F25DE /* LoopKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1E34B6729C7AD62009A50A5 /* LoopKit.framework */; };
@@ -352,6 +353,7 @@
352353
/* End PBXCopyFilesBuildPhase section */
353354

354355
/* Begin PBXFileReference section */
356+
B69083552BCC359800F26B88 /* Bundle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bundle.swift; sourceTree = "<group>"; };
355357
C1229C2129C7ECA70066A89C /* TimeInterval.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimeInterval.swift; sourceTree = "<group>"; };
356358
C1229C2329C7ECEB0066A89C /* Data.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Data.swift; sourceTree = "<group>"; };
357359
C13CC34129C7B73A007F25DE /* MinimedKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MinimedKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1184,6 +1186,7 @@
11841186
C1E34B0929C7ABF2009A50A5 /* Extensions */ = {
11851187
isa = PBXGroup;
11861188
children = (
1189+
B69083552BCC359800F26B88 /* Bundle.swift */,
11871190
C1E34B0A29C7ABF2009A50A5 /* Image.swift */,
11881191
C1E34B8729C7B292009A50A5 /* Comparable.swift */,
11891192
C1E34B8B29C7B334009A50A5 /* IdentifiableClass.swift */,
@@ -1726,6 +1729,7 @@
17261729
buildActionMask = 2147483647;
17271730
files = (
17281731
C1E34B2829C7ABF3009A50A5 /* MinimedPumpSetupCompleteViewController.swift in Sources */,
1732+
B69083572BCC35A000F26B88 /* Bundle.swift in Sources */,
17291733
C1E34B8829C7B292009A50A5 /* Comparable.swift in Sources */,
17301734
C1E34B8A29C7B2FC009A50A5 /* LocalisedString.swift in Sources */,
17311735
C1E34B2429C7ABF3009A50A5 /* Image.swift in Sources */,

MinimedKit/PumpManager/PumpOpsSession.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import Foundation
1010
import LoopKit
1111
import RileyLinkBLEKit
12-
12+
import SwiftUI
1313

1414
public protocol PumpOpsSessionDelegate: AnyObject {
1515
func pumpOpsSession(_ session: PumpOpsSession, didChange state: PumpState)
@@ -42,11 +42,13 @@ extension SetBolusError: LocalizedError {
4242
}
4343

4444
public var helpAnchor: String? {
45+
// ToDo: convert to @Environment(\.appName)
46+
let appName: String = "the app"
4547
switch self {
4648
case .certain(let error):
4749
return error.errorDescription
4850
case .uncertain:
49-
return LocalizedString("Loop sent a bolus command to the pump, but was unable to confirm that the pump received the command. For safety, Loop will assume the bolus was delivered. When Loop eventually fetches history from the pump, and the estimated bolus finish time is passed, Loop will update its records of delivery to match what the pump reports.", comment: "Help anchor for uncertain bolus")
51+
return String(format: LocalizedString("%1$@ sent a bolus command to the pump, but was unable to confirm that the pump received the command. For safety, %2$@ will assume the bolus was delivered. When %3$@ eventually fetches history from the pump, and the estimated bolus finish time is passed, %4$@ will update its records of delivery to match what the pump reports.", comment: "Help anchor for uncertain bolus (1: appName) (2: appName) (3: appName) (4: appName)"), appName, appName, appName, appName)
5052
}
5153
}
5254
}

MinimedKitUI/Extensions/Bundle.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Bundle.swift
3+
// MinimedKit
4+
//
5+
// Created by Darin Krauss on 1/23/21.
6+
// Copyright © 2021 LoopKit Authors. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
extension Bundle {
12+
var bundleDisplayName: String {
13+
return object(forInfoDictionaryKey: "CFBundleDisplayName") as! String
14+
}
15+
}

MinimedKitUI/MinimedPumpUICoordinator.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ class MinimedUICoordinator: UINavigationController, PumpManagerOnboarding, Compl
141141
}
142142

143143
private func hostingController<Content: View>(rootView: Content) -> DismissibleHostingController<some View> {
144+
let rootView = rootView
145+
.environment(\.appName, Bundle.main.bundleDisplayName)
144146
return DismissibleHostingController(content: rootView, colorPalette: colorPalette)
145147
}
146148

MinimedKitUI/RadioSelectionTableViewController.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import UIKit
1010
import LoopKitUI
1111
import MinimedKit
12+
import SwiftUI
1213

1314

1415
extension RadioSelectionTableViewController: IdentifiableClass {
@@ -26,21 +27,23 @@ extension RadioSelectionTableViewController: IdentifiableClass {
2627

2728
static func batteryChemistryType(_ value: MinimedKit.BatteryChemistryType) -> T {
2829
let vc = T()
30+
@Environment(\.appName) var appName
2931

3032
vc.selectedIndex = value.rawValue
3133
vc.options = (0..<2).compactMap({ BatteryChemistryType(rawValue: $0) }).map { String(describing: $0) }
32-
vc.contextHelp = LocalizedString("Alkaline and Lithium batteries decay at differing rates. Alkaline tend to have a linear voltage drop over time whereas lithium cell batteries tend to maintain voltage until halfway through their lifespan. Under normal usage in a Non-MySentry compatible Minimed (x22/x15) insulin pump running Loop, Alkaline batteries last approximately 4 to 5 days. Lithium batteries last between 1-2 weeks. This selection will use different battery voltage decay rates for each of the battery chemistry types and alert the user when a battery is approximately 8 to 10 hours from failure.", comment: "Instructions on selecting battery chemistry type")
34+
vc.contextHelp = String(format: LocalizedString("Alkaline and Lithium batteries decay at differing rates. Alkaline tend to have a linear voltage drop over time whereas lithium cell batteries tend to maintain voltage until halfway through their lifespan. Under normal usage in a Non-MySentry compatible Minimed (x22/x15) insulin pump running %1$@, Alkaline batteries last approximately 4 to 5 days. Lithium batteries last between 1-2 weeks. This selection will use different battery voltage decay rates for each of the battery chemistry types and alert the user when a battery is approximately 8 to 10 hours from failure.", comment: "Instructions on selecting battery chemistry type (1: appName)"), appName)
3335

3436
return vc
3537
}
3638

3739
static func useMySentry(_ value: Bool) -> T {
3840
let vc = T()
41+
@Environment(\.appName) var appName
3942

4043
vc.selectedIndex = value ? 0 : 1
4144

4245
vc.options = ["Use MySentry", "Do not use MySentry"]
43-
vc.contextHelp = LocalizedString("Medtronic pump models 523, 723, 554, and 754 have a feature called 'MySentry' that periodically broadcasts the reservoir and pump battery levels. Listening for these broadcasts allows Loop to communicate with the pump less frequently, which can increase pump battery life. However, when using this feature the RileyLink stays awake more of the time and uses more of its own battery. Enabling this may lengthen pump battery life, while disabling it may lengthen RileyLink battery life. This setting is ignored for other pump models.", comment: "Instructions on selecting setting for MySentry")
46+
vc.contextHelp = String(format: LocalizedString("Medtronic pump models 523, 723, 554, and 754 have a feature called 'MySentry' that periodically broadcasts the reservoir and pump battery levels. Listening for these broadcasts allows %1$@ to communicate with the pump less frequently, which can increase pump battery life. However, when using this feature the RileyLink stays awake more of the time and uses more of its own battery. Enabling this may lengthen pump battery life, while disabling it may lengthen RileyLink battery life. This setting is ignored for other pump models.", comment: "Instructions on selecting setting for MySentry (1: appName)"), appName)
4447

4548
return vc
4649
}

MinimedKitUI/Views/UseMySentrySelectionView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import MinimedKit
1111
import LoopKitUI
1212

1313
struct UseMySentrySelectionView: View {
14+
@Environment(\.appName) private var appName
1415

1516
@Binding var mySentryConfig: MySentryConfig
1617

@@ -24,7 +25,7 @@ struct UseMySentrySelectionView: View {
2425
}
2526
.pickerStyle(.inline)
2627
Section(content: {}, footer: {
27-
Text(LocalizedString("Medtronic pump models 523, 723, 554, and 754 have a feature called 'MySentry' that periodically broadcasts the reservoir and pump battery levels. Listening for these broadcasts allows Loop to communicate with the pump less frequently, which can increase pump battery life. However, when using this feature the RileyLink stays awake more of the time and uses more of its own battery. Enabling this may lengthen pump battery life, while disabling it may lengthen RileyLink battery life. This setting is ignored for other pump models.", comment: "Instructions on selecting setting for MySentry"))
28+
Text(String(format: LocalizedString("Medtronic pump models 523, 723, 554, and 754 have a feature called 'MySentry' that periodically broadcasts the reservoir and pump battery levels. Listening for these broadcasts allows %1$@ to communicate with the pump less frequently, which can increase pump battery life. However, when using this feature the RileyLink stays awake more of the time and uses more of its own battery. Enabling this may lengthen pump battery life, while disabling it may lengthen RileyLink battery life. This setting is ignored for other pump models.", comment: "Instructions on selecting setting for MySentry (1: appName)"), self.appName))
2829
})
2930
}
3031
}

0 commit comments

Comments
 (0)