session-ios/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m

599 lines
26 KiB
Mathematica
Raw Normal View History

2014-10-29 21:58:58 +01:00
//
2019-01-09 17:31:17 +01:00
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
2014-10-29 21:58:58 +01:00
//
2019-08-29 07:21:45 +02:00
#import "AppDelegate.h"
#import "AppSettingsViewController.h"
#import "AboutTableViewController.h"
#import "AdvancedSettingsTableViewController.h"
#import "DebugUITableViewController.h"
#import "NotificationSettingsViewController.h"
#import "OWSBackup.h"
#import "OWSBackupSettingsViewController.h"
#import "OWSLinkedDevicesTableViewController.h"
#import "OWSNavigationController.h"
#import "PrivacySettingsTableViewController.h"
#import "ProfileViewController.h"
2018-06-18 17:28:21 +02:00
#import "RegistrationUtils.h"
2019-05-02 23:58:48 +02:00
#import "Session-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>
#import <SignalServiceKit/TSAccountManager.h>
#import <SignalServiceKit/TSSocketManager.h>
2014-10-29 21:58:58 +01:00
@interface AppSettingsViewController ()
2014-10-29 21:58:58 +01:00
@property (nonatomic, readonly) OWSContactsManager *contactsManager;
2014-10-29 21:58:58 +01:00
@end
#pragma mark -
@implementation AppSettingsViewController
2014-10-29 21:58:58 +01: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;
}
- (instancetype)init
{
self = [super init];
if (!self) {
return self;
}
_contactsManager = Environment.shared.contactsManager;
return self;
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (!self) {
return self;
}
_contactsManager = Environment.shared.contactsManager;
return self;
}
- (void)loadView
{
self.tableViewStyle = UITableViewStylePlain;
[super loadView];
}
- (void)viewDidLoad
{
2014-10-29 21:58:58 +01:00
[super viewDidLoad];
iOS 9 Support - Fixing size classes rendering bugs. - Supporting native iOS San Francisco font. - Quick Reply - Settings now slide to the left as suggested in original designed opposed to modal. - Simplification of restraints on many screens. - Full-API compatiblity with iOS 9 and iOS 8 legacy support. - Customized AddressBook Permission prompt when restrictions are enabled. If user installed Signal previously and already approved access to Contacts, don't bugg him again. - Fixes crash in migration for users who installed Signal <2.1.3 but hadn't signed up yet. - Xcode 7 / iOS 9 Travis Support - Bitcode Support is disabled until it is better understood how exactly optimizations are performed. In a first time, we will split out the crypto code into a separate binary to make it easier to optimize the non-sensitive code. Blog post with more details coming. - Partial ATS support. We are running our own Certificate Authority at Open Whisper Systems. Signal is doing certificate pinning to verify that certificates were signed by our own CA. Unfortunately Apple's App Transport Security requires to hand over chain verification to their framework with no control over the trust store. We have filed a radar to get ATS features with pinned certificates. In the meanwhile, ATS is disabled on our domain. We also followed Amazon's recommendations for our S3 domain we use to upload/download attachments. (#891) - Implement a unified `AFSecurityOWSPolicy` pinning strategy accross libraries (AFNetworking RedPhone/TextSecure & SocketRocket).
2015-09-01 19:22:08 +02:00
[self.navigationItem setHidesBackButton:YES];
OWSAssertDebug([self.navigationController isKindOfClass:[OWSNavigationController class]]);
2017-05-23 16:25:47 +02:00
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
target:self
action:@selector(dismissWasPressed:)];
2019-06-14 07:25:39 +02:00
// [self updateRightBarButtonForTheme];
[self observeNotifications];
self.title = NSLocalizedString(@"SETTINGS_NAV_BAR_TITLE", @"Title for settings activity");
[self updateTableContents];
2014-10-29 21:58:58 +01:00
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self updateTableContents];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
2014-10-29 21:58:58 +01:00
}
#pragma mark - Table Contents
2014-10-29 21:58:58 +01:00
- (void)updateTableContents
{
OWSTableContents *contents = [OWSTableContents new];
__weak AppSettingsViewController *weakSelf = self;
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];
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
return [weakSelf profileHeaderCell];
}
customRowHeight:100.f
actionBlock:^{
[weakSelf showProfile];
}]];
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 {
// Loki: Original code
// ========
// [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.shared.highestSocketState) {
// case OWSWebSocketStateClosed:
// accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_OFFLINE", @"");
// accessoryLabel.textColor = [UIColor ows_redColor];
// break;
// case OWSWebSocketStateConnecting:
// accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTING", @"");
// accessoryLabel.textColor = [UIColor ows_yellowColor];
// break;
// case OWSWebSocketStateOpen:
// accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTED", @"");
// accessoryLabel.textColor = [UIColor ows_greenColor];
// break;
// }
// }
// [accessoryLabel sizeToFit];
// cell.accessoryView = accessoryLabel;
// cell.accessibilityIdentifier
// = ACCESSIBILITY_IDENTIFIER_WITH_NAME(AppSettingsViewController, @"network_status");
// return cell;
// }
// actionBlock:nil]];
// ========
}
2019-06-14 07:25:39 +02:00
// Loki: Original code
// ========
// [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_INVITE_TITLE",
// @"Settings table view cell label")
// accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"invite")
// actionBlock:^{
// [weakSelf showInviteFlow];
// }]];
// ========
[section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_PRIVACY_TITLE",
@"Settings table view cell label")
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"privacy")
actionBlock:^{
[weakSelf showPrivacy];
}]];
[section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_NOTIFICATIONS", nil)
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"notifications")
actionBlock:^{
[weakSelf showNotifications];
}]];
2019-06-14 07:25:39 +02:00
// Loki: Original code
// ========
// [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"LINKED_DEVICES_TITLE",
// @"Menu item and navbar title for the device manager")
// accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"linked_devices")
// actionBlock:^{
// [weakSelf showLinkedDevices];
// }]];
// [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_TITLE", @"")
// accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"advanced")
// actionBlock:^{
// [weakSelf showAdvanced];
// }]];
// ========
BOOL isBackupEnabled = [OWSBackup.sharedManager isBackupEnabled];
2018-12-03 14:46:58 +01:00
BOOL showBackup = (OWSBackup.isFeatureEnabled && isBackupEnabled);
if (showBackup) {
[section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_BACKUP",
@"Label for the backup view in app settings.")
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"backup")
actionBlock:^{
[weakSelf showBackup];
}]];
}
2019-06-14 07:25:39 +02:00
// Loki: Original code
// ========
// [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_ABOUT", @"")
// accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"about")
// actionBlock:^{
// [weakSelf showAbout];
// }]];
// ========
2017-09-01 20:30:39 +02:00
#ifdef USE_DEBUG_UI
2019-06-14 07:25:39 +02:00
// Loki: Original code
// ========
// [section addItem:[OWSTableItem disclosureItemWithText:@"Debug UI"
// accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"debugui")
// actionBlock:^{
// [weakSelf showDebugUI];
// }]];
// ========
#endif
2019-08-21 02:41:55 +02:00
[section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Share Public Key", @"") actionBlock:^{ [weakSelf sharePublicKey]; }]];
2019-08-23 05:59:22 +02:00
[section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Show QR Code", @"") actionBlock:^{ [weakSelf showQRCode]; }]];
[section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Link Device", @"") actionBlock:^{ [weakSelf linkDevice]; }]];
2019-08-21 02:41:55 +02:00
[section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Show Seed", @"") actionBlock:^{ [weakSelf showSeed]; }]];
[section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Clear All Data", @"") actionBlock:^{ [weakSelf clearAllData]; }]];
2019-05-28 01:57:54 +02:00
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.")
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"reregister")
2018-06-21 22:09:59 +02:00
selector:@selector(reregisterUser)
color:[UIColor ows_materialBlueColor]]];
[section addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_DELETE_DATA_BUTTON",
@"Label for 'delete data' button.")
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"delete_data")
2018-06-21 22:09:59 +02:00
selector:@selector(deleteUnregisterUserData)
color:[UIColor ows_destructiveRedColor]]];
} else {
2019-05-28 01:57:54 +02:00
// Loki: Original code
// ========
// [section
// addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_DELETE_ACCOUNT_BUTTON", @"")
// accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"delete_account")
// selector:@selector(unregisterUser)
// color:[UIColor ows_destructiveRedColor]]];
// ========
}
[contents addSection:section];
self.contents = contents;
}
- (OWSTableItem *)destructiveButtonItemWithTitle:(NSString *)title
accessibilityIdentifier:(NSString *)accessibilityIdentifier
selector:(SEL)selector
color:(UIColor *)color
2018-06-21 22:09:59 +02:00
{
2018-11-21 23:21:10 +01:00
__weak AppSettingsViewController *weakSelf = self;
return [OWSTableItem
2018-06-21 22:09:59 +02:00
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
2018-11-21 23:21:10 +01:00
target:weakSelf
2018-06-21 22:09:59 +02:00
selector:selector];
[cell.contentView addSubview:button];
[button autoSetDimension:ALDimensionHeight toSize:kButtonHeight];
[button autoVCenterInSuperview];
[button autoPinLeadingAndTrailingToSuperviewMargin];
button.accessibilityIdentifier = accessibilityIdentifier;
2018-06-21 22:09:59 +02:00
return cell;
}
customRowHeight:90.f
actionBlock:nil];
}
- (UITableViewCell *)profileHeaderCell
{
2018-07-13 00:01:43 +02:00
UITableViewCell *cell = [OWSTableItem newCell];
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIImage *_Nullable localProfileAvatarImage = [OWSProfileManager.sharedManager localProfileAvatarImage];
UIImage *avatarImage = (localProfileAvatarImage
?: [[[OWSContactAvatarBuilder alloc] initForLocalUserWithDiameter:kLargeAvatarSize] buildDefaultImage]);
OWSAssertDebug(avatarImage);
AvatarImageView *avatarView = [[AvatarImageView alloc] initWithImage:avatarImage];
[cell.contentView addSubview:avatarView];
[avatarView autoVCenterInSuperview];
[avatarView autoPinLeadingToSuperviewMargin];
[avatarView autoSetDimension:ALDimensionWidth toSize:kLargeAvatarSize];
[avatarView autoSetDimension:ALDimensionHeight toSize:kLargeAvatarSize];
2019-05-27 08:30:28 +02:00
avatarView.contactID = OWSIdentityManager.sharedManager.identityKeyPair.hexEncodedPublicKey;
2019-06-17 02:08:14 +02:00
/**
if (!localProfileAvatarImage) {
UIImage *cameraImage = [UIImage imageNamed:@"settings-avatar-camera"];
UIImageView *cameraImageView = [[UIImageView alloc] initWithImage:cameraImage];
[cell.contentView addSubview:cameraImageView];
[cameraImageView autoPinTrailingToEdgeOfView:avatarView];
[cameraImageView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:avatarView];
}
2019-06-17 02:08:14 +02:00
*/
2017-08-15 23:02:07 +02:00
UIView *nameView = [UIView containerView];
[cell.contentView addSubview:nameView];
[nameView autoVCenterInSuperview];
[nameView autoPinLeadingToTrailingEdgeOfView:avatarView offset:16.f];
2017-08-15 23:02:07 +02:00
UILabel *titleLabel = [UILabel new];
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];
} else {
2017-08-15 23:02:07 +02:00
titleLabel.text = NSLocalizedString(
@"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-15 23:02:07 +02:00
titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[nameView addSubview:titleLabel];
[titleLabel autoPinEdgeToSuperviewEdge:ALEdgeTop];
[titleLabel autoPinWidthToSuperview];
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]
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];
[subtitleLabel autoPinLeadingToSuperviewMargin];
2017-08-15 23:02:07 +02:00
[subtitleLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom];
2019-04-29 04:04:35 +02:00
[subtitleLabel autoPinWidthToSuperview];
2017-08-15 23:02:07 +02:00
2018-06-29 23:00:22 +02:00
UIImage *disclosureImage = [UIImage imageNamed:(CurrentAppContext().isRTL ? @"NavBarBack" : @"NavBarBackRTL")];
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];
[disclosureButton autoPinTrailingToSuperviewMargin];
[disclosureButton autoPinLeadingToTrailingEdgeOfView:nameView offset:16.f];
[disclosureButton setContentCompressionResistancePriority:(UILayoutPriorityDefaultHigh + 1)
forAxis:UILayoutConstraintAxisHorizontal];
cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"profile");
return cell;
}
- (void)showInviteFlow
{
OWSInviteFlow *inviteFlow = [[OWSInviteFlow alloc] initWithPresentingViewController:self];
[self presentViewController:inviteFlow.actionSheetController animated:YES completion:nil];
}
- (void)showPrivacy
{
PrivacySettingsTableViewController *vc = [[PrivacySettingsTableViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
- (void)showNotifications
{
NotificationSettingsViewController *vc = [[NotificationSettingsViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
- (void)showLinkedDevices
{
2019-01-09 17:31:17 +01:00
OWSLinkedDevicesTableViewController *vc = [OWSLinkedDevicesTableViewController new];
[self.navigationController pushViewController:vc animated:YES];
}
- (void)showProfile
{
[ProfileViewController presentForAppSettings:self.navigationController];
}
- (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];
}
- (void)showBackup
{
OWSBackupSettingsViewController *vc = [OWSBackupSettingsViewController new];
[self.navigationController pushViewController:vc animated:YES];
}
- (void)showDebugUI
{
[DebugUITableViewController presentDebugUIFromViewController:self];
}
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
- (void)unregisterUser
2018-06-21 22:09:59 +02:00
{
[self showDeleteAccountUI:YES];
}
- (void)deleteUnregisterUserData
{
[self showDeleteAccountUI:NO];
}
- (void)showDeleteAccountUI:(BOOL)isRegistered
{
2018-11-21 23:21:10 +01:00
__weak AppSettingsViewController *weakSelf = self;
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:NSLocalizedString(@"CONFIRM_ACCOUNT_DESTRUCTION_TITLE", @"")
message:NSLocalizedString(@"CONFIRM_ACCOUNT_DESTRUCTION_TEXT", @"")
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"PROCEED_BUTTON", @"")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) {
[weakSelf deleteAccount:isRegistered];
}]];
[alert addAction:[OWSAlerts cancelAction]];
[self presentAlert:alert];
}
2018-06-21 22:09:59 +02:00
- (void)deleteAccount:(BOOL)isRegistered
{
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];
}
}
2019-05-13 04:00:13 +02:00
- (void)sharePublicKey
{
NSString *publicKey = OWSIdentityManager.sharedManager.identityKeyPair.hexEncodedPublicKey;
UIActivityViewController *shareVC = [[UIActivityViewController alloc] initWithActivityItems:@[ publicKey ] applicationActivities:nil];
[self presentViewController:shareVC animated:YES completion:nil];
}
2019-08-23 05:59:22 +02:00
- (void)showQRCode
{
2019-09-24 02:57:32 +02:00
LKQRCodeModal *qrCodeModal = [LKQRCodeModal new];
qrCodeModal.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:qrCodeModal animated:YES completion:nil];
2019-08-23 05:59:22 +02:00
}
- (void)linkDevice
{
2019-09-24 07:55:03 +02:00
LKDeviceLinkingModal *deviceLinkingModal = [[LKDeviceLinkingModal alloc] initWithMode:@"master" delegate:nil];
2019-09-20 07:53:24 +02:00
deviceLinkingModal.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:deviceLinkingModal animated:YES completion:nil];
}
2019-05-28 01:57:54 +02:00
- (void)showSeed
{
2019-09-24 02:57:32 +02:00
LKSeedModal *seedModal = [LKSeedModal new];
seedModal.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:seedModal animated:YES completion:nil];
2019-08-01 02:34:32 +02:00
}
- (void)clearAllData
{
2019-09-24 08:36:00 +02:00
LKNukeDataModal *nukeDataModal = [LKNukeDataModal new];
nukeDataModal.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:nukeDataModal animated:YES completion:nil];
2019-05-28 01:57:54 +02:00
}
2018-06-18 17:28:21 +02:00
- (void)reregisterUser
{
[RegistrationUtils showReregistrationUIFromViewController:self];
}
2018-10-11 21:39:47 +02:00
#pragma mark - Dark Theme
- (UIBarButtonItem *)darkThemeBarButton
{
UIBarButtonItem *barButtonItem;
if (Theme.isDarkThemeEnabled) {
barButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ic_dark_theme_on"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(didPressDisableDarkTheme:)];
} else {
barButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ic_dark_theme_off"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(didPressEnableDarkTheme:)];
}
barButtonItem.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"dark_theme");
2018-10-11 21:39:47 +02:00
return barButtonItem;
}
- (void)didPressEnableDarkTheme:(id)sender
{
[Theme setIsDarkThemeEnabled:YES];
[self updateRightBarButtonForTheme];
[self updateTableContents];
}
- (void)didPressDisableDarkTheme:(id)sender
{
[Theme setIsDarkThemeEnabled:NO];
[self updateRightBarButtonForTheme];
[self updateTableContents];
}
- (void)updateRightBarButtonForTheme
{
self.navigationItem.rightBarButtonItem = [self darkThemeBarButton];
}
#pragma mark - Socket Status Notifications
- (void)observeNotifications
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(socketStateDidChange)
2018-10-04 22:42:05 +02:00
name:kNSNotification_OWSWebSocketStateDidChange
object:nil];
}
- (void)socketStateDidChange
{
2017-12-19 17:38:25 +01:00
OWSAssertIsOnMainThread();
[self updateTableContents];
}
2014-10-29 21:58:58 +01:00
@end