Skip to content

Commit cfa5094

Browse files
committed
Merge pull request #30 from someoneAnyone/dev
Syncing master with dev for the 1.0.2 release to the Apple AppStore.
2 parents df117a7 + 4055f8d commit cfa5094

12 files changed

+347
-186
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Peter Ina & Nightscouter
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Nightscouter/Base.lproj/Labs.storyboard

+99-39
Large diffs are not rendered by default.

Nightscouter/Base.lproj/Main.storyboard

+23-23
Large diffs are not rendered by default.

Nightscouter/Info.plist

+7-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</string>
18+
<string>1.0.2</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleURLTypes</key>
@@ -32,9 +32,14 @@
3232
</dict>
3333
</array>
3434
<key>CFBundleVersion</key>
35-
<string>138</string>
35+
<string>151</string>
3636
<key>LSRequiresIPhoneOS</key>
3737
<true/>
38+
<key>NSAppTransportSecurity</key>
39+
<dict>
40+
<key>NSAllowsArbitraryLoads</key>
41+
<true/>
42+
</dict>
3843
<key>NSUserActivityTypes</key>
3944
<array>
4045
<string>com.nothingonline.$(PRODUCT_NAME:rfc1034identifier).sites</string>

NightscouterKit/Extensions/CompassControl+Convience.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public extension CompassControl {
2929

3030
let color = colorForDesiredColorState(boundedColor)
3131

32-
configure(sgv.sgvString, color: color, direction: sgv.direction, bgdelta: watch.bgdelta, units: units.description)
32+
configure(sgv.sgvString(forUnits: units), color: color, direction: sgv.direction, bgdelta: watch.bgdelta, units: units.description)
3333
}
3434
}
3535

NightscouterKit/Extensions/String+Extensions.swift

+8-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@ public extension String {
3333
}
3434

3535
public extension String {
36+
var formatter: NSNumberFormatter {
37+
let formatter = NSNumberFormatter()
38+
formatter.locale = NSLocale.systemLocale()
39+
return formatter
40+
}
41+
3642
public var floatValue: Float? {
37-
return NSNumberFormatter().numberFromString(self)?.floatValue //(self as NSString).floatValue
43+
return formatter.numberFromString(self)?.floatValue
3844
}
3945
public var toDouble: Double? {
40-
return NSNumberFormatter().numberFromString(self)?.doubleValue
46+
return formatter.numberFromString(self)?.doubleValue
4147
}
4248
}

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</string>
18+
<string>1.0.2</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

NightscouterKit/Models/Entry.swift

+58-41
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ public enum Device: String {
101101
case xDripDexcomShare = "xDrip-DexcomShare"
102102
case WatchFace = "watchFace"
103103
case Share2 = "share2"
104+
case MedtronicCGM = "Medtronic_CGM"
105+
104106
}
105107

106108
// type = cal
@@ -122,42 +124,44 @@ public struct SensorGlucoseValue {
122124
enum ReservedValues: Double {
123125
case NoGlucose=0, SensoreNotActive=1, MinimalDeviation=2, NoAntenna=3, SensorNotCalibrated=5, CountsDeviation=6, AbsoluteDeviation=9, PowerDeviation=10, BadRF=12, HupHolland=17
124126
}
127+
128+
public func sgvString(forUnits units: Units) -> String {
129+
130+
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.
131+
132+
if let special:ReservedValues = ReservedValues(rawValue: mgdlSgvValue) {
133+
switch (special) {
134+
case .NoGlucose:
135+
return "?NG"
136+
case .SensoreNotActive:
137+
return "?NA"
138+
case .MinimalDeviation:
139+
return "?MD"
140+
case .NoAntenna:
141+
return "?NA"
142+
case .SensorNotCalibrated:
143+
return "?NC"
144+
case .CountsDeviation:
145+
return "?CD"
146+
case .AbsoluteDeviation:
147+
return "?AD"
148+
case .PowerDeviation:
149+
return "?PD"
150+
case .BadRF:
151+
return "?RF✖"
152+
case .HupHolland:
153+
return "MH"
154+
}
155+
}
156+
if sgv >= 30 && sgv < 40 {
157+
return NSLocalizedString("sgvLowString", tableName: nil, bundle: NSBundle.mainBundle(), value: "", comment: "Label used to indicate a very low blood sugar.")
158+
}
159+
return NSNumberFormatter.localizedStringFromNumber(self.sgv, numberStyle: NSNumberFormatterStyle.DecimalStyle)
160+
}
125161

126-
public var sgvString: String { // Consider moving this to a Printable or similar protocal?
162+
public var sgvString: String { // moved its logic to [public func sgvString(forUnits units: Units) -> String]
127163
get {
128-
129-
let mgdlSgvValue: Double = sgv.isInteger ? sgv : sgv.toMgdl
130-
131-
if let special:ReservedValues = ReservedValues(rawValue: mgdlSgvValue) {
132-
switch (special) {
133-
case .NoGlucose:
134-
return "?NG"
135-
case .SensoreNotActive:
136-
return "?NA"
137-
case .MinimalDeviation:
138-
return "?MD"
139-
case .NoAntenna:
140-
return "?NA"
141-
case .SensorNotCalibrated:
142-
return "?NC"
143-
case .CountsDeviation:
144-
return "?CD"
145-
case .AbsoluteDeviation:
146-
return "?AD"
147-
case .PowerDeviation:
148-
return "?PD"
149-
case .BadRF:
150-
return "?RF✖"
151-
case .HupHolland:
152-
return "MH"
153-
// default:
154-
// return "✖"
155-
}
156-
}
157-
if sgv >= 30 && sgv < 40 {
158-
return NSLocalizedString("sgvLowString", tableName: nil, bundle: NSBundle.mainBundle(), value: "", comment: "Label used to indicate a very low blood sugar.")
159-
}
160-
return NSNumberFormatter.localizedStringFromNumber(self.sgv, numberStyle: NSNumberFormatterStyle.DecimalStyle)
164+
return sgvString(forUnits: .Mgdl)
161165
}
162166
}
163167
}
@@ -258,7 +262,7 @@ public class Entry {
258262
self.device = device
259263
}
260264

261-
public init(identifier: String, date: NSDate, device: String, dateString: String, sgv: SensorGlucoseValue?, cal: Calibration?, mbg: MeterBloodGlucose?, type: Type) {
265+
public init(identifier: String, date: NSDate, device: String, dateString: String?, sgv: SensorGlucoseValue?, cal: Calibration?, mbg: MeterBloodGlucose?, type: Type) {
262266
self.identifier = identifier
263267
self.date = date
264268
self.device = device
@@ -308,18 +312,24 @@ public extension Entry {
308312

309313
let dateString = dict[EntryPropertyKey.dateStringKey] as? String
310314

315+
/*
311316
guard let stringForType = dict[EntryPropertyKey.typeKey] as? String,
312-
type: Type = Type(rawValue: stringForType) else {
313-
314-
self.init(identifier: "none", date: NSDate(), device:"none")
315-
316-
return
317+
type: Type = Type(rawValue: stringForType) else {
318+
319+
self.init(identifier: "none", date: date, device: device)
320+
return
317321
}
322+
*/
318323

319324
var sgValue: SensorGlucoseValue! = nil
320325
var calValue: Calibration! = nil
321326
var mbgValue: MeterBloodGlucose! = nil
322327

328+
var type: Type = .none
329+
if let stringForType = dict[EntryPropertyKey.typeKey] as? String, t: Type = Type(rawValue: stringForType) {
330+
type = t
331+
}
332+
323333
switch type {
324334
case .sgv:
325335

@@ -359,9 +369,16 @@ public extension Entry {
359369
#if DEBUG
360370
print(errorString)
361371
#endif
372+
if let directionString = dict[EntryPropertyKey.directionKey] as? String,
373+
direction = Direction(rawValue: directionString),
374+
sgv = dict[EntryPropertyKey.sgvKey] as? Double {
375+
376+
sgValue = SensorGlucoseValue(sgv: sgv, direction: direction, filtered: 0, unfiltered: 0, rssi: 0, noise: .None)
377+
}
378+
362379
break
363380
}
364-
self.init(identifier: identifier, date: date, device:device, dateString: dateString!, sgv: sgValue, cal: calValue, mbg: mbgValue, type: type)
381+
self.init(identifier: identifier, date: date, device:device, dateString: dateString, sgv: sgValue, cal: calValue, mbg: mbgValue, type: type)
365382
}
366383
}
367384

NightscouterKit/Models/ServerConfiguration.swift

+36-16
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ struct ConfigurationPropertyKey {
143143
static let nameKey = "name"
144144
static let statusKey = "status"
145145
static let thresholdsKey = "thresholds"
146-
146+
147147
// ver 7.0
148148
static let bg_highKey = "bg_high"
149149
static let bg_lowKey = "bg_low"
@@ -159,10 +159,10 @@ struct ConfigurationPropertyKey {
159159
static let versionKey = "version"
160160

161161
// Not implmented yet
162-
static let extendedSettingsKey = "extendedSettings"
163-
static let settingsKey = "settings"
164-
static let enableKey = "enable"
165-
static let showPluginsKey = "showPlugins"
162+
static let extendedSettingsKey = "extendedSettings"
163+
static let settingsKey = "settings"
164+
static let enableKey = "enable"
165+
static let showPluginsKey = "showPlugins"
166166
}
167167

168168
public struct ServerConfiguration: CustomStringConvertible {
@@ -171,7 +171,7 @@ public struct ServerConfiguration: CustomStringConvertible {
171171
public var careportalEnabled: Bool?
172172
public var enabledOptions: [EnabledOptions]?
173173
public var defaults: Defaults?
174-
// public let settings: Defaults?
174+
// public let settings: Defaults?
175175
public var unitsRoot: Units?
176176
public var head:String?
177177
public var version: String?
@@ -278,7 +278,7 @@ public extension ServerConfiguration {
278278
let bg_target_top = thresholdsDict[ConfigurationPropertyKey.bg_target_topKey] as! Double
279279
threshold = Threshold(bg_high: bg_high, bg_low: bg_low, bg_target_bottom: bg_target_bottom, bg_target_top: bg_target_top)
280280
}
281-
281+
282282

283283
var defaultsDefaults: Defaults?
284284
if let defaultsDictionary = root[ConfigurationPropertyKey.defaultsKey] as? [String: AnyObject] {
@@ -305,7 +305,7 @@ public extension ServerConfiguration {
305305
let alarms = Alarm(alarmHigh: aHigh, alarmLow: aLow, alarmTimeAgoUrgent: aTAU, alarmTimeAgoUrgentMins: aTAUMin, alarmTimeAgoWarn: aTAW, alarmTimeAgoWarnMins: aTAWMin, alarmUrgentHigh: aTUH, alarmUrgentLow: aTUL)
306306

307307
let language = defaultsDictionary[ConfigurationPropertyKey.languageKey] as! String
308-
308+
309309
defaultsDefaults = Defaults(units: units, timeFormat: timeFormat, nightMode: nightMode, showRawbg: showRawbg, customTitle: customTitle, theme: theme, alarms: alarms, language: language, showPlugins: nil, enable: nil, thresholds: nil, defaultFeatures: nil)
310310
}
311311

@@ -315,6 +315,7 @@ public extension ServerConfiguration {
315315

316316
var timeFormat: Int = 12
317317

318+
// Some sites seem to post a number other seem to have strings.
318319
if let stringTimeFormat = settingsDictionary[ConfigurationPropertyKey.timeFormatKey] as? String {
319320
timeFormat = Int(stringTimeFormat)!
320321
}
@@ -334,11 +335,31 @@ public extension ServerConfiguration {
334335
let aHigh = settingsDictionary[ConfigurationPropertyKey.alarmHighKey] as! Bool
335336
let aLow = settingsDictionary[ConfigurationPropertyKey.alarmLowKey] as! Bool
336337
let aTAU = settingsDictionary[ConfigurationPropertyKey.alarmTimeagoUrgentKey] as! Bool
337-
let aTAUMDouble = settingsDictionary[ConfigurationPropertyKey.alarmTimeagoUrgentMinsKey] as! Double
338+
339+
// Some sites seem to post a number other seem to have strings.
340+
var aTAUMDouble: Double = 0
341+
if let doubleATAUM = settingsDictionary[ConfigurationPropertyKey.alarmTimeagoUrgentMinsKey] as? Double {
342+
aTAUMDouble = doubleATAUM
343+
}
344+
345+
if let stringATAUM = settingsDictionary[ConfigurationPropertyKey.alarmTimeagoUrgentMinsKey] as? String {
346+
aTAUMDouble = Double(stringATAUM)!
347+
}
348+
338349
let aTAUMin: NSTimeInterval = aTAUMDouble * 60 // Convert minutes to seconds.
339350

340351
let aTAW = settingsDictionary[ConfigurationPropertyKey.alarmTimeagoWarnKey] as! Bool
341-
let aTAWMDouble = settingsDictionary[ConfigurationPropertyKey.alarmTimeagoWarnMinsKey] as! Double
352+
353+
var aTAWMDouble: Double = 0
354+
355+
if let doubATAW = settingsDictionary[ConfigurationPropertyKey.alarmTimeagoWarnMinsKey] as? Double {
356+
aTAWMDouble = doubATAW
357+
}
358+
359+
if let stringATAW = settingsDictionary[ConfigurationPropertyKey.alarmTimeagoWarnMinsKey] as? String {
360+
aTAWMDouble = Double(stringATAW)!
361+
}
362+
342363
let aTAWMin: NSTimeInterval = aTAWMDouble * 60 // Convert minutes to seconds.
343364
let aTUH = settingsDictionary[ConfigurationPropertyKey.alarmUrgentHighKey] as! Bool
344365
let aTUL = settingsDictionary[ConfigurationPropertyKey.alarmUrgentLowKey] as! Bool
@@ -347,7 +368,6 @@ public extension ServerConfiguration {
347368

348369
let language = settingsDictionary[ConfigurationPropertyKey.languageKey] as! String
349370

350-
351371
if let enableArray = settingsDictionary[ConfigurationPropertyKey.enableKey] as? [String] {
352372
for stringItem in enableArray{
353373
if let item = EnabledOptions(rawValue: stringItem){
@@ -363,18 +383,18 @@ public extension ServerConfiguration {
363383
let bg_target_top = thresholdsDict[ConfigurationPropertyKey.bgTargetTopKey] as! Double
364384
threshold = Threshold(bg_high: bg_high, bg_low: bg_low, bg_target_bottom: bg_target_bottom, bg_target_top: bg_target_top)
365385
}
366-
367-
386+
387+
368388

369389
defaultsDefaults = Defaults(units: units, timeFormat: timeFormat, nightMode: nightMode, showRawbg: showRawbg, customTitle: customTitle, theme: theme, alarms: alarms, language: language, showPlugins: nil, enable: options, thresholds: threshold, defaultFeatures: nil)
370-
390+
371391
}
372-
392+
373393
serverConfig.defaults = defaultsDefaults
374394

375395
serverConfig.thresholds = threshold
376396
serverConfig.enabledOptions = options
377-
397+
378398
self = serverConfig
379399
}
380400
}

0 commit comments

Comments
 (0)