forked from organicmaps/organicmaps
[ios] Improved Enable/Disable statistics option code.
This commit is contained in:
parent
2b5fc89216
commit
4fd3a63168
3 changed files with 16 additions and 9 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
+ (Statistics *)instance
|
||||
- (void)setEnabled:(BOOL)enabled
|
||||
{
|
||||
Settings::Set(kStatisticsEnabledSettingsKey, static_cast<bool>(enabled));
|
||||
}
|
||||
|
||||
+ (instancetype)instance
|
||||
{
|
||||
static Statistics * instance;
|
||||
static dispatch_once_t onceToken;
|
||||
|
|
Loading…
Add table
Reference in a new issue