Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <alex@maps.me>2015-09-02 04:47:20 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 03:03:35 +0300
commit4fd3a63168e5ea81559a60c09cafdf60d19a827e (patch)
treefb09f08c9b347a047a5167942136567e4e6d9af8
parent2b5fc89216af4da328a803ac22a416e8f41b86b7 (diff)
[ios] Improved Enable/Disable statistics option code.
-rw-r--r--iphone/Maps/Settings/SettingsViewController.mm5
-rw-r--r--iphone/Maps/Statistics/Statistics.h4
-rw-r--r--iphone/Maps/Statistics/Statistics.mm16
3 files changed, 16 insertions, 9 deletions
diff --git a/iphone/Maps/Settings/SettingsViewController.mm b/iphone/Maps/Settings/SettingsViewController.mm
index 04ac2cc9fb..086852f323 100644
--- a/iphone/Maps/Settings/SettingsViewController.mm
+++ b/iphone/Maps/Settings/SettingsViewController.mm
@@ -126,8 +126,9 @@ typedef NS_ENUM(NSUInteger, Section)
NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
if (indexPath.section == SectionStatistics)
{
- [[Statistics instance] logEvent:@"StatisticsStatusChanged" withParameters:@{@"Enabled" : @(value)}];
- Settings::Set("StatisticsEnabled", (bool)value);
+ Statistics * stat = [Statistics instance];
+ [stat logEvent:@"StatisticsStatusChanged" withParameters:@{@"Enabled" : @(value)}];
+ stat.enabled = value;
}
else if (indexPath.section == SectionZoomButtons)
{
diff --git a/iphone/Maps/Statistics/Statistics.h b/iphone/Maps/Statistics/Statistics.h
index b44bc9f0b1..b4094b262f 100644
--- a/iphone/Maps/Statistics/Statistics.h
+++ b/iphone/Maps/Statistics/Statistics.h
@@ -11,8 +11,8 @@
- (void)logApiUsage:(NSString *)programName;
- (void)logLocation:(CLLocation *)location;
-+ (id)instance;
++ (instancetype)instance;
-@property (nonatomic, readonly) BOOL enabled;
+@property (nonatomic) BOOL enabled;
@end
diff --git a/iphone/Maps/Statistics/Statistics.mm b/iphone/Maps/Statistics/Statistics.mm
index 2b8ca92b90..6e7f8a3665 100644
--- a/iphone/Maps/Statistics/Statistics.mm
+++ b/iphone/Maps/Statistics/Statistics.mm
@@ -4,6 +4,8 @@
#include "platform/settings.hpp"
+static constexpr char const * kStatisticsEnabledSettingsKey = "StatisticsEnabled";
+
@implementation Statistics
- (void)startSessionWithLaunchOptions:(NSDictionary *)launchOptions
@@ -58,16 +60,20 @@
- (BOOL)enabled
{
#ifdef DEBUG
- return NO;
+ bool statisticsEnabled = false;
#else
bool statisticsEnabled = true;
- Settings::Get("StatisticsEnabled", statisticsEnabled);
-
- return statisticsEnabled;
#endif
+ (void)Settings::Get(kStatisticsEnabledSettingsKey, statisticsEnabled);
+ return statisticsEnabled;
+}
+
+- (void)setEnabled:(BOOL)enabled
+{
+ Settings::Set(kStatisticsEnabledSettingsKey, static_cast<bool>(enabled));
}
-+ (Statistics *)instance
++ (instancetype)instance
{
static Statistics * instance;
static dispatch_once_t onceToken;