Skip to content

Commit bf5e21c

Browse files
committed
Merge pull request #35 from someoneAnyone/dev
Dev
2 parents 07ce519 + a03ae2c commit bf5e21c

9 files changed

+102
-70
lines changed

Nightscouter/Info.plist

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0.2</string>
18+
<string>1.0.3</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleURLTypes</key>
@@ -32,7 +32,7 @@
3232
</dict>
3333
</array>
3434
<key>CFBundleVersion</key>
35-
<string>151</string>
35+
<string>152</string>
3636
<key>LSRequiresIPhoneOS</key>
3737
<true/>
3838
<key>NSAppTransportSecurity</key>

Nightscouter/SiteDetailViewController.swift

+22-16
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ extension SiteDetailViewController {
115115
switch (result) {
116116
case let .Error(error):
117117
// display error message
118-
print("error: \(error)")
118+
print("error: \(error)")
119119
self.navigationController?.popViewControllerAnimated(true)
120120

121121
case let .Value(boxedConfiguration):
122122
let configuration:ServerConfiguration = boxedConfiguration.value
123123
// Get back on the main queue to update the user interface
124124
dispatch_async(dispatch_get_main_queue(), { () -> Void in
125-
125+
126126
self.updateTitles(configuration.displayName)
127127

128128
if let enabledOptions = configuration.enabledOptions {
@@ -166,17 +166,23 @@ extension SiteDetailViewController {
166166
self.siteLastReadingLabel?.text = watchEntry.dateTimeAgoString
167167
self.siteLastReadingLabel?.textColor = self.defaultTextColor
168168

169-
// Raw label
170-
if let rawValue = watchEntry.raw {
171-
let color = colorForDesiredColorState(configuration.boundedColorForGlucoseValue(rawValue))
172-
173-
var raw = "\(rawValue.formattedForMgdl)"
174-
if configuration.displayUnits == .Mmol {
175-
raw = rawValue.formattedForMmol
169+
170+
if configuration.displayRawData {
171+
// Raw label
172+
if let rawValue = watchEntry.raw {
173+
let color = colorForDesiredColorState(configuration.boundedColorForGlucoseValue(rawValue))
174+
175+
var raw = "\(rawValue.formattedForMgdl)"
176+
if configuration.displayUnits == .Mmol {
177+
raw = rawValue.formattedForMmol
178+
}
179+
180+
self.siteRawLabel?.textColor = color
181+
self.siteRawLabel?.text = "\(raw) : \(sgv.noise)"
176182
}
177-
178-
self.siteRawLabel?.textColor = color
179-
self.siteRawLabel?.text = "\(raw) : \(sgv.noise)"
183+
} else {
184+
self.siteRawHeader?.hidden = true
185+
self.siteRawLabel?.hidden = true
180186
}
181187

182188
let timeAgo = watchEntry.date.timeIntervalSinceNow
@@ -249,7 +255,7 @@ extension SiteDetailViewController {
249255
AppDataManager.sharedInstance.shouldDisableIdleTimer = self.site!.overrideScreenLock
250256
AppDataManager.sharedInstance.updateSite(site!)
251257
UIApplication.sharedApplication().idleTimerDisabled = site!.overrideScreenLock
252-
258+
253259
#if DEBUG
254260
print("{site.overrideScreenLock:\(site?.overrideScreenLock), AppDataManager.shouldDisableIdleTimer:\(AppDataManager.sharedInstance.shouldDisableIdleTimer), UIApplication.idleTimerDisabled:\(UIApplication.sharedApplication().idleTimerDisabled)}")
255261
#endif
@@ -281,7 +287,7 @@ extension SiteDetailViewController {
281287
}
282288

283289
alertController.addAction(yesAction)
284-
290+
285291
if #available(iOS 9.0, *) {
286292
alertController.preferredAction = yesAction
287293
}
@@ -299,7 +305,7 @@ extension SiteDetailViewController {
299305
#endif
300306
}
301307
alertController.addAction(noAction)
302-
308+
303309
alertController.view.tintColor = NSAssetKit.darkNavColor
304310

305311
self.view.window?.tintColor = nil
@@ -309,7 +315,7 @@ extension SiteDetailViewController {
309315
if let popoverController = alertController.popoverPresentationController {
310316
popoverController.barButtonItem = sender
311317
}
312-
318+
313319
self.presentViewController(alertController, animated: true) {
314320
#if DEBUG
315321
print("presentViewController: \(alertController.debugDescription)")

Nightscouter/SiteTableViewCell.swift

+16-17
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,25 @@ class SiteTableViewCell: UITableViewCell {
7171

7272
siteColorBlockView.backgroundColor = color
7373

74-
if let enabledOptions = configuration.enabledOptions {
75-
let rawEnabled = enabledOptions.contains(EnabledOptions.rawbg)
76-
if rawEnabled {
77-
if let rawValue = watchEntry.raw {
78-
let color = colorForDesiredColorState(configuration.boundedColorForGlucoseValue(rawValue))
79-
80-
var raw = "\(rawValue.formattedForMgdl)"
81-
if configuration.displayUnits == .Mmol {
82-
raw = rawValue.formattedForMmol
83-
}
84-
85-
siteRawLabel?.textColor = color
86-
siteRawLabel.text = "\(raw) : \(sgvValue.noise)"
74+
75+
if configuration.displayRawData {
76+
// Raw label
77+
if let rawValue = watchEntry.raw {
78+
let color = colorForDesiredColorState(configuration.boundedColorForGlucoseValue(rawValue))
79+
80+
var raw = "\(rawValue.formattedForMgdl)"
81+
if configuration.displayUnits == .Mmol {
82+
raw = rawValue.formattedForMmol
8783
}
88-
} else {
89-
siteRawHeader.hidden = true
90-
siteRawLabel.hidden = true
84+
85+
self.siteRawLabel?.textColor = color
86+
self.siteRawLabel?.text = "\(raw) : \(sgvValue.noise)"
9187
}
88+
} else {
89+
self.siteRawHeader?.hidden = true
90+
self.siteRawLabel?.hidden = true
9291
}
93-
92+
9493
let timeAgo = watchEntry.date.timeIntervalSinceNow
9594
let isStaleData = configuration.isDataStaleWith(interval: timeAgo)
9695
siteCompassControl.shouldLookStale(look: isStaleData.warn)

NightscouterKit/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0.2</string>
18+
<string>1.0.3</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

NightscouterKit/Models/Entry.swift

+12-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public enum Direction : String, CustomStringConvertible {
3737
public var emojiForDirection : String {
3838
get {
3939
switch (self) {
40-
case .None: return "None"
40+
case .None: return " "
4141
case .DoubleUp: return ""
4242
case .SingleUp: return ""
4343
case .FortyFiveUp: return ""
@@ -124,15 +124,15 @@ public struct SensorGlucoseValue {
124124
enum ReservedValues: Double {
125125
case NoGlucose=0, SensoreNotActive=1, MinimalDeviation=2, NoAntenna=3, SensorNotCalibrated=5, CountsDeviation=6, AbsoluteDeviation=9, PowerDeviation=10, BadRF=12, HupHolland=17
126126
}
127-
127+
128128
public func sgvString(forUnits units: Units) -> String {
129129

130130
let mgdlSgvValue: Double = (units == .Mgdl) ? sgv : sgv.toMgdl // If the units are set to mgd/L do nothing let it pass... if its mmol/L then convert it back to mgd/L to get its proper string.
131131

132132
if let special:ReservedValues = ReservedValues(rawValue: mgdlSgvValue) {
133133
switch (special) {
134134
case .NoGlucose:
135-
return "?NG"
135+
return "?NC"
136136
case .SensoreNotActive:
137137
return "?NA"
138138
case .MinimalDeviation:
@@ -338,13 +338,19 @@ public extension Entry {
338338
sgv = dict[EntryPropertyKey.sgvKey] as? Double,
339339
filtered = dict[EntryPropertyKey.filteredKey] as? Int,
340340
unfiltlered = dict[EntryPropertyKey.unfilteredKey] as? Int,
341-
rssi = dict[EntryPropertyKey.rssiKey] as? Int,
342-
noiseInt = dict[EntryPropertyKey.noiseKey] as? Int,
343-
noise = Noise(rawValue: noiseInt) else {
341+
rssi = dict[EntryPropertyKey.rssiKey] as? Int else {
344342

345343
break
346344
}
347345

346+
var noise = Noise.None
347+
if let noiseInt = dict[EntryPropertyKey.noiseKey] as? Int,
348+
noiseType = Noise(rawValue: noiseInt) {
349+
350+
noise = noiseType
351+
}
352+
353+
348354
sgValue = SensorGlucoseValue(sgv: sgv, direction: direction, filtered: filtered, unfiltered: unfiltlered, rssi: rssi, noise: noise)
349355
break
350356

NightscouterKit/Models/ServerConfiguration.swift

+22
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,28 @@ public extension ServerConfiguration {
462462
}
463463
}
464464

465+
public var displayRawData: Bool {
466+
if let enabledOptions = enabledOptions {
467+
let rawEnabled = enabledOptions.contains(EnabledOptions.rawbg)
468+
if rawEnabled {
469+
if let defaults = defaults {
470+
471+
switch defaults.showRawbg {
472+
case .Noise:
473+
return true
474+
case .Always:
475+
return true
476+
case .Never:
477+
return false
478+
}
479+
480+
}
481+
}
482+
}
483+
484+
return false
485+
}
486+
465487
public var displayUnits: Units {
466488
if let defaults = defaults {
467489
return defaults.units

NightscouterKit/Models/WatchEntry.swift

+7-5
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,21 @@ public extension WatchEntry {
104104
}
105105

106106
if let opFiltered = bgsDictionary[EntryPropertyKey.filteredKey] as? Int,
107-
opUnfiltlered = bgsDictionary[EntryPropertyKey.unfilteredKey] as? Int,
108-
opNoiseInt = bgsDictionary[EntryPropertyKey.noiseKey] as? Int,
107+
opUnfiltlered = bgsDictionary[EntryPropertyKey.unfilteredKey] as? Int
108+
{
109+
filtered = opFiltered
110+
unfiltlered = opUnfiltlered
111+
112+
}
113+
if let opNoiseInt = bgsDictionary[EntryPropertyKey.noiseKey] as? Int,
109114
opNoise = Noise(rawValue: opNoiseInt) {
110115

111-
filtered = opFiltered
112-
unfiltlered = opUnfiltlered
113116
noise = opNoise
114117

115118
}
116119

117120

118121

119-
120122
if let bgdeltaString = bgsDictionary[EntryPropertyKey.bgdeltaKey] as? String {
121123
bgdelta = bgdeltaString.toDouble!
122124
}

NightscouterToday/Info.plist

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>XPC!</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.0.2</string>
20+
<string>1.0.3</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>151</string>
24+
<string>152</string>
2525
<key>NSAppTransportSecurity</key>
2626
<dict>
2727
<key>NSAllowsArbitraryLoads</key>

NightscouterToday/SiteNSNowTableViewCell.swift

+18-21
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SiteNSNowTableViewCell: UITableViewCell {
2222

2323
@IBOutlet weak var siteNameLabel: UILabel!
2424

25-
@IBOutlet weak var siteColorBlockView: UIView!
25+
@IBOutlet weak var siteColorBlockView: UIView!
2626
// @IBOutlet weak var siteCompassControl: CompassControl!
2727

2828
@IBOutlet weak var siteSgvLabel: UILabel!
@@ -63,7 +63,7 @@ class SiteNSNowTableViewCell: UITableViewCell {
6363
siteLastReadingLabel.text = watchEntry.dateTimeAgoString
6464

6565
if let sgvValue = watchEntry.sgv {
66-
66+
6767
var boundedColor = configuration.boundedColorForGlucoseValue(sgvValue.sgv)
6868
if units == .Mmol {
6969
boundedColor = configuration.boundedColorForGlucoseValue(sgvValue.sgv.toMgdl)
@@ -77,28 +77,25 @@ class SiteNSNowTableViewCell: UITableViewCell {
7777

7878
siteDirectionLabel.text = "\(watchEntry.bgdelta.formattedForBGDelta) \(units.description)"
7979
siteDirectionLabel.textColor = color
80-
8180

82-
if let enabledOptions = configuration.enabledOptions {
83-
let rawEnabled = enabledOptions.contains(EnabledOptions.rawbg)
84-
if rawEnabled {
85-
if let rawValue = watchEntry.raw {
86-
let color = colorForDesiredColorState(configuration.boundedColorForGlucoseValue(rawValue))
87-
88-
var raw = "\(rawValue.formattedForMgdl)"
89-
if configuration.displayUnits == .Mmol {
90-
raw = rawValue.formattedForMmol
91-
}
92-
93-
siteRawLabel?.textColor = color
94-
siteRawLabel.text = "\(raw) : \(sgvValue.noise)"
81+
82+
if configuration.displayRawData {
83+
if let rawValue = watchEntry.raw {
84+
let color = colorForDesiredColorState(configuration.boundedColorForGlucoseValue(rawValue))
85+
86+
var raw = "\(rawValue.formattedForMgdl)"
87+
if configuration.displayUnits == .Mmol {
88+
raw = rawValue.formattedForMmol
9589
}
96-
} else {
97-
siteRawHeader.hidden = true
98-
siteRawLabel.hidden = true
90+
91+
siteRawLabel?.textColor = color
92+
siteRawLabel.text = "\(raw) : \(sgvValue.noise)"
9993
}
94+
} else {
95+
siteRawHeader.hidden = true
96+
siteRawLabel.hidden = true
10097
}
101-
98+
10299
let timeAgo = watchEntry.date.timeIntervalSinceNow
103100
let isStaleData = configuration.isDataStaleWith(interval: timeAgo)
104101
// siteCompassControl.shouldLookStale(look: isStaleData.warn)
@@ -154,7 +151,7 @@ class SiteNSNowTableViewCell: UITableViewCell {
154151
siteRawLabel.text = nil
155152
siteLastReadingLabel.text = nil
156153
// siteCompassControl.shouldLookStale(look: true)
157-
siteColorBlockView.backgroundColor = colorForDesiredColorState(DesiredColorState.Neutral)
154+
siteColorBlockView.backgroundColor = colorForDesiredColorState(DesiredColorState.Neutral)
158155

159156
siteSgvLabel.text = nil
160157
siteSgvLabel.textColor = Theme.Color.labelTextColor

0 commit comments

Comments
 (0)