2015-01-16 15:28:41 +01:00
|
|
|
//
|
2019-01-17 22:47:36 +01:00
|
|
|
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
2015-01-16 15:28:41 +01:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "PrivacySettingsTableViewController.h"
|
2017-04-03 23:48:55 +02:00
|
|
|
#import "BlockListViewController.h"
|
2018-02-28 16:55:33 +01:00
|
|
|
#import "OWS2FASettingsViewController.h"
|
2017-02-25 04:15:11 +01:00
|
|
|
#import "Signal-Swift.h"
|
2017-12-19 03:50:51 +01:00
|
|
|
#import <SignalMessaging/Environment.h>
|
|
|
|
#import <SignalMessaging/OWSPreferences.h>
|
2018-03-20 18:02:10 +01:00
|
|
|
#import <SignalMessaging/ThreadUtil.h>
|
2018-10-22 16:00:40 +02:00
|
|
|
#import <SignalMessaging/UIColor+OWS.h>
|
2018-12-19 22:35:43 +01:00
|
|
|
#import <SignalServiceKit/NSString+SSK.h>
|
2018-02-28 15:58:54 +01:00
|
|
|
#import <SignalServiceKit/OWS2FAManager.h>
|
2017-09-15 21:28:44 +02:00
|
|
|
#import <SignalServiceKit/OWSReadReceiptManager.h>
|
2018-10-10 20:04:40 +02:00
|
|
|
#import <SignalServiceKit/SignalServiceKit-Swift.h>
|
2015-01-16 15:28:41 +01:00
|
|
|
|
2016-11-08 19:08:04 +01:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2018-10-31 00:06:25 +01:00
|
|
|
static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-sender/";
|
|
|
|
|
2015-01-16 15:28:41 +01:00
|
|
|
@implementation PrivacySettingsTableViewController
|
|
|
|
|
2018-03-05 17:57:12 +01:00
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
2015-01-16 15:28:41 +01:00
|
|
|
[super viewDidLoad];
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2015-02-18 23:21:03 +01:00
|
|
|
self.title = NSLocalizedString(@"SETTINGS_PRIVACY_TITLE", @"");
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2018-03-21 18:25:39 +01:00
|
|
|
[self observeNotifications];
|
|
|
|
|
2017-07-14 16:55:49 +02:00
|
|
|
[self updateTableContents];
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
|
|
|
|
2017-07-14 16:55:49 +02:00
|
|
|
- (void)viewDidAppear:(BOOL)animated
|
|
|
|
{
|
2018-07-18 03:50:13 +02:00
|
|
|
[super viewDidAppear:animated];
|
|
|
|
|
2017-07-14 16:55:49 +02:00
|
|
|
[self updateTableContents];
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
|
|
|
|
2018-03-21 18:25:39 +01:00
|
|
|
- (void)observeNotifications
|
|
|
|
{
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
selector:@selector(screenLockDidChange:)
|
|
|
|
name:OWSScreenLock.ScreenLockDidChange
|
|
|
|
object:nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
}
|
|
|
|
|
2018-10-10 20:04:40 +02:00
|
|
|
#pragma mark - Dependencies
|
|
|
|
|
|
|
|
- (id<OWSUDManager>)udManager
|
|
|
|
{
|
|
|
|
return SSKEnvironment.shared.udManager;
|
|
|
|
}
|
|
|
|
|
2018-10-11 01:17:01 +02:00
|
|
|
- (OWSPreferences *)preferences
|
|
|
|
{
|
|
|
|
return Environment.shared.preferences;
|
|
|
|
}
|
|
|
|
|
2018-10-31 17:06:02 +01:00
|
|
|
- (OWSReadReceiptManager *)readReceiptManager
|
|
|
|
{
|
|
|
|
return OWSReadReceiptManager.sharedManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id<OWSTypingIndicators>)typingIndicators
|
|
|
|
{
|
|
|
|
return SSKEnvironment.shared.typingIndicators;
|
|
|
|
}
|
|
|
|
|
2017-07-14 16:55:49 +02:00
|
|
|
#pragma mark - Table Contents
|
2015-01-16 15:28:41 +01:00
|
|
|
|
2017-07-14 16:55:49 +02:00
|
|
|
- (void)updateTableContents
|
2016-11-08 19:08:04 +01:00
|
|
|
{
|
2017-07-14 16:55:49 +02:00
|
|
|
OWSTableContents *contents = [OWSTableContents new];
|
|
|
|
|
|
|
|
__weak PrivacySettingsTableViewController *weakSelf = self;
|
|
|
|
|
2018-03-21 22:11:38 +01:00
|
|
|
OWSTableSection *blocklistSection = [OWSTableSection new];
|
|
|
|
blocklistSection.headerTitle
|
|
|
|
= NSLocalizedString(@"SETTINGS_BLOCK_LIST_TITLE", @"Label for the block list section of the settings view");
|
|
|
|
[blocklistSection
|
|
|
|
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_BLOCK_LIST_TITLE",
|
|
|
|
@"Label for the block list section of the settings view")
|
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf showBlocklist];
|
|
|
|
}]];
|
|
|
|
[contents addSection:blocklistSection];
|
2017-07-14 16:55:49 +02:00
|
|
|
|
2017-09-14 22:25:36 +02:00
|
|
|
OWSTableSection *readReceiptsSection = [OWSTableSection new];
|
2018-03-21 22:11:38 +01:00
|
|
|
readReceiptsSection.headerTitle
|
|
|
|
= NSLocalizedString(@"SETTINGS_READ_RECEIPT", @"Label for the 'read receipts' setting.");
|
2017-09-14 22:25:36 +02:00
|
|
|
readReceiptsSection.footerTitle = NSLocalizedString(
|
|
|
|
@"SETTINGS_READ_RECEIPTS_SECTION_FOOTER", @"An explanation of the 'read receipts' setting.");
|
2018-10-31 17:06:02 +01:00
|
|
|
[readReceiptsSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_READ_RECEIPT",
|
|
|
|
@"Label for the 'read receipts' setting.")
|
|
|
|
isOn:[self.readReceiptManager areReadReceiptsEnabled]
|
|
|
|
target:weakSelf
|
|
|
|
selector:@selector(didToggleReadReceiptsSwitch:)]];
|
2017-09-14 22:25:36 +02:00
|
|
|
[contents addSection:readReceiptsSection];
|
|
|
|
|
2018-10-31 17:06:02 +01:00
|
|
|
OWSTableSection *typingIndicatorsSection = [OWSTableSection new];
|
|
|
|
typingIndicatorsSection.headerTitle
|
|
|
|
= NSLocalizedString(@"SETTINGS_TYPING_INDICATORS", @"Label for the 'typing indicators' setting.");
|
2018-11-08 17:29:11 +01:00
|
|
|
typingIndicatorsSection.footerTitle = NSLocalizedString(
|
|
|
|
@"SETTINGS_TYPING_INDICATORS_FOOTER", @"An explanation of the 'typing indicators' setting.");
|
2018-10-31 17:06:02 +01:00
|
|
|
[typingIndicatorsSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_TYPING_INDICATORS",
|
|
|
|
@"Label for the 'typing indicators' setting.")
|
|
|
|
isOn:[self.typingIndicators areTypingIndicatorsEnabled]
|
|
|
|
target:weakSelf
|
|
|
|
selector:@selector(didToggleTypingIndicatorsSwitch:)]];
|
|
|
|
[contents addSection:typingIndicatorsSection];
|
|
|
|
|
2018-03-21 22:11:38 +01:00
|
|
|
OWSTableSection *screenLockSection = [OWSTableSection new];
|
|
|
|
screenLockSection.headerTitle = NSLocalizedString(
|
|
|
|
@"SETTINGS_SCREEN_LOCK_SECTION_TITLE", @"Title for the 'screen lock' section of the privacy settings.");
|
|
|
|
screenLockSection.footerTitle = NSLocalizedString(
|
|
|
|
@"SETTINGS_SCREEN_LOCK_SECTION_FOOTER", @"Footer for the 'screen lock' section of the privacy settings.");
|
|
|
|
[screenLockSection
|
|
|
|
addItem:[OWSTableItem
|
|
|
|
switchItemWithText:NSLocalizedString(@"SETTINGS_SCREEN_LOCK_SWITCH_LABEL",
|
|
|
|
@"Label for the 'enable screen lock' switch of the privacy settings.")
|
|
|
|
isOn:OWSScreenLock.sharedManager.isScreenLockEnabled
|
|
|
|
target:self
|
|
|
|
selector:@selector(isScreenLockEnabledDidChange:)]];
|
|
|
|
[contents addSection:screenLockSection];
|
|
|
|
|
|
|
|
if (OWSScreenLock.sharedManager.isScreenLockEnabled) {
|
|
|
|
OWSTableSection *screenLockTimeoutSection = [OWSTableSection new];
|
|
|
|
uint32_t screenLockTimeout = (uint32_t)round(OWSScreenLock.sharedManager.screenLockTimeout);
|
2018-03-22 21:21:41 +01:00
|
|
|
NSString *screenLockTimeoutString = [self formatScreenLockTimeout:screenLockTimeout useShortFormat:YES];
|
2018-03-21 22:11:38 +01:00
|
|
|
[screenLockTimeoutSection
|
|
|
|
addItem:[OWSTableItem
|
|
|
|
disclosureItemWithText:
|
|
|
|
NSLocalizedString(@"SETTINGS_SCREEN_LOCK_ACTIVITY_TIMEOUT",
|
|
|
|
@"Label for the 'screen lock activity timeout' setting of the privacy settings.")
|
|
|
|
detailText:screenLockTimeoutString
|
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf showScreenLockTimeoutUI];
|
|
|
|
}]];
|
|
|
|
[contents addSection:screenLockTimeoutSection];
|
|
|
|
}
|
|
|
|
|
2017-09-27 22:57:02 +02:00
|
|
|
OWSTableSection *screenSecuritySection = [OWSTableSection new];
|
|
|
|
screenSecuritySection.headerTitle = NSLocalizedString(@"SETTINGS_SECURITY_TITLE", @"Section header");
|
|
|
|
screenSecuritySection.footerTitle = NSLocalizedString(@"SETTINGS_SCREEN_SECURITY_DETAIL", nil);
|
2018-10-11 01:17:01 +02:00
|
|
|
[screenSecuritySection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_SCREEN_SECURITY", @"")
|
|
|
|
isOn:[self.preferences screenSecurityIsEnabled]
|
|
|
|
target:weakSelf
|
|
|
|
selector:@selector(didToggleScreenSecuritySwitch:)]];
|
2017-09-27 22:57:02 +02:00
|
|
|
[contents addSection:screenSecuritySection];
|
2018-01-03 18:35:36 +01:00
|
|
|
|
2017-07-14 16:55:49 +02:00
|
|
|
// Allow calls to connect directly vs. using TURN exclusively
|
|
|
|
OWSTableSection *callingSection = [OWSTableSection new];
|
|
|
|
callingSection.headerTitle
|
|
|
|
= NSLocalizedString(@"SETTINGS_SECTION_TITLE_CALLING", @"settings topic header for table section");
|
|
|
|
callingSection.footerTitle = NSLocalizedString(@"SETTINGS_CALLING_HIDES_IP_ADDRESS_PREFERENCE_TITLE_DETAIL",
|
|
|
|
@"User settings section footer, a detailed explanation");
|
|
|
|
[callingSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(
|
|
|
|
@"SETTINGS_CALLING_HIDES_IP_ADDRESS_PREFERENCE_TITLE",
|
|
|
|
@"Table cell label")
|
2018-10-11 01:17:01 +02:00
|
|
|
isOn:[self.preferences doCallsHideIPAddress]
|
2017-07-14 16:55:49 +02:00
|
|
|
target:weakSelf
|
|
|
|
selector:@selector(didToggleCallsHideIPAddressSwitch:)]];
|
|
|
|
[contents addSection:callingSection];
|
|
|
|
|
2018-02-23 23:08:21 +01:00
|
|
|
if (@available(iOS 11, *)) {
|
|
|
|
OWSTableSection *callKitSection = [OWSTableSection new];
|
|
|
|
[callKitSection
|
|
|
|
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(
|
|
|
|
@"SETTINGS_PRIVACY_CALLKIT_SYSTEM_CALL_LOG_PREFERENCE_TITLE",
|
|
|
|
@"Short table cell label")
|
2018-10-11 01:17:01 +02:00
|
|
|
isOn:[self.preferences isSystemCallLogEnabled]
|
2018-02-23 23:08:21 +01:00
|
|
|
target:weakSelf
|
|
|
|
selector:@selector(didToggleEnableSystemCallLogSwitch:)]];
|
|
|
|
callKitSection.footerTitle = NSLocalizedString(
|
|
|
|
@"SETTINGS_PRIVACY_CALLKIT_SYSTEM_CALL_LOG_PREFERENCE_DESCRIPTION", @"Settings table section footer.");
|
|
|
|
[contents addSection:callKitSection];
|
|
|
|
} else if (@available(iOS 10, *)) {
|
2017-07-14 16:55:49 +02:00
|
|
|
OWSTableSection *callKitSection = [OWSTableSection new];
|
|
|
|
callKitSection.footerTitle
|
|
|
|
= NSLocalizedString(@"SETTINGS_SECTION_CALL_KIT_DESCRIPTION", @"Settings table section footer.");
|
|
|
|
[callKitSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_PRIVACY_CALLKIT_TITLE",
|
|
|
|
@"Short table cell label")
|
2018-10-11 01:17:01 +02:00
|
|
|
isOn:[self.preferences isCallKitEnabled]
|
2017-07-14 16:55:49 +02:00
|
|
|
target:weakSelf
|
|
|
|
selector:@selector(didToggleEnableCallKitSwitch:)]];
|
2018-10-11 01:17:01 +02:00
|
|
|
if (self.preferences.isCallKitEnabled) {
|
2017-07-14 16:55:49 +02:00
|
|
|
[callKitSection
|
|
|
|
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_PRIVACY_CALLKIT_PRIVACY_TITLE",
|
|
|
|
@"Label for 'CallKit privacy' preference")
|
2018-10-11 01:17:01 +02:00
|
|
|
isOn:![self.preferences isCallKitPrivacyEnabled]
|
2017-07-14 16:55:49 +02:00
|
|
|
target:weakSelf
|
|
|
|
selector:@selector(didToggleEnableCallKitPrivacySwitch:)]];
|
2016-11-08 19:08:04 +01:00
|
|
|
}
|
2017-07-14 16:55:49 +02:00
|
|
|
[contents addSection:callKitSection];
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
2017-07-14 16:55:49 +02:00
|
|
|
|
2018-02-28 15:58:54 +01:00
|
|
|
OWSTableSection *twoFactorAuthSection = [OWSTableSection new];
|
|
|
|
twoFactorAuthSection.headerTitle = NSLocalizedString(
|
|
|
|
@"SETTINGS_TWO_FACTOR_AUTH_TITLE", @"Title for the 'two factor auth' section of the privacy settings.");
|
|
|
|
[twoFactorAuthSection
|
2018-03-01 04:26:52 +01:00
|
|
|
addItem:
|
|
|
|
[OWSTableItem
|
|
|
|
disclosureItemWithText:NSLocalizedString(@"SETTINGS_TWO_FACTOR_AUTH_ITEM",
|
|
|
|
@"Label for the 'two factor auth' item of the privacy settings.")
|
|
|
|
detailText:
|
|
|
|
([OWS2FAManager.sharedManager is2FAEnabled]
|
|
|
|
? NSLocalizedString(@"SETTINGS_TWO_FACTOR_AUTH_ENABLED",
|
|
|
|
@"Indicates that 'two factor auth' is enabled in the privacy settings.")
|
|
|
|
: NSLocalizedString(@"SETTINGS_TWO_FACTOR_AUTH_DISABLED",
|
|
|
|
@"Indicates that 'two factor auth' is disabled in the privacy settings."))
|
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf show2FASettings];
|
|
|
|
}]];
|
2018-02-28 15:58:54 +01:00
|
|
|
[contents addSection:twoFactorAuthSection];
|
|
|
|
|
2018-03-22 14:02:41 +01:00
|
|
|
OWSTableSection *historyLogsSection = [OWSTableSection new];
|
|
|
|
historyLogsSection.headerTitle = NSLocalizedString(@"SETTINGS_HISTORYLOG_TITLE", @"Section header");
|
|
|
|
[historyLogsSection addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_CLEAR_HISTORY", @"")
|
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf clearHistoryLogs];
|
|
|
|
}]];
|
|
|
|
[contents addSection:historyLogsSection];
|
|
|
|
|
2018-10-11 01:17:42 +02:00
|
|
|
OWSTableSection *unidentifiedDeliveryIndicatorsSection = [OWSTableSection new];
|
|
|
|
unidentifiedDeliveryIndicatorsSection.headerTitle
|
2018-10-10 20:04:40 +02:00
|
|
|
= NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_SECTION_TITLE", @"table section label");
|
2018-10-22 20:28:46 +02:00
|
|
|
[unidentifiedDeliveryIndicatorsSection
|
|
|
|
addItem:[OWSTableItem
|
|
|
|
itemWithCustomCellBlock:^UITableViewCell * {
|
|
|
|
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
|
|
|
|
reuseIdentifier:@"UITableViewCellStyleValue1"];
|
|
|
|
[OWSTableItem configureCell:cell];
|
|
|
|
cell.preservesSuperviewLayoutMargins = YES;
|
|
|
|
cell.contentView.preservesSuperviewLayoutMargins = YES;
|
|
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
|
|
|
|
|
UILabel *label = [UILabel new];
|
|
|
|
label.text
|
|
|
|
= NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_SHOW_INDICATORS", @"switch label");
|
|
|
|
label.font = [UIFont ows_regularFontWithSize:18.f];
|
|
|
|
label.textColor = [Theme primaryColor];
|
|
|
|
[label setContentHuggingHorizontalHigh];
|
|
|
|
|
|
|
|
UIImage *icon = [UIImage imageNamed:@"ic_secret_sender_indicator"];
|
|
|
|
UIImageView *iconView = [[UIImageView alloc]
|
|
|
|
initWithImage:[icon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
|
|
|
|
iconView.tintColor = Theme.secondaryColor;
|
|
|
|
[iconView setContentHuggingHorizontalHigh];
|
|
|
|
|
|
|
|
UIView *spacer = [UIView new];
|
|
|
|
[spacer setContentHuggingHorizontalLow];
|
|
|
|
|
|
|
|
UISwitch *cellSwitch = [UISwitch new];
|
|
|
|
cell.accessoryView = cellSwitch;
|
|
|
|
[cellSwitch setOn:weakSelf.preferences.shouldShowUnidentifiedDeliveryIndicators];
|
|
|
|
[cellSwitch addTarget:weakSelf
|
|
|
|
action:@selector(didToggleUDShowIndicatorsSwitch:)
|
|
|
|
forControlEvents:UIControlEventValueChanged];
|
|
|
|
[cellSwitch setContentHuggingHorizontalHigh];
|
|
|
|
|
|
|
|
UIStackView *stackView =
|
|
|
|
[[UIStackView alloc] initWithArrangedSubviews:@[ label, iconView, spacer, cellSwitch ]];
|
|
|
|
stackView.axis = UILayoutConstraintAxisHorizontal;
|
|
|
|
stackView.spacing = 10;
|
2018-10-24 17:43:28 +02:00
|
|
|
stackView.alignment = UIStackViewAlignmentCenter;
|
2018-10-22 20:28:46 +02:00
|
|
|
|
|
|
|
[cell.contentView addSubview:stackView];
|
|
|
|
[stackView ows_autoPinToSuperviewMargins];
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
customRowHeight:UITableViewAutomaticDimension
|
|
|
|
actionBlock:^{
|
2018-10-31 00:06:25 +01:00
|
|
|
NSURL *url = [NSURL URLWithString:kSealedSenderInfoURL];
|
2018-10-22 20:28:46 +02:00
|
|
|
OWSAssertDebug(url);
|
|
|
|
[UIApplication.sharedApplication openURL:url];
|
|
|
|
}]];
|
2018-10-10 20:04:40 +02:00
|
|
|
|
2018-10-11 01:17:42 +02:00
|
|
|
unidentifiedDeliveryIndicatorsSection.footerTitle
|
|
|
|
= NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_SHOW_INDICATORS_FOOTER", @"table section footer");
|
2018-10-22 16:00:40 +02:00
|
|
|
[contents addSection:unidentifiedDeliveryIndicatorsSection];
|
2018-10-11 01:17:42 +02:00
|
|
|
|
|
|
|
OWSTableSection *unidentifiedDeliveryUnrestrictedSection = [OWSTableSection new];
|
2018-10-10 20:04:40 +02:00
|
|
|
OWSTableItem *unrestrictedAccessItem = [OWSTableItem
|
|
|
|
switchItemWithText:NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS", @"switch label")
|
|
|
|
isOn:weakSelf.udManager.shouldAllowUnrestrictedAccessLocal
|
|
|
|
target:weakSelf
|
|
|
|
selector:@selector(didToggleUDUnrestrictedAccessSwitch:)];
|
2018-10-11 01:17:42 +02:00
|
|
|
[unidentifiedDeliveryUnrestrictedSection addItem:unrestrictedAccessItem];
|
2018-10-22 20:28:46 +02:00
|
|
|
unidentifiedDeliveryUnrestrictedSection.footerTitle
|
|
|
|
= NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS_FOOTER", @"table section footer");
|
2018-10-11 01:17:42 +02:00
|
|
|
[contents addSection:unidentifiedDeliveryUnrestrictedSection];
|
2018-10-10 20:04:40 +02:00
|
|
|
|
2018-10-22 16:00:40 +02:00
|
|
|
OWSTableSection *unidentifiedDeliveryLearnMoreSection = [OWSTableSection new];
|
|
|
|
[unidentifiedDeliveryLearnMoreSection
|
2018-10-22 20:28:46 +02:00
|
|
|
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_LEARN_MORE",
|
|
|
|
@"Label for a link to more info about unidentified delivery.")
|
|
|
|
actionBlock:^{
|
2018-10-31 00:06:25 +01:00
|
|
|
NSURL *url = [NSURL URLWithString:kSealedSenderInfoURL];
|
2018-10-22 20:28:46 +02:00
|
|
|
OWSAssertDebug(url);
|
|
|
|
[UIApplication.sharedApplication openURL:url];
|
|
|
|
}]];
|
2018-10-22 16:00:40 +02:00
|
|
|
[contents addSection:unidentifiedDeliveryLearnMoreSection];
|
|
|
|
|
2019-01-17 22:47:36 +01:00
|
|
|
OWSTableSection *linkPreviewsSection = [OWSTableSection new];
|
|
|
|
[linkPreviewsSection
|
|
|
|
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_LINK_PREVIEWS",
|
|
|
|
@"Setting for enabling & disabling link previews.")
|
|
|
|
isOn:SSKPreferences.areLinkPreviewsEnabled
|
|
|
|
target:weakSelf
|
|
|
|
selector:@selector(didToggleLinkPreviewsEnabled:)]];
|
2019-01-17 22:48:55 +01:00
|
|
|
linkPreviewsSection.headerTitle
|
2019-01-17 22:47:36 +01:00
|
|
|
= NSLocalizedString(@"SETTINGS_LINK_PREVIEWS", @"Setting for enabling & disabling link previews.");
|
|
|
|
[contents addSection:linkPreviewsSection];
|
|
|
|
|
2018-02-28 16:55:33 +01:00
|
|
|
self.contents = contents;
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
|
|
|
|
2017-07-14 16:55:49 +02:00
|
|
|
#pragma mark - Events
|
|
|
|
|
|
|
|
- (void)showBlocklist
|
2016-11-08 19:08:04 +01:00
|
|
|
{
|
2017-07-14 16:55:49 +02:00
|
|
|
BlockListViewController *vc = [BlockListViewController new];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
|
|
|
|
2017-07-14 16:55:49 +02:00
|
|
|
- (void)clearHistoryLogs
|
|
|
|
{
|
|
|
|
UIAlertController *alertController =
|
|
|
|
[UIAlertController alertControllerWithTitle:nil
|
|
|
|
message:NSLocalizedString(@"SETTINGS_DELETE_HISTORYLOG_CONFIRMATION",
|
|
|
|
@"Alert message before user confirms clearing history")
|
|
|
|
preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
2017-08-21 22:58:26 +02:00
|
|
|
[alertController addAction:[OWSAlerts cancelAction]];
|
2017-07-14 16:55:49 +02:00
|
|
|
|
2018-02-28 16:56:56 +01:00
|
|
|
UIAlertAction *deleteAction = [UIAlertAction
|
|
|
|
actionWithTitle:NSLocalizedString(@"SETTINGS_DELETE_HISTORYLOG_CONFIRMATION_BUTTON",
|
|
|
|
@"Confirmation text for button which deletes all message, calling, attachments, etc.")
|
|
|
|
style:UIAlertActionStyleDestructive
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
[self deleteThreadsAndMessages];
|
|
|
|
}];
|
2017-07-14 16:55:49 +02:00
|
|
|
[alertController addAction:deleteAction];
|
|
|
|
|
|
|
|
[self presentViewController:alertController animated:true completion:nil];
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
|
|
|
|
2017-12-19 03:07:54 +01:00
|
|
|
- (void)deleteThreadsAndMessages
|
|
|
|
{
|
2018-03-20 18:02:10 +01:00
|
|
|
[ThreadUtil deleteAllContent];
|
2017-12-19 03:07:54 +01:00
|
|
|
}
|
|
|
|
|
2016-09-11 22:53:12 +02:00
|
|
|
- (void)didToggleScreenSecuritySwitch:(UISwitch *)sender
|
|
|
|
{
|
2017-07-14 16:55:49 +02:00
|
|
|
BOOL enabled = sender.isOn;
|
2018-08-27 18:51:32 +02:00
|
|
|
OWSLogInfo(@"toggled screen security: %@", enabled ? @"ON" : @"OFF");
|
2018-10-11 01:17:01 +02:00
|
|
|
[self.preferences setScreenSecurity:enabled];
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2017-09-14 22:25:36 +02:00
|
|
|
- (void)didToggleReadReceiptsSwitch:(UISwitch *)sender
|
|
|
|
{
|
|
|
|
BOOL enabled = sender.isOn;
|
2018-08-27 18:51:32 +02:00
|
|
|
OWSLogInfo(@"toggled areReadReceiptsEnabled: %@", enabled ? @"ON" : @"OFF");
|
2018-10-31 17:06:02 +01:00
|
|
|
[self.readReceiptManager setAreReadReceiptsEnabled:enabled];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)didToggleTypingIndicatorsSwitch:(UISwitch *)sender
|
|
|
|
{
|
|
|
|
BOOL enabled = sender.isOn;
|
|
|
|
OWSLogInfo(@"toggled areTypingIndicatorsEnabled: %@", enabled ? @"ON" : @"OFF");
|
|
|
|
[self.typingIndicators setTypingIndicatorsEnabledWithValue:enabled];
|
2017-09-14 22:25:36 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 16:06:01 +01:00
|
|
|
- (void)didToggleCallsHideIPAddressSwitch:(UISwitch *)sender
|
|
|
|
{
|
|
|
|
BOOL enabled = sender.isOn;
|
2018-08-27 18:51:32 +02:00
|
|
|
OWSLogInfo(@"toggled callsHideIPAddress: %@", enabled ? @"ON" : @"OFF");
|
2018-10-11 01:17:01 +02:00
|
|
|
[self.preferences setDoCallsHideIPAddress:enabled];
|
2017-02-22 16:06:01 +01:00
|
|
|
}
|
|
|
|
|
2018-02-23 23:08:21 +01:00
|
|
|
- (void)didToggleEnableSystemCallLogSwitch:(UISwitch *)sender
|
|
|
|
{
|
2018-08-27 18:55:37 +02:00
|
|
|
OWSLogInfo(@"user toggled call kit preference: %@", (sender.isOn ? @"ON" : @"OFF"));
|
2018-10-11 01:17:01 +02:00
|
|
|
[self.preferences setIsSystemCallLogEnabled:sender.isOn];
|
2018-02-23 23:08:21 +01:00
|
|
|
|
|
|
|
// rebuild callUIAdapter since CallKit configuration changed.
|
2018-10-15 20:58:15 +02:00
|
|
|
[AppEnvironment.shared.callService createCallUIAdapter];
|
2018-02-23 23:08:21 +01:00
|
|
|
}
|
|
|
|
|
2018-03-05 17:57:12 +01:00
|
|
|
- (void)didToggleEnableCallKitSwitch:(UISwitch *)sender
|
|
|
|
{
|
2018-08-27 18:55:37 +02:00
|
|
|
OWSLogInfo(@"user toggled call kit preference: %@", (sender.isOn ? @"ON" : @"OFF"));
|
2018-10-11 01:17:01 +02:00
|
|
|
[self.preferences setIsCallKitEnabled:sender.isOn];
|
2018-02-23 23:08:21 +01:00
|
|
|
|
2017-03-02 19:03:41 +01:00
|
|
|
// rebuild callUIAdapter since CallKit vs not changed.
|
2018-10-15 20:58:15 +02:00
|
|
|
[AppEnvironment.shared.callService createCallUIAdapter];
|
2018-02-23 23:08:21 +01:00
|
|
|
|
|
|
|
// Show/Hide dependent switch: CallKit privacy
|
2017-07-14 16:55:49 +02:00
|
|
|
[self updateTableContents];
|
2017-02-25 04:15:11 +01:00
|
|
|
}
|
|
|
|
|
2018-03-05 17:57:12 +01:00
|
|
|
- (void)didToggleEnableCallKitPrivacySwitch:(UISwitch *)sender
|
|
|
|
{
|
2018-08-27 18:55:37 +02:00
|
|
|
OWSLogInfo(@"user toggled call kit privacy preference: %@", (sender.isOn ? @"ON" : @"OFF"));
|
2018-10-11 01:17:01 +02:00
|
|
|
[self.preferences setIsCallKitPrivacyEnabled:!sender.isOn];
|
2018-02-23 23:08:21 +01:00
|
|
|
|
|
|
|
// rebuild callUIAdapter since CallKit configuration changed.
|
2018-10-15 20:58:15 +02:00
|
|
|
[AppEnvironment.shared.callService createCallUIAdapter];
|
2017-02-25 04:15:11 +01:00
|
|
|
}
|
|
|
|
|
2018-10-10 20:04:40 +02:00
|
|
|
- (void)didToggleUDUnrestrictedAccessSwitch:(UISwitch *)sender
|
|
|
|
{
|
|
|
|
OWSLogInfo(@"toggled to: %@", (sender.isOn ? @"ON" : @"OFF"));
|
|
|
|
[self.udManager setShouldAllowUnrestrictedAccessLocal:sender.isOn];
|
|
|
|
}
|
|
|
|
|
2018-10-11 01:17:42 +02:00
|
|
|
- (void)didToggleUDShowIndicatorsSwitch:(UISwitch *)sender
|
|
|
|
{
|
|
|
|
OWSLogInfo(@"toggled to: %@", (sender.isOn ? @"ON" : @"OFF"));
|
|
|
|
[self.preferences setShouldShowUnidentifiedDeliveryIndicators:sender.isOn];
|
|
|
|
}
|
|
|
|
|
2019-01-17 22:47:36 +01:00
|
|
|
- (void)didToggleLinkPreviewsEnabled:(UISwitch *)sender
|
|
|
|
{
|
|
|
|
OWSLogInfo(@"toggled to: %@", (sender.isOn ? @"ON" : @"OFF"));
|
|
|
|
[SSKPreferences setAreLinkPreviewsEnabledWithValue:sender.isOn];
|
|
|
|
}
|
|
|
|
|
2018-03-01 04:26:52 +01:00
|
|
|
- (void)show2FASettings
|
2018-02-28 15:58:54 +01:00
|
|
|
{
|
2018-08-27 18:09:39 +02:00
|
|
|
OWSLogInfo(@"");
|
2018-02-28 16:55:33 +01:00
|
|
|
|
|
|
|
OWS2FASettingsViewController *vc = [OWS2FASettingsViewController new];
|
2018-03-01 04:26:52 +01:00
|
|
|
vc.mode = OWS2FASettingsMode_Status;
|
2018-02-28 16:55:33 +01:00
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
2018-02-28 15:58:54 +01:00
|
|
|
}
|
|
|
|
|
2018-03-21 18:25:39 +01:00
|
|
|
- (void)isScreenLockEnabledDidChange:(UISwitch *)sender
|
|
|
|
{
|
|
|
|
BOOL shouldBeEnabled = sender.isOn;
|
|
|
|
|
|
|
|
if (shouldBeEnabled == OWSScreenLock.sharedManager.isScreenLockEnabled) {
|
2018-08-27 18:51:32 +02:00
|
|
|
OWSLogError(@"ignoring redundant screen lock.");
|
2018-03-21 18:25:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-27 18:55:37 +02:00
|
|
|
OWSLogInfo(@"trying to set is screen lock enabled: %@", @(shouldBeEnabled));
|
2018-03-21 18:25:39 +01:00
|
|
|
|
2018-04-12 18:23:11 +02:00
|
|
|
[OWSScreenLock.sharedManager setIsScreenLockEnabled:shouldBeEnabled];
|
2018-03-21 18:25:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)screenLockDidChange:(NSNotification *)notification
|
|
|
|
{
|
2018-08-27 18:09:39 +02:00
|
|
|
OWSLogInfo(@"");
|
2018-03-21 18:25:39 +01:00
|
|
|
|
|
|
|
[self updateTableContents];
|
|
|
|
}
|
|
|
|
|
2018-03-21 22:11:38 +01:00
|
|
|
- (void)showScreenLockTimeoutUI
|
|
|
|
{
|
2018-08-27 18:09:39 +02:00
|
|
|
OWSLogInfo(@"");
|
2018-03-21 22:11:38 +01:00
|
|
|
|
|
|
|
UIAlertController *controller = [UIAlertController
|
|
|
|
alertControllerWithTitle:NSLocalizedString(@"SETTINGS_SCREEN_LOCK_ACTIVITY_TIMEOUT",
|
|
|
|
@"Label for the 'screen lock activity timeout' setting of the privacy settings.")
|
|
|
|
message:nil
|
|
|
|
preferredStyle:UIAlertControllerStyleActionSheet];
|
|
|
|
for (NSNumber *timeoutValue in OWSScreenLock.sharedManager.screenLockTimeouts) {
|
|
|
|
uint32_t screenLockTimeout = (uint32_t)round(timeoutValue.doubleValue);
|
2018-03-22 21:21:41 +01:00
|
|
|
NSString *screenLockTimeoutString = [self formatScreenLockTimeout:screenLockTimeout useShortFormat:NO];
|
2018-03-21 22:11:38 +01:00
|
|
|
|
|
|
|
[controller addAction:[UIAlertAction actionWithTitle:screenLockTimeoutString
|
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
handler:^(UIAlertAction *action) {
|
|
|
|
[OWSScreenLock.sharedManager
|
|
|
|
setScreenLockTimeout:screenLockTimeout];
|
|
|
|
}]];
|
|
|
|
}
|
|
|
|
[controller addAction:[OWSAlerts cancelAction]];
|
|
|
|
UIViewController *fromViewController = [[UIApplication sharedApplication] frontmostViewController];
|
|
|
|
[fromViewController presentViewController:controller animated:YES completion:nil];
|
|
|
|
}
|
|
|
|
|
2018-03-22 21:21:41 +01:00
|
|
|
- (NSString *)formatScreenLockTimeout:(NSInteger)value useShortFormat:(BOOL)useShortFormat
|
2018-03-22 14:02:41 +01:00
|
|
|
{
|
|
|
|
if (value <= 1) {
|
|
|
|
return NSLocalizedString(@"SCREEN_LOCK_ACTIVITY_TIMEOUT_NONE",
|
|
|
|
@"Indicates a delay of zero seconds, and that 'screen lock activity' will timeout immediately.");
|
|
|
|
}
|
2018-03-22 21:21:41 +01:00
|
|
|
return [NSString formatDurationSeconds:(uint32_t)value useShortFormat:useShortFormat];
|
2018-03-22 14:02:41 +01:00
|
|
|
}
|
|
|
|
|
2015-01-16 15:28:41 +01:00
|
|
|
@end
|
2016-11-08 19:08:04 +01:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|