|
|
|
@ -5,11 +5,12 @@
|
|
|
|
|
#import "AdvancedSettingsTableViewController.h"
|
|
|
|
|
#import "DebugLogger.h"
|
|
|
|
|
#import "Environment.h"
|
|
|
|
|
#import "Pastelog.h"
|
|
|
|
|
#import "PropertyListPreferences.h"
|
|
|
|
|
#import "PushManager.h"
|
|
|
|
|
#import "Signal-Swift.h"
|
|
|
|
|
#import "TSAccountManager.h"
|
|
|
|
|
#import "Pastelog.h"
|
|
|
|
|
#import <SignalServiceKit/OWSSignalService.h>
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
@ -17,6 +18,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
@property (nonatomic) UISwitch *enableLogSwitch;
|
|
|
|
|
|
|
|
|
|
@property (nonatomic) UISwitch *enableCensorshipCircumventionSwitch;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
@ -28,13 +31,20 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
[super loadView];
|
|
|
|
|
|
|
|
|
|
self.title = NSLocalizedString(@"SETTINGS_ADVANCED_TITLE", @"");
|
|
|
|
|
|
|
|
|
|
self.enableLogSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
|
|
|
|
|
|
|
|
|
|
self.enableLogSwitch = [UISwitch new];
|
|
|
|
|
[self.enableLogSwitch setOn:[PropertyListPreferences loggingIsEnabled]];
|
|
|
|
|
[self.enableLogSwitch addTarget:self
|
|
|
|
|
action:@selector(didToggleEnableLogSwitch:)
|
|
|
|
|
forControlEvents:UIControlEventValueChanged];
|
|
|
|
|
|
|
|
|
|
self.enableCensorshipCircumventionSwitch = [UISwitch new];
|
|
|
|
|
[self.enableCensorshipCircumventionSwitch
|
|
|
|
|
setOn:OWSSignalService.sharedInstance.isCensorshipCircumventionManuallyActivated];
|
|
|
|
|
[self.enableCensorshipCircumventionSwitch addTarget:self
|
|
|
|
|
action:@selector(didToggleEnableCensorshipCircumventionSwitch:)
|
|
|
|
|
forControlEvents:UIControlEventValueChanged];
|
|
|
|
|
|
|
|
|
|
[self observeNotifications];
|
|
|
|
|
|
|
|
|
|
[self updateTableContents];
|
|
|
|
@ -100,10 +110,40 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
actionBlock:^{
|
|
|
|
|
[weakSelf syncPushTokens];
|
|
|
|
|
}]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[contents addSection:pushNotificationsSection];
|
|
|
|
|
|
|
|
|
|
// Censorship circumvention has certain disadvantages so it should only be
|
|
|
|
|
// used if necessary. Therefore:
|
|
|
|
|
//
|
|
|
|
|
// * We don't show this setting if the user has a phone number from a censored region -
|
|
|
|
|
// censorship circumvention will be auto-activated for this user.
|
|
|
|
|
// * We don't show this setting if the user is already connected; they're not being
|
|
|
|
|
// censored.
|
|
|
|
|
// * We continue to show this setting so long as it is set to allow users to disable
|
|
|
|
|
// it, for example when they leave a censored region.
|
|
|
|
|
if (!OWSSignalService.sharedInstance.hasCensoredPhoneNumber
|
|
|
|
|
&& (OWSSignalService.sharedInstance.isCensorshipCircumventionManuallyActivated ||
|
|
|
|
|
[TSSocketManager sharedManager].state != SocketManagerStateOpen)) {
|
|
|
|
|
OWSTableSection *censorshipSection = [OWSTableSection new];
|
|
|
|
|
censorshipSection.headerTitle = NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_HEADER",
|
|
|
|
|
@"Table header for the 'censorship circumvention' section.");
|
|
|
|
|
censorshipSection.footerTitle = NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER",
|
|
|
|
|
@"Table footer for the 'censorship circumvention' section.");
|
|
|
|
|
[pushNotificationsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
|
|
|
|
|
UITableViewCell *cell = [UITableViewCell new];
|
|
|
|
|
cell.textLabel.text = NSLocalizedString(
|
|
|
|
|
@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION", @"Label for the 'censorship circumvention' switch.");
|
|
|
|
|
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
|
|
|
|
|
cell.textLabel.textColor = [UIColor blackColor];
|
|
|
|
|
|
|
|
|
|
cell.accessoryView = self.enableCensorshipCircumventionSwitch;
|
|
|
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
|
|
return cell;
|
|
|
|
|
}
|
|
|
|
|
actionBlock:nil]];
|
|
|
|
|
[contents addSection:censorshipSection];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.contents = contents;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -133,6 +173,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
[self updateTableContents];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)didToggleEnableCensorshipCircumventionSwitch:(UISwitch *)sender
|
|
|
|
|
{
|
|
|
|
|
OWSSignalService.sharedInstance.isCensorshipCircumventionManuallyActivated = sender.isOn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Logging
|
|
|
|
|
|
|
|
|
|
+ (NSString *)tag
|
|
|
|
|