Skip to content

Commit 52fc355

Browse files
authored
Preventing truncation of insulin action duration (Fixes #213) (#214)
Moving most outlets to weak references Adding a note about improving reliability of wakeup on constrained devices
1 parent 6cf7790 commit 52fc355

15 files changed

+45
-39
lines changed

Loop/Managers/DeviceDataManager.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ final class DeviceDataManager: CarbStoreDelegate, DoseStoreDelegate, Transmitter
118118
}
119119
}
120120

121+
/// Controls the management of the RileyLink timer tick, which is a reliably-changing BLE
122+
/// characteristic which can cause the app to wake. For most users, the G5 Transmitter and
123+
/// G4 Receiver are reliable as hearbeats, but users who find their resources extremely constrained
124+
/// due to greedy apps or older devices may choose to always enable the timer by always setting `true`
121125
private func enableRileyLinkHeartbeatIfNeeded() {
122126
if transmitter != nil {
123127
rileyLinkManager.timerTickEnabled = false

Loop/View Controllers/SettingsTableViewController.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,11 @@ final class SettingsTableViewController: UITableViewController, DailyValueSchedu
246246

247247
if let insulinActionDuration = dataManager.insulinActionDuration {
248248
let formatter = DateComponentsFormatter()
249+
formatter.unitsStyle = .abbreviated
250+
// Seems to have no effect.
251+
// http://stackoverflow.com/questions/32522965/what-am-i-doing-wrong-with-allowsfractionalunits-on-nsdatecomponentsformatter
249252
formatter.allowsFractionalUnits = true
250-
formatter.allowedUnits = [.hour]
253+
// formatter.allowedUnits = [.hour]
251254

252255
configCell.detailTextLabel?.text = formatter.string(from: insulinActionDuration)
253256
} else {

Loop/View Controllers/StatusTableViewController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -782,9 +782,9 @@ final class StatusTableViewController: UITableViewController, UIGestureRecognize
782782

783783
// MARK: - HUDs
784784

785-
@IBOutlet var loopCompletionHUD: LoopCompletionHUDView!
785+
@IBOutlet weak var loopCompletionHUD: LoopCompletionHUDView!
786786

787-
@IBOutlet var glucoseHUD: GlucoseHUDView! {
787+
@IBOutlet weak var glucoseHUD: GlucoseHUDView! {
788788
didSet {
789789
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(openCGMApp(_:)))
790790
glucoseHUD.addGestureRecognizer(tapGestureRecognizer)
@@ -811,9 +811,9 @@ final class StatusTableViewController: UITableViewController, UIGestureRecognize
811811
}
812812
}
813813

814-
@IBOutlet var basalRateHUD: BasalRateHUDView!
814+
@IBOutlet weak var basalRateHUD: BasalRateHUDView!
815815

816-
@IBOutlet var reservoirVolumeHUD: ReservoirVolumeHUDView!
816+
@IBOutlet weak var reservoirVolumeHUD: ReservoirVolumeHUDView!
817817

818-
@IBOutlet var batteryLevelHUD: BatteryLevelHUDView!
818+
@IBOutlet weak var batteryLevelHUD: BatteryLevelHUDView!
819819
}

Loop/Views/AuthenticationTableViewCell.xib

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
33
<dependencies>
44
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
66
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
7+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
78
</dependencies>
89
<objects>
910
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
@@ -12,20 +13,18 @@
1213
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
1314
<autoresizingMask key="autoresizingMask"/>
1415
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="zYL-ef-vkj" id="SNu-9y-BhE">
15-
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
16+
<frame key="frameInset" width="600" height="43.5"/>
1617
<autoresizingMask key="autoresizingMask"/>
1718
<subviews>
1819
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Sk9-jr-Tir">
19-
<rect key="frame" x="15" y="0.0" width="100" height="42.5"/>
2020
<constraints>
2121
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="100" id="kpp-t4-Nzk"/>
2222
</constraints>
2323
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
24-
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
24+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2525
<nil key="highlightedColor"/>
2626
</label>
2727
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Required" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="dcD-jN-TVb">
28-
<rect key="frame" x="123" y="0.0" width="469" height="43.5"/>
2928
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
3029
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no"/>
3130
</textField>

Loop/Views/BasalRateHUDView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import UIKit
1111

1212
final class BasalRateHUDView: HUDView {
1313

14-
@IBOutlet private var basalStateView: BasalStateView!
14+
@IBOutlet private weak var basalStateView: BasalStateView!
1515

16-
@IBOutlet private var basalRateLabel: UILabel! {
16+
@IBOutlet private weak var basalRateLabel: UILabel! {
1717
didSet {
1818
basalRateLabel?.text = String(format: basalRateFormatString, "")
1919
basalRateLabel?.textColor = .doseTintColor

Loop/Views/BatteryLevelHUDView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import UIKit
1111

1212
final class BatteryLevelHUDView: HUDView {
1313

14-
@IBOutlet private var levelMaskView: LevelMaskView!
14+
@IBOutlet private weak var levelMaskView: LevelMaskView!
1515

1616
override func awakeFromNib() {
1717
super.awakeFromNib()

Loop/Views/ChartTableViewCell.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import UIKit
1111

1212
final class ChartTableViewCell: UITableViewCell {
1313

14-
@IBOutlet var chartContentView: ChartContentView!
14+
@IBOutlet weak var chartContentView: ChartContentView!
1515

16-
@IBOutlet var titleLabel: UILabel?
16+
@IBOutlet weak var titleLabel: UILabel?
1717

18-
@IBOutlet var subtitleLabel: UILabel?
18+
@IBOutlet weak var subtitleLabel: UILabel?
1919

2020
override func prepareForReuse() {
2121
super.prepareForReuse()

Loop/Views/GlucoseHUDView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ import HealthKit
1313

1414
final class GlucoseHUDView: HUDView {
1515

16-
@IBOutlet private var unitLabel: UILabel! {
16+
@IBOutlet private weak var unitLabel: UILabel! {
1717
didSet {
1818
unitLabel.text = ""
1919
unitLabel.textColor = .glucoseTintColor
2020
}
2121
}
2222

23-
@IBOutlet private var glucoseLabel: UILabel! {
23+
@IBOutlet private weak var glucoseLabel: UILabel! {
2424
didSet {
2525
glucoseLabel.text = ""
2626
glucoseLabel.textColor = .glucoseTintColor
2727
}
2828
}
2929

30-
@IBOutlet private var alertLabel: UILabel! {
30+
@IBOutlet private weak var alertLabel: UILabel! {
3131
didSet {
3232
alertLabel.alpha = 0
3333
alertLabel.backgroundColor = UIColor.agingColor

Loop/Views/HUDView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010

1111
class HUDView: UIView {
1212

13-
@IBOutlet var caption: UILabel! {
13+
@IBOutlet weak var caption: UILabel! {
1414
didSet {
1515
caption?.text = ""
1616
}

Loop/Views/LoopCompletionHUDView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010

1111
final class LoopCompletionHUDView: HUDView {
1212

13-
@IBOutlet private var loopStateView: LoopStateView!
13+
@IBOutlet private weak var loopStateView: LoopStateView!
1414

1515
override func awakeFromNib() {
1616
super.awakeFromNib()

0 commit comments

Comments
 (0)