Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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
  • Loading branch information
loudnate authored Oct 2, 2016
commit 52fc3550470ca553801b4134d77be8720ec0dd31
4 changes: 4 additions & 0 deletions Loop/Managers/DeviceDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ final class DeviceDataManager: CarbStoreDelegate, DoseStoreDelegate, Transmitter
}
}

/// Controls the management of the RileyLink timer tick, which is a reliably-changing BLE
/// characteristic which can cause the app to wake. For most users, the G5 Transmitter and
/// G4 Receiver are reliable as hearbeats, but users who find their resources extremely constrained
/// due to greedy apps or older devices may choose to always enable the timer by always setting `true`
private func enableRileyLinkHeartbeatIfNeeded() {
if transmitter != nil {
rileyLinkManager.timerTickEnabled = false
Expand Down
5 changes: 4 additions & 1 deletion Loop/View Controllers/SettingsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,11 @@ final class SettingsTableViewController: UITableViewController, DailyValueSchedu

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

configCell.detailTextLabel?.text = formatter.string(from: insulinActionDuration)
} else {
Expand Down
10 changes: 5 additions & 5 deletions Loop/View Controllers/StatusTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,9 @@ final class StatusTableViewController: UITableViewController, UIGestureRecognize

// MARK: - HUDs

@IBOutlet var loopCompletionHUD: LoopCompletionHUDView!
@IBOutlet weak var loopCompletionHUD: LoopCompletionHUDView!

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

@IBOutlet var basalRateHUD: BasalRateHUDView!
@IBOutlet weak var basalRateHUD: BasalRateHUDView!

@IBOutlet var reservoirVolumeHUD: ReservoirVolumeHUDView!
@IBOutlet weak var reservoirVolumeHUD: ReservoirVolumeHUDView!

@IBOutlet var batteryLevelHUD: BatteryLevelHUDView!
@IBOutlet weak var batteryLevelHUD: BatteryLevelHUDView!
}
13 changes: 6 additions & 7 deletions Loop/Views/AuthenticationTableViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<?xml version="1.0" encoding="UTF-8"?>
<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">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
Expand All @@ -12,20 +13,18 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="zYL-ef-vkj" id="SNu-9y-BhE">
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
<frame key="frameInset" width="600" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<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">
<rect key="frame" x="15" y="0.0" width="100" height="42.5"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="100" id="kpp-t4-Nzk"/>
</constraints>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Required" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="dcD-jN-TVb">
<rect key="frame" x="123" y="0.0" width="469" height="43.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no"/>
</textField>
Expand Down
4 changes: 2 additions & 2 deletions Loop/Views/BasalRateHUDView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import UIKit

final class BasalRateHUDView: HUDView {

@IBOutlet private var basalStateView: BasalStateView!
@IBOutlet private weak var basalStateView: BasalStateView!

@IBOutlet private var basalRateLabel: UILabel! {
@IBOutlet private weak var basalRateLabel: UILabel! {
didSet {
basalRateLabel?.text = String(format: basalRateFormatString, "–")
basalRateLabel?.textColor = .doseTintColor
Expand Down
2 changes: 1 addition & 1 deletion Loop/Views/BatteryLevelHUDView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit

final class BatteryLevelHUDView: HUDView {

@IBOutlet private var levelMaskView: LevelMaskView!
@IBOutlet private weak var levelMaskView: LevelMaskView!

override func awakeFromNib() {
super.awakeFromNib()
Expand Down
6 changes: 3 additions & 3 deletions Loop/Views/ChartTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import UIKit

final class ChartTableViewCell: UITableViewCell {

@IBOutlet var chartContentView: ChartContentView!
@IBOutlet weak var chartContentView: ChartContentView!

@IBOutlet var titleLabel: UILabel?
@IBOutlet weak var titleLabel: UILabel?

@IBOutlet var subtitleLabel: UILabel?
@IBOutlet weak var subtitleLabel: UILabel?

override func prepareForReuse() {
super.prepareForReuse()
Expand Down
6 changes: 3 additions & 3 deletions Loop/Views/GlucoseHUDView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ import HealthKit

final class GlucoseHUDView: HUDView {

@IBOutlet private var unitLabel: UILabel! {
@IBOutlet private weak var unitLabel: UILabel! {
didSet {
unitLabel.text = "–"
unitLabel.textColor = .glucoseTintColor
}
}

@IBOutlet private var glucoseLabel: UILabel! {
@IBOutlet private weak var glucoseLabel: UILabel! {
didSet {
glucoseLabel.text = "–"
glucoseLabel.textColor = .glucoseTintColor
}
}

@IBOutlet private var alertLabel: UILabel! {
@IBOutlet private weak var alertLabel: UILabel! {
didSet {
alertLabel.alpha = 0
alertLabel.backgroundColor = UIColor.agingColor
Expand Down
2 changes: 1 addition & 1 deletion Loop/Views/HUDView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit

class HUDView: UIView {

@IBOutlet var caption: UILabel! {
@IBOutlet weak var caption: UILabel! {
didSet {
caption?.text = "—"
}
Expand Down
2 changes: 1 addition & 1 deletion Loop/Views/LoopCompletionHUDView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit

final class LoopCompletionHUDView: HUDView {

@IBOutlet private var loopStateView: LoopStateView!
@IBOutlet private weak var loopStateView: LoopStateView!

override func awakeFromNib() {
super.awakeFromNib()
Expand Down
4 changes: 2 additions & 2 deletions Loop/Views/ReservoirVolumeHUDView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import UIKit

final class ReservoirVolumeHUDView: HUDView {

@IBOutlet private var levelMaskView: LevelMaskView!
@IBOutlet private weak var levelMaskView: LevelMaskView!

@IBOutlet private var volumeLabel: UILabel!
@IBOutlet private weak var volumeLabel: UILabel!

override func awakeFromNib() {
super.awakeFromNib()
Expand Down
2 changes: 1 addition & 1 deletion Loop/Views/SwitchTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class SwitchTableViewCell: UITableViewCell {

@IBOutlet weak var subtitleLabel: UILabel?

@IBOutlet var `switch`: UISwitch?
@IBOutlet weak var `switch`: UISwitch?

override func layoutSubviews() {
super.layoutSubviews()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ final class AddCarbsInterfaceController: WKInterfaceController, IdentifiableClas
}
}

@IBOutlet var valueLabel: WKInterfaceLabel!
@IBOutlet weak var valueLabel: WKInterfaceLabel!

@IBOutlet var absorptionButtonA: WKInterfaceButton!
@IBOutlet weak var absorptionButtonA: WKInterfaceButton!

@IBOutlet var absorptionButtonB: WKInterfaceButton!
@IBOutlet weak var absorptionButtonB: WKInterfaceButton!

@IBOutlet var absorptionButtonC: WKInterfaceButton!
@IBOutlet weak var absorptionButtonC: WKInterfaceButton!

override func awake(withContext context: Any?) {
super.awake(withContext: context)
Expand Down
4 changes: 2 additions & 2 deletions WatchApp Extension/Controllers/BolusInterfaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ final class BolusInterfaceController: WKInterfaceController, IdentifiableClass {
private var maxPickerValue = 0

/// 1.25
@IBOutlet var valueLabel: WKInterfaceLabel!
@IBOutlet weak var valueLabel: WKInterfaceLabel!

/// REC: 2.25 U
@IBOutlet var recommendedValueLabel: WKInterfaceLabel!
@IBOutlet weak var recommendedValueLabel: WKInterfaceLabel!

override func awake(withContext context: Any?) {
super.awake(withContext: context)
Expand Down
12 changes: 6 additions & 6 deletions WatchApp Extension/Controllers/StatusInterfaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import Foundation

final class StatusInterfaceController: WKInterfaceController, ContextUpdatable {

@IBOutlet var graphImage: WKInterfaceImage!
@IBOutlet var loopHUDImage: WKInterfaceImage!
@IBOutlet var loopTimer: WKInterfaceTimer!
@IBOutlet var glucoseLabel: WKInterfaceLabel!
@IBOutlet var eventualGlucoseLabel: WKInterfaceLabel!
@IBOutlet var statusLabel: WKInterfaceLabel!
@IBOutlet weak var graphImage: WKInterfaceImage!
@IBOutlet weak var loopHUDImage: WKInterfaceImage!
@IBOutlet weak var loopTimer: WKInterfaceTimer!
@IBOutlet weak var glucoseLabel: WKInterfaceLabel!
@IBOutlet weak var eventualGlucoseLabel: WKInterfaceLabel!
@IBOutlet weak var statusLabel: WKInterfaceLabel!

private var lastContext: WatchContext?

Expand Down