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"
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"
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 >
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 : ) ] ;
2019-06-14 07:25:39 +02:00
// [ self updateRightBarButtonForTheme ] ;
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 {
2019-05-14 06:20:04 +02:00
// 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 ] ] ;
// === === = =
2017-05-10 23:27:53 +02:00
}
2017-07-31 22:45:06 +02:00
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 ] ;
// } ] ] ;
// === === = =
2017-05-10 23:27:53 +02:00
[ section addItem : [ OWSTableItem disclosureItemWithText : NSLocalizedString ( @ "SETTINGS_PRIVACY_TITLE" ,
@ "Settings table view cell label" )
2019-03-22 18:05:35 +01:00
accessibilityIdentifier : ACCESSIBILITY_IDENTIFIER _WITH _NAME ( self , @ "privacy" )
2017-05-10 23:27:53 +02:00
actionBlock : ^ {
[ weakSelf showPrivacy ] ;
} ] ] ;
[ section addItem : [ OWSTableItem disclosureItemWithText : NSLocalizedString ( @ "SETTINGS_NOTIFICATIONS" , nil )
2019-03-22 18:05:35 +01:00
accessibilityIdentifier : ACCESSIBILITY_IDENTIFIER _WITH _NAME ( self , @ "notifications" )
2017-05-10 23:27:53 +02:00
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 ] ;
// } ] ] ;
// === === = =
2018-03-20 17:26:17 +01:00
BOOL isBackupEnabled = [ OWSBackup . sharedManager isBackupEnabled ] ;
2018-12-03 14:46:58 +01:00
BOOL showBackup = ( OWSBackup . isFeatureEnabled && isBackupEnabled ) ;
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." )
2019-03-22 18:05:35 +01:00
accessibilityIdentifier : ACCESSIBILITY_IDENTIFIER _WITH _NAME ( self , @ "backup" )
2018-03-20 17:26:17 +01:00
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-05-10 23:27:53 +02:00
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 ] ;
// } ] ] ;
// === === = =
2017-06-15 19:43:18 +02:00
# 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 ] ; } ] ] ;
2019-09-20 06:26:29 +02:00
[ 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." )
2019-03-22 18:05:35 +01:00
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." )
2019-03-22 18:05:35 +01:00
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 ] ] ] ;
// === === = =
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
}
2019-03-19 21:02:16 +01:00
- ( 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 ] ;
2019-03-19 21:02:16 +01:00
button . accessibilityIdentifier = accessibilityIdentifier ;
2018-06-21 22:09:59 +02:00
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 ] ;
2019-05-27 08:30:28 +02:00
avatarView . contactID = OWSIdentityManager . sharedManager . identityKeyPair . hexEncodedPublicKey ;
2017-08-14 20:51:19 +02:00
2019-06-17 02:08:14 +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 ] ;
}
2019-06-17 02:08:14 +02:00
* /
2017-08-14 22:18:54 +02:00
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 ] ;
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" ) ] ;
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 : 0 xcccccc ] ;
[ 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
2019-03-22 18:05:35 +01:00
cell . accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER _WITH _NAME ( self , @ "profile" ) ;
2019-03-19 21:02:16 +01:00
2017-08-14 20:51:19 +02:00
return cell ;
}
2017-05-10 23:27:53 +02:00
- ( void ) showInviteFlow
{
2019-01-17 17:43:44 +01:00
OWSInviteFlow * inviteFlow = [ [ OWSInviteFlow alloc ] initWithPresentingViewController : self ] ;
2017-05-10 23:27:53 +02:00
[ 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
{
2019-01-09 17:31:17 +01:00
OWSLinkedDevicesTableViewController * vc = [ OWSLinkedDevicesTableViewController new ] ;
2017-05-10 23:27:53 +02:00
[ 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
{
2018-11-21 23:21:10 +01:00
__weak AppSettingsViewController * weakSelf = self ;
2019-03-21 15:55:04 +01:00
UIAlertController * alert =
2015-12-22 12:45:09 +01:00
[ UIAlertController alertControllerWithTitle : NSLocalizedString ( @ "CONFIRM_ACCOUNT_DESTRUCTION_TITLE" , @ "" )
message : NSLocalizedString ( @ "CONFIRM_ACCOUNT_DESTRUCTION_TEXT" , @ "" )
preferredStyle : UIAlertControllerStyleAlert ] ;
2019-03-21 15:55:04 +01:00
[ alert addAction : [ UIAlertAction actionWithTitle : NSLocalizedString ( @ "PROCEED_BUTTON" , @ "" )
style : UIAlertActionStyleDestructive
handler : ^ ( UIAlertAction * action ) {
[ weakSelf deleteAccount : isRegistered ] ;
} ] ] ;
[ alert addAction : [ OWSAlerts cancelAction ] ] ;
[ self presentAlert : alert ] ;
2015-02-16 19:48:31 +01:00
}
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
}
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
}
2019-09-20 06:26:29 +02:00
- ( void ) linkDevice
{
2019-09-20 07:53:24 +02:00
LKDeviceLinkingModal * deviceLinkingModal = [ LKDeviceLinkingModal new ] ;
deviceLinkingModal . modalPresentationStyle = UIModalPresentationOverFullScreen ;
[ self presentViewController : deviceLinkingModal animated : YES completion : nil ] ;
2019-09-20 06:26:29 +02:00
}
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
{
NSString * title = NSLocalizedString ( @ "Clear All Data" , @ "" ) ;
NSString * message = NSLocalizedString ( @ "Are you sure you want to clear all your data? This will delete your entire account, including all conversations and your personal key pair." , @ "" ) ;
UIAlertController * alert = [ UIAlertController alertControllerWithTitle : title message : message preferredStyle : UIAlertControllerStyleAlert ] ;
[ alert addAction : [ UIAlertAction actionWithTitle : NSLocalizedString ( @ "OK" , @ "" ) style : UIAlertActionStyleDestructive handler : ^ ( UIAlertAction * action ) {
[ ThreadUtil deleteAllContent ] ;
[ SSKEnvironment . shared . identityManager clearIdentityKey ] ;
[ LKAPI clearRandomSnodePool ] ;
2019-08-29 07:21:45 +02:00
AppDelegate * appDelegate = ( AppDelegate * ) UIApplication . sharedApplication . delegate ;
[ appDelegate stopLongPollerIfNeeded ] ;
2019-08-02 03:16:34 +02:00
[ SSKEnvironment . shared . tsAccountManager resetForReregistration ] ;
2019-08-01 02:34:32 +02:00
UIViewController * rootViewController = [ [ OnboardingController new ] initialViewController ] ;
OWSNavigationController * navigationController = [ [ OWSNavigationController alloc ] initWithRootViewController : rootViewController ] ;
navigationController . navigationBarHidden = YES ;
UIApplication . sharedApplication . keyWindow . rootViewController = navigationController ;
} ] ] ;
[ alert addAction : [ UIAlertAction actionWithTitle : NSLocalizedString ( @ "Cancel" , @ "" ) style : UIAlertActionStyleDefault handler : ^ ( UIAlertAction * action ) { / * Do nothing * / } ] ] ;
[ self presentAlert : alert ] ;
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 : ) ] ;
}
2019-03-22 18:05:35 +01:00
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 ] ;
}
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 )
2018-10-04 22:42:05 +02:00
name : kNSNotification_OWSWebSocketStateDidChange
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