@@ -16,24 +16,33 @@ import CoreServices
16
16
/// Units Section Id in PreferencesTableViewController
17
17
let kUnitsSection = 0
18
18
19
+ /// Screen always on section id
20
+ let kScreenSection = 1
21
+
19
22
/// Cache Section Id in PreferencesTableViewController
20
- let kCacheSection = 1
23
+ let kCacheSection = 2
21
24
22
25
/// Map Source Section Id in PreferencesTableViewController
23
- let kMapSourceSection = 2
26
+ let kMapSourceSection = 3
24
27
25
28
/// Activity Type Section Id in PreferencesTableViewController
26
- let kActivityTypeSection = 3
29
+ let kActivityTypeSection = 4
27
30
28
31
/// Default Name Section Id in PreferencesTableViewController
29
- let kDefaultNameSection = 4
32
+ let kDefaultNameSection = 5
30
33
31
34
/// GPX Files Location Section Id in PreferencesTableViewController
32
- let kGPXFilesLocationSection = 5
35
+ let kGPXFilesLocationSection = 6
33
36
34
37
/// Cell Id of the Use Imperial units in UnitsSection
35
38
let kUseImperialUnitsCell = 0
36
39
40
+
41
+ /// Cell Id of the keepScreenAlwaysOnl units in ScreenSection
42
+ let kKeepScreenAlwaysOnCell = 0
43
+
44
+
45
+
37
46
/// Cell Id for Use offline cache in CacheSection of PreferencesTableViewController
38
47
let kUseOfflineCacheCell = 0
39
48
@@ -119,6 +128,7 @@ class PreferencesTableViewController: UITableViewController, UINavigationBarDele
119
128
case kActivityTypeSection: return NSLocalizedString ( " ACTIVITY_TYPE " , comment: " no comment " )
120
129
case kDefaultNameSection: return NSLocalizedString ( " DEFAULT_NAME_SECTION " , comment: " no comment " )
121
130
case kGPXFilesLocationSection: return NSLocalizedString ( " GPX_FILES_FOLDER " , comment: " no comment " )
131
+ case kScreenSection: return NSLocalizedString ( " SCREEN " , comment: " no comment " )
122
132
default : fatalError ( " Unknown section " )
123
133
}
124
134
}
@@ -134,6 +144,7 @@ class PreferencesTableViewController: UITableViewController, UINavigationBarDele
134
144
case kActivityTypeSection: return CLActivityType . count
135
145
case kDefaultNameSection: return 1
136
146
case kGPXFilesLocationSection: return 1
147
+ case kScreenSection: return 1
137
148
default : fatalError ( " Unknown section " )
138
149
}
139
150
}
@@ -166,6 +177,19 @@ class PreferencesTableViewController: UITableViewController, UINavigationBarDele
166
177
}
167
178
}
168
179
180
+ // Units section
181
+ if indexPath. section == kScreenSection {
182
+ switch indexPath. row {
183
+ case kKeepScreenAlwaysOnCell:
184
+ cell = UITableViewCell ( style: . value1, reuseIdentifier: " CacheCell " )
185
+ cell. textLabel? . text = NSLocalizedString ( " KEEP_SCREEN_ALWAYS_ON " , comment: " no comment " )
186
+ if preferences. keepScreenAlwaysOn {
187
+ cell. accessoryType = . checkmark
188
+ }
189
+ default : fatalError ( " Unknown section " )
190
+ }
191
+ }
192
+
169
193
// Cache Section
170
194
if indexPath. section == kCacheSection {
171
195
switch indexPath. row {
@@ -264,6 +288,22 @@ class PreferencesTableViewController: UITableViewController, UINavigationBarDele
264
288
}
265
289
}
266
290
291
+ if indexPath. section == kScreenSection {
292
+ switch indexPath. row {
293
+ case kKeepScreenAlwaysOnCell:
294
+ let newKeepScreenAlwaysOn = !preferences. keepScreenAlwaysOn
295
+ preferences. keepScreenAlwaysOn = newKeepScreenAlwaysOn
296
+ print ( " PreferencesTableViewController: toggle keep screen always on to \( newKeepScreenAlwaysOn) " )
297
+ // Update cell UI
298
+ tableView. cellForRow ( at: indexPath) ? . accessoryType = newKeepScreenAlwaysOn ? . checkmark : . none
299
+ // Notify the map
300
+ self . delegate? . didUpdateKeepScreenAlwaysOn ( newKeepScreenAlwaysOn)
301
+ default :
302
+ fatalError ( " didSelectRowAt: Unknown cell " )
303
+ }
304
+ }
305
+
306
+
267
307
if indexPath. section == kCacheSection { // 0 -> sets and unsets cache
268
308
switch indexPath. row {
269
309
case kUseOfflineCacheCell:
0 commit comments