From 1dffdb5ca037b96ec6b30dd01fccd61fb6a6ed6e Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 6 Jun 2017 10:40:25 -0400 Subject: [PATCH] Indicate if censorship circumvention is active in the main app settings view. // FREEBIE --- .../SettingsTableViewController.m | 75 ++++++++++++------- .../translations/en.lproj/Localizable.strings | 3 + 2 files changed, 49 insertions(+), 29 deletions(-) diff --git a/Signal/src/ViewControllers/SettingsTableViewController.m b/Signal/src/ViewControllers/SettingsTableViewController.m index f5d234403..7a9a7bea8 100644 --- a/Signal/src/ViewControllers/SettingsTableViewController.m +++ b/Signal/src/ViewControllers/SettingsTableViewController.m @@ -75,6 +75,13 @@ [self updateTableContents]; } +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + + [self updateTableContents]; +} + - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } @@ -120,37 +127,47 @@ } customRowHeight:96.f actionBlock:nil]]; - [section addItem:[OWSTableItem itemWithCustomCellBlock:^{ - UITableViewCell *cell = [UITableViewCell new]; - cell.textLabel.text = NSLocalizedString( - @"NETWORK_STATUS_HEADER", @""); - cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f]; - cell.textLabel.textColor = [UIColor blackColor]; - - UILabel *accessoryLabel = [UILabel new]; - accessoryLabel.font = [UIFont ows_regularFontWithSize:18.f]; - switch ([TSSocketManager sharedManager].state) { - case SocketManagerStateClosed: - accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_OFFLINE", @""); - accessoryLabel.textColor = [UIColor ows_redColor]; - break; - case SocketManagerStateConnecting: - accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTING", @""); - accessoryLabel.textColor = [UIColor ows_yellowColor]; - break; - case SocketManagerStateOpen: - accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTED", @""); - accessoryLabel.textColor = [UIColor ows_greenColor]; - break; + + if (OWSSignalService.sharedInstance.isCensorshipCircumventionActive) { + [section + addItem:[OWSTableItem disclosureItemWithText: + NSLocalizedString(@"NETWORK_STATUS_CENSORSHIP_CIRCUMVENTION_ACTIVE", + @"Indicates to the user that censorship circumvention has been activated.") + actionBlock:^{ + [weakSelf showAdvanced]; + }]]; + } else { + [section addItem:[OWSTableItem itemWithCustomCellBlock:^{ + UITableViewCell *cell = [UITableViewCell new]; + cell.textLabel.text = NSLocalizedString(@"NETWORK_STATUS_HEADER", @""); + cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f]; + cell.textLabel.textColor = [UIColor blackColor]; + + UILabel *accessoryLabel = [UILabel new]; + accessoryLabel.font = [UIFont ows_regularFontWithSize:18.f]; + switch ([TSSocketManager sharedManager].state) { + case SocketManagerStateClosed: + accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_OFFLINE", @""); + accessoryLabel.textColor = [UIColor ows_redColor]; + break; + case SocketManagerStateConnecting: + accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTING", @""); + accessoryLabel.textColor = [UIColor ows_yellowColor]; + break; + case SocketManagerStateOpen: + accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTED", @""); + accessoryLabel.textColor = [UIColor ows_greenColor]; + break; + } + [accessoryLabel sizeToFit]; + cell.accessoryView = accessoryLabel; + return cell; } - [accessoryLabel sizeToFit]; - cell.accessoryView = accessoryLabel; - return cell; + actionBlock:^{ + [OWSAlerts showAlertWithTitle:NSLocalizedString(@"NETWORK_STATUS_HEADER", @"") + message:NSLocalizedString(@"NETWORK_STATUS_TEXT", @"")]; + }]]; } - actionBlock:^{ - [OWSAlerts showAlertWithTitle:NSLocalizedString(@"NETWORK_STATUS_HEADER", @"") - message:NSLocalizedString(@"NETWORK_STATUS_TEXT", @"")]; - }]]; [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_INVITE_TITLE", @"Settings table view cell label") actionBlock:^{ diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 372da52d2..9092bcaf1 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -792,6 +792,9 @@ /* No comment provided by engineer. */ "NETWORK_ERROR_RECOVERY" = "Please check you're online and try again."; +/* Indicates to the user that censorship circumvention has been activated. */ +"NETWORK_STATUS_CENSORSHIP_CIRCUMVENTION_ACTIVE" = "Censorship Circumvention: On"; + /* No comment provided by engineer. */ "NETWORK_STATUS_CONNECTED" = "Connected";