Expose manual censorship circumvention setting.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-05-11 09:50:44 -04:00
parent db10cbaeea
commit e746636c7c
2 changed files with 60 additions and 6 deletions

View File

@ -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

View File

@ -1087,6 +1087,15 @@
/* Title for the 'add to block list' view. */
"SETTINGS_ADD_TO_BLOCK_LIST_TITLE" = "Block";
/* Label for the 'censorship circumvention' switch. */
"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION" = "Censorship Circumvention";
/* Table footer for the 'censorship circumvention' section. */
"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_FOOTER" = "Do not enable this feature unless you are in a location where Signal is censored.";
/* Table header for the 'censorship circumvention' section. */
"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_HEADER" = "Censorship Circumvention";
/* No comment provided by engineer. */
"SETTINGS_ADVANCED_DEBUGLOG" = "Enable Debug Log";
@ -1165,7 +1174,7 @@
/* Short table cell label */
"SETTINGS_PRIVACY_CALLKIT_TITLE" = "iOS Call Integration";
/* No comment provided by engineer. */
/* Settings table view cell label */
"SETTINGS_PRIVACY_TITLE" = "Privacy";
/* Section header */