blob: 1b9dcc084fd8884c7a4fb2275980d26388c2cf48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#import "Preferences.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIAlertView.h>
#import "../Classes/MapViewController.h"
#import "Framework.h"
#include "platform/settings.hpp"
//********************* Helper delegate to handle async dialog message ******************
@interface PrefDelegate : NSObject
@property (nonatomic, weak) id m_controller;
@end
@implementation PrefDelegate
@end
//***************************************************************************************
@implementation Preferences
// TODO: Export this logic to C++
+ (void)setup:(id)controller
{
Settings::Units u;
if (!Settings::Get("Units", u))
{
// get system locale preferences
BOOL const isMetric = [[[NSLocale autoupdatingCurrentLocale] objectForKey:NSLocaleUsesMetricSystem] boolValue];
if (isMetric)
{
u = Settings::Metric;
[controller setupMeasurementSystem];
}
else
{
u = Settings::Foot;
// Will be released in delegate's callback itself
PrefDelegate * d = [[PrefDelegate alloc] init];
d.m_controller = controller;
}
Settings::Set("Units", u);
}
else
[controller setupMeasurementSystem];
}
@end
|