2014-10-29 21:58:58 +01:00
|
|
|
//
|
2018-01-08 21:31:51 +01:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2014-10-29 21:58:58 +01:00
|
|
|
//
|
|
|
|
|
2017-07-31 22:45:06 +02:00
|
|
|
#import "AppSettingsViewController.h"
|
2015-01-16 15:28:41 +01:00
|
|
|
#import "AboutTableViewController.h"
|
2015-12-22 12:45:09 +01:00
|
|
|
#import "AdvancedSettingsTableViewController.h"
|
2017-06-22 18:58:59 +02:00
|
|
|
#import "DebugUITableViewController.h"
|
2015-04-14 21:49:00 +02:00
|
|
|
#import "NotificationSettingsViewController.h"
|
2018-03-20 17:26:17 +01:00
|
|
|
#import "OWSBackup.h"
|
2018-03-05 17:57:12 +01:00
|
|
|
#import "OWSBackupSettingsViewController.h"
|
2017-05-10 23:27:53 +02:00
|
|
|
#import "OWSLinkedDevicesTableViewController.h"
|
2017-09-07 17:03:54 +02:00
|
|
|
#import "OWSNavigationController.h"
|
2015-12-22 12:45:09 +01:00
|
|
|
#import "PrivacySettingsTableViewController.h"
|
2017-07-31 22:45:06 +02:00
|
|
|
#import "ProfileViewController.h"
|
2015-12-22 12:45:09 +01:00
|
|
|
#import "PushManager.h"
|
2018-06-18 17:28:21 +02:00
|
|
|
#import "RegistrationUtils.h"
|
2016-11-18 23:11:56 +01:00
|
|
|
#import "Signal-Swift.h"
|
2017-12-19 03:50:51 +01:00
|
|
|
#import <SignalMessaging/Environment.h>
|
|
|
|
#import <SignalMessaging/OWSContactsManager.h>
|
2017-12-08 17:50:35 +01:00
|
|
|
#import <SignalMessaging/UIUtil.h>
|
2017-05-27 02:41:27 +02:00
|
|
|
#import <SignalServiceKit/TSAccountManager.h>
|
|
|
|
#import <SignalServiceKit/TSSocketManager.h>
|
2014-10-29 21:58:58 +01:00
|
|
|
|
2017-07-31 22:45:06 +02:00
|
|
|
@interface AppSettingsViewController ()
|
2014-10-29 21:58:58 +01:00
|
|
|
|
2016-11-23 17:07:38 +01:00
|
|
|
@property (nonatomic, readonly) OWSContactsManager *contactsManager;
|
|
|
|
|
2014-10-29 21:58:58 +01:00
|
|
|
@end
|
|
|
|
|
2017-05-10 22:40:35 +02:00
|
|
|
#pragma mark -
|
|
|
|
|
2017-07-31 22:45:06 +02:00
|
|
|
@implementation AppSettingsViewController
|
2014-10-29 21:58:58 +01:00
|
|
|
|
2017-09-07 17:03:54 +02:00
|
|
|
/**
|
|
|
|
* We always present the settings controller modally, from within an OWSNavigationController
|
|
|
|
*/
|
|
|
|
+ (OWSNavigationController *)inModalNavigationController
|
|
|
|
{
|
|
|
|
AppSettingsViewController *viewController = [AppSettingsViewController new];
|
|
|
|
OWSNavigationController *navController =
|
|
|
|
[[OWSNavigationController alloc] initWithRootViewController:viewController];
|
|
|
|
|
|
|
|
return navController;
|
|
|
|
}
|
|
|
|
|
2016-11-23 17:07:38 +01:00
|
|
|
- (instancetype)init
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (!self) {
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2018-08-31 19:16:31 +02:00
|
|
|
_contactsManager = Environment.shared.contactsManager;
|
2016-11-23 17:07:38 +01:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype)initWithCoder:(NSCoder *)aDecoder
|
|
|
|
{
|
|
|
|
self = [super initWithCoder:aDecoder];
|
|
|
|
if (!self) {
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2018-08-31 19:16:31 +02:00
|
|
|
_contactsManager = Environment.shared.contactsManager;
|
2016-11-23 17:07:38 +01:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2017-05-10 23:27:53 +02:00
|
|
|
- (void)loadView
|
|
|
|
{
|
|
|
|
self.tableViewStyle = UITableViewStylePlain;
|
|
|
|
[super loadView];
|
|
|
|
}
|
|
|
|
|
2016-08-22 23:41:11 +02:00
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
2014-10-29 21:58:58 +01:00
|
|
|
[super viewDidLoad];
|
2015-09-01 19:22:08 +02:00
|
|
|
[self.navigationItem setHidesBackButton:YES];
|
|
|
|
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug([self.navigationController isKindOfClass:[OWSNavigationController class]]);
|
2017-09-07 17:03:54 +02:00
|
|
|
|
2017-05-23 16:25:47 +02:00
|
|
|
self.navigationItem.leftBarButtonItem =
|
|
|
|
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
|
|
|
|
target:self
|
|
|
|
action:@selector(dismissWasPressed:)];
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2017-05-11 15:30:19 +02:00
|
|
|
[self observeNotifications];
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2016-10-15 21:58:59 +02:00
|
|
|
self.title = NSLocalizedString(@"SETTINGS_NAV_BAR_TITLE", @"Title for settings activity");
|
2017-07-31 22:45:06 +02:00
|
|
|
|
2017-05-10 22:40:35 +02:00
|
|
|
[self updateTableContents];
|
2014-10-29 21:58:58 +01:00
|
|
|
}
|
|
|
|
|
2017-06-06 16:40:25 +02:00
|
|
|
- (void)viewWillAppear:(BOOL)animated
|
|
|
|
{
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
|
|
|
[self updateTableContents];
|
|
|
|
}
|
|
|
|
|
2017-07-31 22:45:06 +02:00
|
|
|
- (void)dealloc
|
|
|
|
{
|
2017-05-10 22:40:35 +02:00
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
2014-10-29 21:58:58 +01:00
|
|
|
}
|
|
|
|
|
2017-05-10 22:40:35 +02:00
|
|
|
#pragma mark - Table Contents
|
2014-10-29 21:58:58 +01:00
|
|
|
|
2017-05-10 22:40:35 +02:00
|
|
|
- (void)updateTableContents
|
|
|
|
{
|
|
|
|
OWSTableContents *contents = [OWSTableContents new];
|
2017-05-10 23:27:53 +02:00
|
|
|
|
2017-07-31 22:45:06 +02:00
|
|
|
__weak AppSettingsViewController *weakSelf = self;
|
2017-05-10 23:27:53 +02:00
|
|
|
|
2018-01-26 23:31:45 +01:00
|
|
|
#ifdef INTERNAL
|
|
|
|
OWSTableSection *internalSection = [OWSTableSection new];
|
|
|
|
[section addItem:[OWSTableItem softCenterLabelItemWithText:@"Internal Build"]];
|
|
|
|
[contents addSection:internalSection];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
OWSTableSection *section = [OWSTableSection new];
|
2017-08-14 20:51:19 +02:00
|
|
|
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
|
|
|
|
return [weakSelf profileHeaderCell];
|
2017-05-10 23:27:53 +02:00
|
|
|
}
|
2017-08-14 20:51:19 +02:00
|
|
|
customRowHeight:100.f
|
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf showProfile];
|
|
|
|
}]];
|
2017-06-06 16:40:25 +02:00
|
|
|
|
|
|
|
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 {
|
2018-07-13 00:01:43 +02:00
|
|
|
[section addItem:[OWSTableItem
|
|
|
|
itemWithCustomCellBlock:^{
|
|
|
|
UITableViewCell *cell = [OWSTableItem newCell];
|
|
|
|
cell.textLabel.text = NSLocalizedString(@"NETWORK_STATUS_HEADER", @"");
|
|
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
|
UILabel *accessoryLabel = [UILabel new];
|
|
|
|
if (TSAccountManager.sharedInstance.isDeregistered) {
|
|
|
|
accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_DEREGISTERED",
|
|
|
|
@"Error indicating that this device is no longer registered.");
|
|
|
|
accessoryLabel.textColor = [UIColor ows_redColor];
|
|
|
|
} else {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
actionBlock:nil]];
|
2017-05-10 23:27:53 +02:00
|
|
|
}
|
2017-07-31 22:45:06 +02:00
|
|
|
|
2017-05-10 23:27:53 +02:00
|
|
|
[section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_INVITE_TITLE",
|
|
|
|
@"Settings table view cell label")
|
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf showInviteFlow];
|
|
|
|
}]];
|
|
|
|
[section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_PRIVACY_TITLE",
|
|
|
|
@"Settings table view cell label")
|
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf showPrivacy];
|
|
|
|
}]];
|
|
|
|
[section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_NOTIFICATIONS", nil)
|
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf showNotifications];
|
|
|
|
}]];
|
|
|
|
[section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"LINKED_DEVICES_TITLE",
|
|
|
|
@"Menu item and navbar title for the device manager")
|
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf showLinkedDevices];
|
|
|
|
}]];
|
|
|
|
[section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_TITLE", @"")
|
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf showAdvanced];
|
|
|
|
}]];
|
2018-03-20 17:26:17 +01:00
|
|
|
// Show backup UI in debug builds OR if backup has already been enabled.
|
|
|
|
//
|
|
|
|
// NOTE: Backup format is not yet finalized and backups are not yet
|
|
|
|
// properly encrypted, so these debug backups should only be
|
|
|
|
// done on test devices and will not be usable if/when we ship
|
|
|
|
// backup to production.
|
|
|
|
//
|
|
|
|
// TODO: Always show backup when we go to production.
|
|
|
|
BOOL isBackupEnabled = [OWSBackup.sharedManager isBackupEnabled];
|
|
|
|
BOOL showBackup = isBackupEnabled;
|
2018-07-18 04:20:31 +02:00
|
|
|
SUPPRESS_DEADSTORE_WARNING(showBackup);
|
2018-03-05 17:57:12 +01:00
|
|
|
#ifdef DEBUG
|
2018-03-20 17:26:17 +01:00
|
|
|
showBackup = YES;
|
2018-03-05 17:57:12 +01:00
|
|
|
#endif
|
2018-03-20 17:26:17 +01:00
|
|
|
if (showBackup) {
|
|
|
|
[section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_BACKUP",
|
|
|
|
@"Label for the backup view in app settings.")
|
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf showBackup];
|
|
|
|
}]];
|
|
|
|
}
|
2017-05-10 23:27:53 +02:00
|
|
|
[section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_ABOUT", @"")
|
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf showAbout];
|
|
|
|
}]];
|
|
|
|
|
2017-09-01 20:30:39 +02:00
|
|
|
#ifdef USE_DEBUG_UI
|
2017-06-22 18:58:59 +02:00
|
|
|
[section addItem:[OWSTableItem disclosureItemWithText:@"Debug UI"
|
2017-06-15 19:43:18 +02:00
|
|
|
actionBlock:^{
|
2017-06-22 18:58:59 +02:00
|
|
|
[weakSelf showDebugUI];
|
2017-06-15 19:43:18 +02:00
|
|
|
}]];
|
|
|
|
#endif
|
|
|
|
|
2018-06-21 22:09:59 +02:00
|
|
|
if (TSAccountManager.sharedInstance.isDeregistered) {
|
|
|
|
[section addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_REREGISTER_BUTTON",
|
|
|
|
@"Label for re-registration button.")
|
|
|
|
selector:@selector(reregisterUser)
|
|
|
|
color:[UIColor ows_materialBlueColor]]];
|
|
|
|
[section addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_DELETE_DATA_BUTTON",
|
|
|
|
@"Label for 'delete data' button.")
|
|
|
|
selector:@selector(deleteUnregisterUserData)
|
|
|
|
color:[UIColor ows_destructiveRedColor]]];
|
|
|
|
} else {
|
|
|
|
[section addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_DELETE_ACCOUNT_BUTTON", @"")
|
|
|
|
selector:@selector(unregisterUser)
|
|
|
|
color:[UIColor ows_destructiveRedColor]]];
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
2017-05-10 23:27:53 +02:00
|
|
|
|
2017-05-10 22:40:35 +02:00
|
|
|
[contents addSection:section];
|
2017-07-31 22:45:06 +02:00
|
|
|
|
2017-05-10 22:40:35 +02:00
|
|
|
self.contents = contents;
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
|
|
|
|
2018-06-21 22:09:59 +02:00
|
|
|
- (OWSTableItem *)destructiveButtonItemWithTitle:(NSString *)title selector:(SEL)selector color:(UIColor *)color
|
|
|
|
{
|
|
|
|
return [OWSTableItem
|
|
|
|
itemWithCustomCellBlock:^{
|
2018-07-13 00:01:43 +02:00
|
|
|
UITableViewCell *cell = [OWSTableItem newCell];
|
2018-06-21 22:09:59 +02:00
|
|
|
cell.preservesSuperviewLayoutMargins = YES;
|
|
|
|
cell.contentView.preservesSuperviewLayoutMargins = YES;
|
|
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
|
|
|
|
|
const CGFloat kButtonHeight = 40.f;
|
|
|
|
OWSFlatButton *button = [OWSFlatButton buttonWithTitle:title
|
|
|
|
font:[OWSFlatButton fontForHeight:kButtonHeight]
|
|
|
|
titleColor:[UIColor whiteColor]
|
|
|
|
backgroundColor:color
|
|
|
|
target:self
|
|
|
|
selector:selector];
|
|
|
|
[cell.contentView addSubview:button];
|
|
|
|
[button autoSetDimension:ALDimensionHeight toSize:kButtonHeight];
|
|
|
|
[button autoVCenterInSuperview];
|
|
|
|
[button autoPinLeadingAndTrailingToSuperviewMargin];
|
|
|
|
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
customRowHeight:90.f
|
|
|
|
actionBlock:nil];
|
|
|
|
}
|
|
|
|
|
2017-08-14 20:51:19 +02:00
|
|
|
- (UITableViewCell *)profileHeaderCell
|
|
|
|
{
|
2018-07-13 00:01:43 +02:00
|
|
|
UITableViewCell *cell = [OWSTableItem newCell];
|
2017-08-14 20:51:19 +02:00
|
|
|
cell.preservesSuperviewLayoutMargins = YES;
|
|
|
|
cell.contentView.preservesSuperviewLayoutMargins = YES;
|
2017-08-14 22:18:54 +02:00
|
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
2017-08-14 20:51:19 +02:00
|
|
|
|
2017-08-14 22:18:54 +02:00
|
|
|
UIImage *_Nullable localProfileAvatarImage = [OWSProfileManager.sharedManager localProfileAvatarImage];
|
|
|
|
UIImage *avatarImage = (localProfileAvatarImage
|
2018-09-27 16:42:27 +02:00
|
|
|
?: [[[OWSContactAvatarBuilder alloc] initForLocalUserWithDiameter:kLargeAvatarSize] buildDefaultImage]);
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(avatarImage);
|
2017-08-14 20:51:19 +02:00
|
|
|
|
|
|
|
AvatarImageView *avatarView = [[AvatarImageView alloc] initWithImage:avatarImage];
|
|
|
|
[cell.contentView addSubview:avatarView];
|
|
|
|
[avatarView autoVCenterInSuperview];
|
2018-04-02 21:31:32 +02:00
|
|
|
[avatarView autoPinLeadingToSuperviewMargin];
|
2018-09-26 18:02:17 +02:00
|
|
|
[avatarView autoSetDimension:ALDimensionWidth toSize:kLargeAvatarSize];
|
|
|
|
[avatarView autoSetDimension:ALDimensionHeight toSize:kLargeAvatarSize];
|
2017-08-14 20:51:19 +02:00
|
|
|
|
2017-08-14 22:18:54 +02:00
|
|
|
if (!localProfileAvatarImage) {
|
|
|
|
UIImage *cameraImage = [UIImage imageNamed:@"settings-avatar-camera"];
|
|
|
|
UIImageView *cameraImageView = [[UIImageView alloc] initWithImage:cameraImage];
|
|
|
|
[cell.contentView addSubview:cameraImageView];
|
2018-04-02 21:31:32 +02:00
|
|
|
[cameraImageView autoPinTrailingToEdgeOfView:avatarView];
|
2017-08-14 22:18:54 +02:00
|
|
|
[cameraImageView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:avatarView];
|
|
|
|
}
|
|
|
|
|
2017-08-15 23:02:07 +02:00
|
|
|
UIView *nameView = [UIView containerView];
|
|
|
|
[cell.contentView addSubview:nameView];
|
|
|
|
[nameView autoVCenterInSuperview];
|
2018-04-02 21:31:32 +02:00
|
|
|
[nameView autoPinLeadingToTrailingEdgeOfView:avatarView offset:16.f];
|
2017-08-14 20:51:19 +02:00
|
|
|
|
2017-08-15 23:02:07 +02:00
|
|
|
UILabel *titleLabel = [UILabel new];
|
2017-08-14 22:18:54 +02:00
|
|
|
NSString *_Nullable localProfileName = [OWSProfileManager.sharedManager localProfileName];
|
|
|
|
if (localProfileName.length > 0) {
|
2017-08-15 23:02:07 +02:00
|
|
|
titleLabel.text = localProfileName;
|
2018-07-13 15:50:49 +02:00
|
|
|
titleLabel.textColor = [Theme primaryColor];
|
2017-08-15 23:02:07 +02:00
|
|
|
titleLabel.font = [UIFont ows_dynamicTypeTitle2Font];
|
2017-08-14 22:18:54 +02:00
|
|
|
} else {
|
2017-08-15 23:02:07 +02:00
|
|
|
titleLabel.text = NSLocalizedString(
|
2017-08-14 22:18:54 +02:00
|
|
|
@"APP_SETTINGS_EDIT_PROFILE_NAME_PROMPT", @"Text prompting user to edit their profile name.");
|
2017-08-15 23:02:07 +02:00
|
|
|
titleLabel.textColor = [UIColor ows_materialBlueColor];
|
|
|
|
titleLabel.font = [UIFont ows_dynamicTypeHeadlineFont];
|
2017-08-14 22:18:54 +02:00
|
|
|
}
|
2017-08-15 23:02:07 +02:00
|
|
|
titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
|
|
|
[nameView addSubview:titleLabel];
|
|
|
|
[titleLabel autoPinEdgeToSuperviewEdge:ALEdgeTop];
|
|
|
|
[titleLabel autoPinWidthToSuperview];
|
2017-08-14 20:51:19 +02:00
|
|
|
|
|
|
|
const CGFloat kSubtitlePointSize = 12.f;
|
2017-08-15 23:02:07 +02:00
|
|
|
UILabel *subtitleLabel = [UILabel new];
|
2018-07-13 15:50:49 +02:00
|
|
|
subtitleLabel.textColor = [Theme secondaryColor];
|
2017-08-15 23:02:07 +02:00
|
|
|
subtitleLabel.font = [UIFont ows_regularFontWithSize:kSubtitlePointSize];
|
|
|
|
subtitleLabel.attributedText = [[NSAttributedString alloc]
|
2017-08-14 20:51:19 +02:00
|
|
|
initWithString:[PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:[TSAccountManager
|
|
|
|
localNumber]]];
|
2017-08-15 23:02:07 +02:00
|
|
|
subtitleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
|
|
|
[nameView addSubview:subtitleLabel];
|
|
|
|
[subtitleLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:titleLabel];
|
2018-04-02 21:31:32 +02:00
|
|
|
[subtitleLabel autoPinLeadingToSuperviewMargin];
|
2017-08-15 23:02:07 +02:00
|
|
|
[subtitleLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom];
|
|
|
|
|
2018-06-29 23:00:22 +02:00
|
|
|
UIImage *disclosureImage = [UIImage imageNamed:(CurrentAppContext().isRTL ? @"NavBarBack" : @"NavBarBackRTL")];
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(disclosureImage);
|
2017-08-15 23:02:07 +02:00
|
|
|
UIImageView *disclosureButton =
|
|
|
|
[[UIImageView alloc] initWithImage:[disclosureImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
|
|
|
|
disclosureButton.tintColor = [UIColor colorWithRGBHex:0xcccccc];
|
|
|
|
[cell.contentView addSubview:disclosureButton];
|
|
|
|
[disclosureButton autoVCenterInSuperview];
|
2018-04-02 21:31:32 +02:00
|
|
|
[disclosureButton autoPinTrailingToSuperviewMargin];
|
|
|
|
[disclosureButton autoPinLeadingToTrailingEdgeOfView:nameView offset:16.f];
|
2018-03-05 17:57:12 +01:00
|
|
|
[disclosureButton setContentCompressionResistancePriority:(UILayoutPriorityDefaultHigh + 1)
|
|
|
|
forAxis:UILayoutConstraintAxisHorizontal];
|
2017-08-14 20:51:19 +02:00
|
|
|
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
|
2017-05-10 23:27:53 +02:00
|
|
|
- (void)showInviteFlow
|
|
|
|
{
|
|
|
|
OWSInviteFlow *inviteFlow =
|
|
|
|
[[OWSInviteFlow alloc] initWithPresentingViewController:self contactsManager:self.contactsManager];
|
|
|
|
[self presentViewController:inviteFlow.actionSheetController animated:YES completion:nil];
|
|
|
|
}
|
2015-01-14 22:30:01 +01:00
|
|
|
|
2017-05-10 23:27:53 +02:00
|
|
|
- (void)showPrivacy
|
|
|
|
{
|
|
|
|
PrivacySettingsTableViewController *vc = [[PrivacySettingsTableViewController alloc] init];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
2015-12-30 13:48:25 +01:00
|
|
|
|
2017-05-10 23:27:53 +02:00
|
|
|
- (void)showNotifications
|
|
|
|
{
|
|
|
|
NotificationSettingsViewController *vc = [[NotificationSettingsViewController alloc] init];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
2015-12-30 13:48:25 +01:00
|
|
|
|
2017-05-10 23:27:53 +02:00
|
|
|
- (void)showLinkedDevices
|
|
|
|
{
|
|
|
|
OWSLinkedDevicesTableViewController *vc =
|
|
|
|
[[UIStoryboard main] instantiateViewControllerWithIdentifier:@"OWSLinkedDevicesTableViewController"];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
|
2017-07-31 22:45:06 +02:00
|
|
|
- (void)showProfile
|
|
|
|
{
|
2017-08-16 16:25:36 +02:00
|
|
|
[ProfileViewController presentForAppSettings:self.navigationController];
|
2017-07-31 22:45:06 +02:00
|
|
|
}
|
|
|
|
|
2017-05-10 23:27:53 +02:00
|
|
|
- (void)showAdvanced
|
|
|
|
{
|
|
|
|
AdvancedSettingsTableViewController *vc = [[AdvancedSettingsTableViewController alloc] init];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)showAbout
|
|
|
|
{
|
|
|
|
AboutTableViewController *vc = [[AboutTableViewController alloc] init];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
|
2018-03-05 17:57:12 +01:00
|
|
|
- (void)showBackup
|
|
|
|
{
|
|
|
|
OWSBackupSettingsViewController *vc = [OWSBackupSettingsViewController new];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
|
2017-06-22 18:58:59 +02:00
|
|
|
- (void)showDebugUI
|
2017-06-15 19:43:18 +02:00
|
|
|
{
|
2017-06-22 18:58:59 +02:00
|
|
|
[DebugUITableViewController presentDebugUIFromViewController:self];
|
2017-06-15 19:43:18 +02:00
|
|
|
}
|
|
|
|
|
2017-05-23 16:25:47 +02:00
|
|
|
- (void)dismissWasPressed:(id)sender
|
|
|
|
{
|
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
}
|
|
|
|
|
2018-06-18 17:28:21 +02:00
|
|
|
#pragma mark - Unregister & Re-register
|
2017-05-10 23:27:53 +02:00
|
|
|
|
|
|
|
- (void)unregisterUser
|
2018-06-21 22:09:59 +02:00
|
|
|
{
|
|
|
|
[self showDeleteAccountUI:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)deleteUnregisterUserData
|
|
|
|
{
|
|
|
|
[self showDeleteAccountUI:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)showDeleteAccountUI:(BOOL)isRegistered
|
2017-05-10 23:27:53 +02:00
|
|
|
{
|
2015-12-22 12:45:09 +01:00
|
|
|
UIAlertController *alertController =
|
|
|
|
[UIAlertController alertControllerWithTitle:NSLocalizedString(@"CONFIRM_ACCOUNT_DESTRUCTION_TITLE", @"")
|
|
|
|
message:NSLocalizedString(@"CONFIRM_ACCOUNT_DESTRUCTION_TEXT", @"")
|
|
|
|
preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"PROCEED_BUTTON", @"")
|
|
|
|
style:UIAlertActionStyleDestructive
|
|
|
|
handler:^(UIAlertAction *action) {
|
2018-06-21 22:09:59 +02:00
|
|
|
[self deleteAccount:isRegistered];
|
2015-12-22 12:45:09 +01:00
|
|
|
}]];
|
2017-08-21 22:58:26 +02:00
|
|
|
[alertController addAction:[OWSAlerts cancelAction]];
|
2015-02-16 19:48:31 +01:00
|
|
|
|
|
|
|
[self presentViewController:alertController animated:YES completion:nil];
|
|
|
|
}
|
|
|
|
|
2018-06-21 22:09:59 +02:00
|
|
|
- (void)deleteAccount:(BOOL)isRegistered
|
2017-07-31 22:45:06 +02:00
|
|
|
{
|
2018-06-21 22:09:59 +02:00
|
|
|
if (isRegistered) {
|
|
|
|
[ModalActivityIndicatorViewController
|
|
|
|
presentFromViewController:self
|
|
|
|
canCancel:NO
|
|
|
|
backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
|
|
|
|
[TSAccountManager
|
|
|
|
unregisterTextSecureWithSuccess:^{
|
|
|
|
[SignalApp resetAppData];
|
|
|
|
}
|
|
|
|
failure:^(NSError *error) {
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[modalActivityIndicator dismissWithCompletion:^{
|
|
|
|
[OWSAlerts
|
|
|
|
showAlertWithTitle:NSLocalizedString(@"UNREGISTER_SIGNAL_FAIL", @"")];
|
|
|
|
}];
|
|
|
|
});
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
} else {
|
|
|
|
[SignalApp resetAppData];
|
|
|
|
}
|
2015-01-14 22:30:01 +01:00
|
|
|
}
|
|
|
|
|
2018-06-18 17:28:21 +02:00
|
|
|
- (void)reregisterUser
|
|
|
|
{
|
|
|
|
[RegistrationUtils showReregistrationUIFromViewController:self];
|
|
|
|
}
|
|
|
|
|
2015-01-16 15:28:41 +01:00
|
|
|
#pragma mark - Socket Status Notifications
|
|
|
|
|
2017-05-11 15:30:19 +02:00
|
|
|
- (void)observeNotifications
|
|
|
|
{
|
2015-12-22 12:45:09 +01:00
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
2017-05-10 22:40:35 +02:00
|
|
|
selector:@selector(socketStateDidChange)
|
|
|
|
name:kNSNotification_SocketManagerStateDidChange
|
2015-12-22 12:45:09 +01:00
|
|
|
object:nil];
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
|
|
|
|
2017-07-31 22:45:06 +02:00
|
|
|
- (void)socketStateDidChange
|
|
|
|
{
|
2017-12-19 17:38:25 +01:00
|
|
|
OWSAssertIsOnMainThread();
|
2017-07-31 22:45:06 +02:00
|
|
|
|
2017-05-10 22:40:35 +02:00
|
|
|
[self updateTableContents];
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
|
|
|
|
2014-10-29 21:58:58 +01:00
|
|
|
@end
|