@@ -11,7 +11,7 @@ import MapKit
11
11
import CoreLocation
12
12
import CoreGPX
13
13
14
- //Button colors
14
+ // Button colors
15
15
let kPurpleButtonBackgroundColor : UIColor = UIColor ( red: 146.0 / 255.0 , green: 166.0 / 255.0 , blue: 218.0 / 255.0 , alpha: 0.90 )
16
16
let kGreenButtonBackgroundColor : UIColor = UIColor ( red: 142.0 / 255.0 , green: 224.0 / 255.0 , blue: 102.0 / 255.0 , alpha: 0.90 )
17
17
let kRedButtonBackgroundColor : UIColor = UIColor ( red: 244.0 / 255.0 , green: 94.0 / 255.0 , blue: 94.0 / 255.0 , alpha: 0.90 )
@@ -20,7 +20,7 @@ let kDisabledBlueButtonBackgroundColor: UIColor = UIColor(red: 74.0/255.0, green
20
20
let kDisabledRedButtonBackgroundColor : UIColor = UIColor ( red: 244.0 / 255.0 , green: 94.0 / 255.0 , blue: 94.0 / 255.0 , alpha: 0.10 )
21
21
let kWhiteBackgroundColor : UIColor = UIColor ( red: 254.0 / 255.0 , green: 254.0 / 255.0 , blue: 254.0 / 255.0 , alpha: 0.90 )
22
22
23
- //Accesory View buttons tags
23
+ // Accesory View buttons tags
24
24
let kDeleteWaypointAccesoryButtonTag = 666
25
25
let kEditWaypointAccesoryButtonTag = 333
26
26
@@ -70,7 +70,7 @@ class InterfaceController: WKInterfaceController {
70
70
manager. requestAlwaysAuthorization ( )
71
71
72
72
manager. desiredAccuracy = kCLLocationAccuracyBest
73
- manager. distanceFilter = 2 //meters
73
+ manager. distanceFilter = 2 // meters
74
74
manager. allowsBackgroundLocationUpdates = true
75
75
return manager
76
76
} ( )
@@ -81,10 +81,10 @@ class InterfaceController: WKInterfaceController {
81
81
/// Underlying class that handles background stuff
82
82
let map = GPXMapView ( ) // not even a map view. Considering renaming
83
83
84
- //Status Vars
84
+ // Status Vars
85
85
var stopWatch = StopWatch ( )
86
86
var lastGpxFilename : String = " "
87
- var wasSentToBackground : Bool = false //Was the app sent to background
87
+ var wasSentToBackground : Bool = false // Was the app sent to background
88
88
var isDisplayingLocationServicesDenied : Bool = false
89
89
90
90
/// Does the 'file' have any waypoint?
@@ -130,36 +130,24 @@ class InterfaceController: WKInterfaceController {
130
130
// set Tracker button to allow Start
131
131
trackerButton. setTitle ( NSLocalizedString ( " START_TRACKING " , comment: " no comment " ) )
132
132
trackerButton. setBackgroundColor ( kGreenButtonBackgroundColor)
133
- //save & reset button to transparent.
133
+ // Save & reset button to transparent.
134
134
saveButton. setBackgroundColor ( kDisabledBlueButtonBackgroundColor)
135
135
resetButton. setBackgroundColor ( kDisabledRedButtonBackgroundColor)
136
- //reset clock
136
+ // Reset clock
137
137
stopWatch. reset ( )
138
138
timeLabel. setText ( stopWatch. elapsedTimeString)
139
139
140
- map. reset ( ) //reset gpx logging
141
- lastGpxFilename = " " //clear last filename, so when saving it appears an empty field
140
+ map. reset ( ) // Reset gpx logging
141
+ lastGpxFilename = " " // Clear last filename, so when saving it appears an empty field
142
142
143
143
totalTrackedDistanceLabel. setText ( map. totalTrackedDistance. toDistance ( useImperial: preferences. useImperial) )
144
-
145
- //currentSegmentDistanceLabel.distance = (map.currentSegmentDistance)
146
-
147
- /*
148
- // XXX Left here for reference
149
- UIView.animateWithDuration(0.2, delay: 0.0, options: UIViewAnimationOptions.CurveLinear, animations: { () -> Void in
150
- self.trackerButton.hidden = true
151
- self.pauseButton.hidden = false
152
- }, completion: {(f: Bool) -> Void in
153
- println("finished animation start tracking")
154
- })
155
- */
156
-
144
+
157
145
case . tracking:
158
146
print ( " switched to tracking mode " )
159
147
// set trackerButton to allow Pause
160
148
trackerButton. setTitle ( NSLocalizedString ( " PAUSE " , comment: " no comment " ) )
161
149
trackerButton. setBackgroundColor ( kPurpleButtonBackgroundColor)
162
- //activate save & reset buttons
150
+ // Activate save & reset buttons
163
151
saveButton. setBackgroundColor ( kBlueButtonBackgroundColor)
164
152
resetButton. setBackgroundColor ( kRedButtonBackgroundColor)
165
153
// start clock
@@ -173,7 +161,7 @@ class InterfaceController: WKInterfaceController {
173
161
// activate save & reset (just in case switched from .NotStarted)
174
162
saveButton. setBackgroundColor ( kBlueButtonBackgroundColor)
175
163
resetButton. setBackgroundColor ( kRedButtonBackgroundColor)
176
- //pause clock
164
+ // Pause clock
177
165
self . stopWatch. stop ( )
178
166
// start new track segment
179
167
self . map. startNewTrackSegment ( )
@@ -182,7 +170,7 @@ class InterfaceController: WKInterfaceController {
182
170
}
183
171
184
172
/// Editing Waypoint Temporal Reference
185
- var lastLocation : CLLocation ? //Last point of current segment.
173
+ var lastLocation : CLLocation ? // Last point of current segment.
186
174
187
175
override func awake( withContext context: Any ? ) {
188
176
print ( " InterfaceController:: awake " )
@@ -242,7 +230,7 @@ class InterfaceController: WKInterfaceController {
242
230
case . tracking:
243
231
gpxTrackingStatus = . paused
244
232
case . paused:
245
- //set to tracking
233
+ // Set to tracking
246
234
gpxTrackingStatus = . tracking
247
235
}
248
236
@@ -279,7 +267,7 @@ class InterfaceController: WKInterfaceController {
279
267
let gpxString = self . map. exportToGPXString ( )
280
268
GPXFileManager . save ( filename, gpxContents: gpxString)
281
269
self . lastGpxFilename = filename
282
- //print(gpxString)
270
+ // print(gpxString)
283
271
284
272
/// Just a 'done' button, without
285
273
let action = WKAlertAction ( title: " Done " , style: . default) { }
@@ -330,19 +318,19 @@ class InterfaceController: WKInterfaceController {
330
318
func checkLocationServicesStatus( ) {
331
319
let authorizationStatus = CLLocationManager . authorizationStatus ( )
332
320
333
- //Has the user already made a permission choice?
321
+ // Has the user already made a permission choice?
334
322
guard authorizationStatus != . notDetermined else {
335
- //We should take no action until the user has made a choice
323
+ // We should take no action until the user has made a choice
336
324
return
337
325
}
338
326
339
- //Does the app have permissions to use the location servies?
327
+ // Does the app have permissions to use the location servies?
340
328
guard [ . authorizedAlways, . authorizedWhenInUse ] . contains ( authorizationStatus) else {
341
329
displayLocationServicesDeniedAlert ( )
342
330
return
343
331
}
344
332
345
- //Are location services enabled?
333
+ // Are location services enabled?
346
334
guard CLLocationManager . locationServicesEnabled ( ) else {
347
335
displayLocationServicesDisabledAlert ( )
348
336
return
@@ -408,8 +396,6 @@ extension InterfaceController: CLLocationManagerDelegate {
408
396
altitudeLabel. setText ( kUnknownAltitudeText)
409
397
signalImageView. setImage ( signalImage0)
410
398
speedLabel. setText ( kUnknownSpeedText)
411
- //signalAccuracyLabel.text = kUnknownAccuracyText
412
- //signalImageView.image = signalImage0
413
399
let locationError = error as? CLError
414
400
switch locationError? . code {
415
401
case CLError . locationUnknown:
@@ -430,7 +416,7 @@ extension InterfaceController: CLLocationManagerDelegate {
430
416
///
431
417
///
432
418
func locationManager( _ manager: CLLocationManager , didUpdateLocations locations: [ CLLocation ] ) {
433
- //updates signal image accuracy
419
+ // Updates signal image accuracy
434
420
let newLocation = locations. first!
435
421
436
422
let hAcc = newLocation. horizontalAccuracy
@@ -461,14 +447,13 @@ extension InterfaceController: CLLocationManagerDelegate {
461
447
coordinatesLabel. setText ( " \( latFormat) , \( lonFormat) " )
462
448
altitudeLabel. setText ( newLocation. altitude. toAltitude ( useImperial: preferences. useImperial) )
463
449
464
- //Update speed (provided in m/s, but displayed in km/h)
450
+ // Update speed (provided in m/s, but displayed in km/h)
465
451
speedLabel. setText ( newLocation. speed. toSpeed ( useImperial: preferences. useImperial) )
466
452
467
453
if gpxTrackingStatus == . tracking {
468
454
print ( " didUpdateLocation: adding point to track ( \( newLocation. coordinate. latitude) , \( newLocation. coordinate. longitude) ) " )
469
455
map. addPointToCurrentTrackSegmentAtLocation ( newLocation)
470
456
totalTrackedDistanceLabel. setText ( map. totalTrackedDistance. toDistance ( useImperial: preferences. useImperial) )
471
- //currentSegmentDistanceLabel.distance = map.currentSegmentDistance
472
457
}
473
458
}
474
459
}
0 commit comments