Support GA services

Make GA togglable in Settings

#335
This commit is contained in:
giomfo
2016-06-04 17:37:23 +02:00
parent 0ff2d49993
commit 4112027217
5 changed files with 70 additions and 18 deletions
+48 -7
View File
@@ -48,8 +48,9 @@
#define OTHER_TERM_CONDITIONS_INDEX 1
#define OTHER_PRIVACY_INDEX 2
#define OTHER_THIRD_PARTY_INDEX 3
#define OTHER_CLEAR_CACHE_INDEX 4
#define OTHER_COUNT 5
#define OTHER_CRASH_REPORT_INDEX 4
#define OTHER_CLEAR_CACHE_INDEX 5
#define OTHER_COUNT 6
typedef void (^blockSettingsViewController_onReadyToDestroy)();
@@ -523,7 +524,9 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
{
cell = [[MXKTableViewCellWithLabelAndTextField alloc] init];
cell.mxkLabelLeadingConstraint.constant = 15;
UIEdgeInsets separatorInset = cell.separatorInset;
cell.mxkLabelLeadingConstraint.constant = separatorInset.left;
cell.mxkTextFieldTrailingConstraint.constant = 15;
}
@@ -549,7 +552,9 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
{
cell = [[MXKTableViewCellWithLabelAndSwitch alloc] init];
cell.mxkLabelLeadingConstraint.constant = 15;
UIEdgeInsets separatorInset = cell.separatorInset;
cell.mxkLabelLeadingConstraint.constant = separatorInset.left;
cell.mxkSwitchTrailingConstraint.constant = 15;
}
@@ -923,6 +928,18 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
cell = thirdPartyCell;
}
else if (row == OTHER_CRASH_REPORT_INDEX)
{
MXKTableViewCellWithLabelAndSwitch* sendCrashReportCell = [self getLabelAndSwitchCell:tableView];
sendCrashReportCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_send_crash_report", @"Vector", nil);
sendCrashReportCell.mxkSwitch.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"enableCrashReport"];
[sendCrashReportCell.mxkSwitch removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
[sendCrashReportCell.mxkSwitch addTarget:self action:@selector(toggleSendCrashReport:) forControlEvents:UIControlEventTouchUpInside];
[sendCrashReportCell layoutIfNeeded];
cell = sendCrashReportCell;
}
else if (row == OTHER_CLEAR_CACHE_INDEX)
{
MXKTableViewCellWithButton *clearCacheBtnCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier]];
@@ -1118,6 +1135,30 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
}
}
- (void)toggleSendCrashReport:(id)sender
{
BOOL enable = [[NSUserDefaults standardUserDefaults] boolForKey:@"enableCrashReport"];
if (enable)
{
NSLog(@"[SettingsViewController] disable automatic crash report sending");
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"enableCrashReport"];
[[NSUserDefaults standardUserDefaults] synchronize];
[[AppDelegate theDelegate] stopGoogleAnalytics];
// Remove potential crash file.
[MXLogger deleteCrashLog];
}
else
{
NSLog(@"[SettingsViewController] enable automatic crash report sending");
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"enableCrashReport"];
[[NSUserDefaults standardUserDefaults] synchronize];
[[AppDelegate theDelegate] startGoogleAnalytics];
}
}
- (void)onClearCache:(id)sender
{
[[AppDelegate theDelegate] reloadMatrixSessions:YES];
@@ -1195,7 +1236,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
} failure:^(NSError *error) {
NSLog(@"[Vector Settings View Controller] Failed to set displayName");
NSLog(@"[SettingsViewController] Failed to set displayName");
if (weakSelf)
{
@@ -1231,7 +1272,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
} failure:^(NSError *error) {
NSLog(@"[Vector SettingsViewController] Failed to upload image");
NSLog(@"[SettingsViewController] Failed to upload image");
if (weakSelf)
{
@@ -1258,7 +1299,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
}
failure:^(NSError *error) {
NSLog(@"[Vector SettingsViewController] Failed to set avatar url");
NSLog(@"[SettingsViewController] Failed to set avatar url");
if (weakSelf)
{