Work on two-factor auth settings UI.
This commit is contained in:
parent
1f6cbd399e
commit
e12a1e984a
|
@ -211,7 +211,7 @@ SPEC CHECKSUMS:
|
|||
PureLayout: 4d550abe49a94f24c2808b9b95db9131685fe4cd
|
||||
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
|
||||
SAMKeychain: 483e1c9f32984d50ca961e26818a534283b4cd5c
|
||||
SignalServiceKit: c639443811f2670986006f5b661cb1a862de66ab
|
||||
SignalServiceKit: 5cc6e8e249f381c5eaee8693c0dff20fc1a3eee0
|
||||
SocketRocket: dbb1554b8fc288ef8ef370d6285aeca7361be31e
|
||||
SQLCipher: f9fcf29b2e59ced7defc2a2bdd0ebe79b40d4990
|
||||
SSZipArchive: 14401ade5f8e82aba1ff03e9f88e9de60937ae60
|
||||
|
@ -222,4 +222,4 @@ SPEC CHECKSUMS:
|
|||
|
||||
PODFILE CHECKSUM: 66db99df53e7593362ebb004bea5d2215ca00e8e
|
||||
|
||||
COCOAPODS: 1.3.1
|
||||
COCOAPODS: 1.4.0
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
344F249A200FD03300CFB4F4 /* MessageApprovalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 344F2496200FD03200CFB4F4 /* MessageApprovalViewController.swift */; };
|
||||
344F249B200FD03300CFB4F4 /* SharingThreadPickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 344F2497200FD03200CFB4F4 /* SharingThreadPickerViewController.m */; };
|
||||
344F249C200FD03300CFB4F4 /* AttachmentApprovalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 344F2498200FD03200CFB4F4 /* AttachmentApprovalViewController.swift */; };
|
||||
345BC30C2047030700257B7C /* OWS2FASettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 345BC30B2047030600257B7C /* OWS2FASettingsViewController.m */; };
|
||||
3461284B1FD0B94000532771 /* SAELoadViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3461284A1FD0B93F00532771 /* SAELoadViewController.swift */; };
|
||||
346129341FD1A88700532771 /* OWSSwiftUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346129331FD1A88700532771 /* OWSSwiftUtils.swift */; };
|
||||
346129391FD1B47300532771 /* OWSPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129371FD1B47200532771 /* OWSPreferences.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
|
@ -568,6 +569,8 @@
|
|||
344F2496200FD03200CFB4F4 /* MessageApprovalViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MessageApprovalViewController.swift; path = SignalMessaging/attachments/MessageApprovalViewController.swift; sourceTree = SOURCE_ROOT; };
|
||||
344F2497200FD03200CFB4F4 /* SharingThreadPickerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SharingThreadPickerViewController.m; path = SignalMessaging/attachments/SharingThreadPickerViewController.m; sourceTree = SOURCE_ROOT; };
|
||||
344F2498200FD03200CFB4F4 /* AttachmentApprovalViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AttachmentApprovalViewController.swift; path = SignalMessaging/attachments/AttachmentApprovalViewController.swift; sourceTree = SOURCE_ROOT; };
|
||||
345BC30A2047030600257B7C /* OWS2FASettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWS2FASettingsViewController.h; sourceTree = "<group>"; };
|
||||
345BC30B2047030600257B7C /* OWS2FASettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWS2FASettingsViewController.m; sourceTree = "<group>"; };
|
||||
3461284A1FD0B93F00532771 /* SAELoadViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAELoadViewController.swift; sourceTree = "<group>"; };
|
||||
346129331FD1A88700532771 /* OWSSwiftUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OWSSwiftUtils.swift; sourceTree = "<group>"; };
|
||||
346129371FD1B47200532771 /* OWSPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSPreferences.h; sourceTree = "<group>"; };
|
||||
|
@ -1469,6 +1472,8 @@
|
|||
34B3F8571E8DF1700035BE1A /* NotificationSettingsOptionsViewController.m */,
|
||||
34B3F8581E8DF1700035BE1A /* NotificationSettingsViewController.h */,
|
||||
34B3F8591E8DF1700035BE1A /* NotificationSettingsViewController.m */,
|
||||
345BC30A2047030600257B7C /* OWS2FASettingsViewController.h */,
|
||||
345BC30B2047030600257B7C /* OWS2FASettingsViewController.m */,
|
||||
34CCAF391F0C2748004084F4 /* OWSAddToContactViewController.h */,
|
||||
34CCAF3A1F0C2748004084F4 /* OWSAddToContactViewController.m */,
|
||||
347E0B772003CD7400BC2F76 /* OWSBackupExportViewController.h */,
|
||||
|
@ -3102,6 +3107,7 @@
|
|||
4523149E1F7E916B003A428C /* SlideOffAnimatedTransition.swift in Sources */,
|
||||
452C468F1E427E200087B011 /* OutboundCallInitiator.swift in Sources */,
|
||||
45F170BB1E2FC5D3003FC1F2 /* CallAudioService.swift in Sources */,
|
||||
345BC30C2047030700257B7C /* OWS2FASettingsViewController.m in Sources */,
|
||||
34B3F8711E8DF1700035BE1A /* AboutTableViewController.m in Sources */,
|
||||
34B3F88D1E8DF1700035BE1A /* OWSQRCodeScanningViewController.m in Sources */,
|
||||
34BECE2E1F7ABCE000D7438D /* GifPickerViewController.swift in Sources */,
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#import "OWSDatabaseMigration.h"
|
||||
#import "OWSNavigationController.h"
|
||||
#import "OWSProgressView.h"
|
||||
#import "OWSViewController.h"
|
||||
#import "OWSWebRTCDataProtos.pb.h"
|
||||
#import "PrivacySettingsTableViewController.h"
|
||||
#import "ProfileViewController.h"
|
||||
|
@ -53,6 +52,7 @@
|
|||
#import <SignalMessaging/OWSPreferences.h>
|
||||
#import <SignalMessaging/OWSProfileManager.h>
|
||||
#import <SignalMessaging/OWSSounds.h>
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
#import <SignalMessaging/Release.h>
|
||||
#import <SignalMessaging/ThreadUtil.h>
|
||||
#import <SignalMessaging/UIColor+OWS.h>
|
||||
|
|
|
@ -89,6 +89,10 @@
|
|||
self.title = NSLocalizedString(@"SETTINGS_NAV_BAR_TITLE", @"Title for settings activity");
|
||||
|
||||
[self updateTableContents];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self showPrivacy];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TSThread;
|
||||
|
|
|
@ -285,6 +285,10 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|||
}
|
||||
|
||||
[self updateBarButtonItems];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self settingsButtonPressed:nil];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)updateBarButtonItems
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSConversationSettingsViewDelegate.h"
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSUInteger, Enable2FAMode) {
|
||||
Enable2FAMode_Status = 0,
|
||||
Enable2FAMode_SelectPIN,
|
||||
Enable2FAMode_ConfirmPIN,
|
||||
};
|
||||
|
||||
@interface OWS2FASettingsViewController : OWSViewController
|
||||
|
||||
@property (nonatomic) Enable2FAMode mode;
|
||||
|
||||
// When confirming the PIN, this is the PIN that was
|
||||
// initially entered by the user.
|
||||
@property (nonatomic, nullable) NSString *candidatePin;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,940 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWS2FASettingsViewController.h"
|
||||
#import "OWSTableViewController.h"
|
||||
#import "Signal-Swift.h"
|
||||
#import "SignalMessaging.h"
|
||||
#import <SignalMessaging/NSString+OWS.h>
|
||||
#import <SignalMessaging/SignalMessaging-Swift.h>
|
||||
#import <SignalMessaging/SignalMessaging.h>
|
||||
#import <SignalMessaging/UIColor+OWS.h>
|
||||
#import <SignalMessaging/UIFont+OWS.h>
|
||||
#import <SignalMessaging/UIView+OWS.h>
|
||||
#import <SignalServiceKit/OWS2FAManager.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWS2FASettingsViewController () <UITextFieldDelegate>
|
||||
|
||||
@property (nonatomic, weak) UIViewController *root2FAViewController;
|
||||
|
||||
@property (nonatomic) UITextField *pinTextfield;
|
||||
@property (nonatomic) OWSTableViewController *tableViewController;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWS2FASettingsViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.view.backgroundColor = UIColor.whiteColor;
|
||||
|
||||
self.title = NSLocalizedString(@"ENABLE_2FA_VIEW_TITLE", @"Title for the 'enable two factor auth PIN' views.");
|
||||
|
||||
switch (self.mode) {
|
||||
case Enable2FAMode_Status:
|
||||
[self createStatusContents];
|
||||
break;
|
||||
case Enable2FAMode_SelectPIN:
|
||||
[self createSelectCodeContents];
|
||||
break;
|
||||
case Enable2FAMode_ConfirmPIN:
|
||||
[self createConfirmCodeContents];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
// If we're using a table, refresh its contents.
|
||||
[self updateTableContents];
|
||||
|
||||
[self updateNavigationItems];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
// If we're using a PIN textfield, select it.
|
||||
[self.pinTextfield becomeFirstResponder];
|
||||
}
|
||||
|
||||
- (UILabel *)createLabelWithText:(NSString *)text
|
||||
{
|
||||
UILabel *label = [UILabel new];
|
||||
label.textColor = [UIColor blackColor];
|
||||
label.text = text;
|
||||
label.font = [UIFont ows_regularFontWithSize:ScaleFromIPhone5To7Plus(14.f, 16.f)];
|
||||
label.numberOfLines = 0;
|
||||
label.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
[self.view addSubview:label];
|
||||
return label;
|
||||
}
|
||||
|
||||
- (void)createPinTextfield
|
||||
{
|
||||
self.pinTextfield = [UITextField new];
|
||||
self.pinTextfield.textColor = [UIColor blackColor];
|
||||
switch (self.mode) {
|
||||
case Enable2FAMode_SelectPIN:
|
||||
self.pinTextfield.placeholder = NSLocalizedString(@"ENABLE_2FA_VIEW_SELECT_PIN_DEFAULT_TEXT",
|
||||
@"Text field placeholder for 'two factor auth pin' when selecting a pin.");
|
||||
break;
|
||||
case Enable2FAMode_ConfirmPIN:
|
||||
self.pinTextfield.placeholder = NSLocalizedString(@"ENABLE_2FA_VIEW_CONFIRM_PIN_DEFAULT_TEXT",
|
||||
@"Text field placeholder for 'two factor auth pin' when confirming a pin.");
|
||||
break;
|
||||
case Enable2FAMode_Status:
|
||||
OWSFail(@"%@ invalid mode.", self.logTag) break;
|
||||
}
|
||||
self.pinTextfield.font = [UIFont ows_mediumFontWithSize:ScaleFromIPhone5To7Plus(30.f, 36.f)];
|
||||
self.pinTextfield.textAlignment = NSTextAlignmentCenter;
|
||||
self.pinTextfield.keyboardType = UIKeyboardTypeNumberPad;
|
||||
self.pinTextfield.delegate = self;
|
||||
self.pinTextfield.secureTextEntry = YES;
|
||||
self.pinTextfield.textAlignment = NSTextAlignmentCenter;
|
||||
[self.pinTextfield addTarget:self
|
||||
action:@selector(textFieldDidChange:)
|
||||
forControlEvents:UIControlEventEditingChanged];
|
||||
[self.view addSubview:self.pinTextfield];
|
||||
}
|
||||
|
||||
- (void)createTableView
|
||||
{
|
||||
self.tableViewController = [OWSTableViewController new];
|
||||
[self.view addSubview:self.tableViewController.view];
|
||||
}
|
||||
|
||||
- (void)createStatusContents
|
||||
{
|
||||
const CGFloat kVSpacing = 30.f;
|
||||
|
||||
// TODO: Add hero image?
|
||||
// TODO: Tweak background color?
|
||||
|
||||
NSString *instructions = ([OWS2FAManager.sharedManager is2FAEnabled]
|
||||
? NSLocalizedString(@"ENABLE_2FA_VIEW_STATUS_ENABLED_INSTRUCTIONS",
|
||||
@"Indicates that user has 'two factor auth pin' enabled.")
|
||||
: NSLocalizedString(@"ENABLE_2FA_VIEW_STATUS_DISABLED_INSTRUCTIONS",
|
||||
@"Indicates that user has 'two factor auth pin' disabled."));
|
||||
UILabel *instructionsLabel = [self createLabelWithText:instructions];
|
||||
|
||||
[self createTableView];
|
||||
|
||||
[instructionsLabel autoPinToTopLayoutGuideOfViewController:self withInset:kVSpacing];
|
||||
[instructionsLabel autoPinWidthToSuperviewWithMargin:self.hMargin];
|
||||
|
||||
[self.tableViewController.view autoPinWidthToSuperview];
|
||||
[self.tableViewController.view autoPinEdge:ALEdgeTop
|
||||
toEdge:ALEdgeBottom
|
||||
ofView:instructionsLabel
|
||||
withOffset:kVSpacing];
|
||||
[self.tableViewController.view autoPinToBottomLayoutGuideOfViewController:self withInset:0];
|
||||
|
||||
[self updateTableContents];
|
||||
}
|
||||
|
||||
- (void)createSelectCodeContents
|
||||
{
|
||||
[self createEnterPINContentsWithInstructions:NSLocalizedString(@"ENABLE_2FA_VIEW_SELECT_PIN_INSTRUCTIONS",
|
||||
@"Indicates that user should select a 'two factor auth pin'.")];
|
||||
}
|
||||
|
||||
- (void)createConfirmCodeContents
|
||||
{
|
||||
[self
|
||||
createEnterPINContentsWithInstructions:NSLocalizedString(@"ENABLE_2FA_VIEW_CONFIRM_PIN_INSTRUCTIONS",
|
||||
@"Indicates that user should confirm their 'two factor auth pin'.")];
|
||||
}
|
||||
|
||||
- (CGFloat)hMargin
|
||||
{
|
||||
return 20.f;
|
||||
}
|
||||
|
||||
- (void)createEnterPINContentsWithInstructions:(NSString *)instructionsText
|
||||
{
|
||||
const CGFloat kVSpacing = 30.f;
|
||||
|
||||
UILabel *instructionsLabel = [self createLabelWithText:instructionsText];
|
||||
|
||||
[self createPinTextfield];
|
||||
|
||||
[instructionsLabel autoPinTopToSuperviewWithMargin:kVSpacing];
|
||||
[instructionsLabel autoPinWidthToSuperviewWithMargin:self.hMargin];
|
||||
|
||||
// CGFloat textFieldWidth = [self.pinTextfield sizeThatFits:CGSizeZero].width + 10.f;
|
||||
|
||||
[self.pinTextfield autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:instructionsLabel withOffset:kVSpacing];
|
||||
[self.pinTextfield autoPinWidthToSuperviewWithMargin:self.hMargin];
|
||||
// [self.pinTextfield autoSetDimension:ALDimensionWidth toSize:textFieldWidth];
|
||||
[self.pinTextfield autoHCenterInSuperview];
|
||||
|
||||
UIView *underscoreView = [UIView new];
|
||||
underscoreView.backgroundColor = [UIColor colorWithWhite:0.5 alpha:1.f];
|
||||
[self.view addSubview:underscoreView];
|
||||
[underscoreView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.pinTextfield withOffset:3];
|
||||
[underscoreView autoPinWidthToSuperviewWithMargin:self.hMargin];
|
||||
// [underscoreView autoSetDimension:ALDimensionWidth toSize:textFieldWidth];
|
||||
[underscoreView autoHCenterInSuperview];
|
||||
[underscoreView autoSetDimension:ALDimensionHeight toSize:1.f];
|
||||
|
||||
[self updateNavigationItems];
|
||||
}
|
||||
|
||||
- (void)updateTableContents
|
||||
{
|
||||
__weak OWS2FASettingsViewController *weakSelf = self;
|
||||
|
||||
// Only some modes use a table.
|
||||
switch (self.mode) {
|
||||
case Enable2FAMode_Status: {
|
||||
OWSTableContents *contents = [OWSTableContents new];
|
||||
OWSTableSection *section = [OWSTableSection new];
|
||||
if ([OWS2FAManager.sharedManager is2FAEnabled]) {
|
||||
[section
|
||||
addItem:[OWSTableItem disclosureItemWithText:
|
||||
NSLocalizedString(@"ENABLE_2FA_VIEW_DISABLE_2FA",
|
||||
@"Label for the 'enable two-factor auth' item in the settings view")
|
||||
actionBlock:^{
|
||||
[weakSelf tryToDisable2FA];
|
||||
}]];
|
||||
} else {
|
||||
[section
|
||||
addItem:[OWSTableItem disclosureItemWithText:
|
||||
NSLocalizedString(@"ENABLE_2FA_VIEW_ENABLE_2FA",
|
||||
@"Label for the 'enable two-factor auth' item in the settings view")
|
||||
actionBlock:^{
|
||||
[weakSelf showEnable2FAWorkUI];
|
||||
}]];
|
||||
}
|
||||
[contents addSection:section];
|
||||
self.tableViewController.contents = contents;
|
||||
break;
|
||||
}
|
||||
case Enable2FAMode_SelectPIN:
|
||||
case Enable2FAMode_ConfirmPIN:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)shouldHaveNextButton
|
||||
{
|
||||
switch (self.mode) {
|
||||
case Enable2FAMode_Status:
|
||||
return NO;
|
||||
case Enable2FAMode_SelectPIN:
|
||||
case Enable2FAMode_ConfirmPIN:
|
||||
return [self hasValidPin];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateNavigationItems
|
||||
{
|
||||
// Note: This affects how the "back" button will look if another
|
||||
// view is pushed on top of this one, not how the "back"
|
||||
// button looks when this view is visible.
|
||||
self.navigationItem.backBarButtonItem =
|
||||
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"VERIFICATION_BACK_BUTTON",
|
||||
@"button text for back button on verification view")
|
||||
style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(backButtonWasPressed)];
|
||||
|
||||
if (self.shouldHaveNextButton) {
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
|
||||
initWithTitle:NSLocalizedString(@"ENABLE_2FA_VIEW_NEXT_BUTTON",
|
||||
@"Label for the 'next' button in the 'enable two factor auth' views.")
|
||||
style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(nextButtonWasPressed)];
|
||||
} else {
|
||||
self.navigationItem.rightBarButtonItem = nil;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UITextFieldDelegate
|
||||
|
||||
- (BOOL)textField:(UITextField *)textField
|
||||
shouldChangeCharactersInRange:(NSRange)range
|
||||
replacementString:(NSString *)insertionText
|
||||
{
|
||||
// TODO: ?
|
||||
const NSUInteger kMaxPinLength = 14;
|
||||
|
||||
// * We only want to let the user enter decimal digits.
|
||||
// * The user should be able to copy and paste freely.
|
||||
// * Invalid input should be simply ignored.
|
||||
//
|
||||
// We accomplish this by being permissive and trying to "take as much of the user
|
||||
// input as possible".
|
||||
//
|
||||
// * Always accept deletes.
|
||||
// * Ignore invalid input.
|
||||
// * Take partial input if possible.
|
||||
|
||||
NSString *oldText = textField.text;
|
||||
// Construct the new contents of the text field by:
|
||||
// 1. Determining the "left" substring: the contents of the old text _before_ the deletion range.
|
||||
// Filtering will remove non-decimal digit characters.
|
||||
NSString *left = [oldText substringToIndex:range.location].digitsOnly;
|
||||
// 2. Determining the "right" substring: the contents of the old text _after_ the deletion range.
|
||||
NSString *right = [oldText substringFromIndex:range.location + range.length].digitsOnly;
|
||||
// 3. Determining the "center" substring: the contents of the new insertion text.
|
||||
NSString *center = insertionText.digitsOnly;
|
||||
// 4. Construct the "raw" new text by concatenating left, center and right.
|
||||
NSString *textAfterChange = [[left stringByAppendingString:center] stringByAppendingString:right];
|
||||
// 5. Ensure we don't exceed the maximum length for a PIN.
|
||||
if (textAfterChange.length > kMaxPinLength) {
|
||||
textAfterChange = [textAfterChange substringToIndex:kMaxPinLength];
|
||||
}
|
||||
// 6. Construct the "formatted" new text by inserting a hyphen if necessary.
|
||||
// reformat the phone number, trying to keep the cursor beside the inserted or deleted digit
|
||||
textField.text = textAfterChange;
|
||||
NSUInteger cursorPositionAfterChange = MIN(left.length + center.length, textAfterChange.length);
|
||||
UITextPosition *pos =
|
||||
[textField positionFromPosition:textField.beginningOfDocument offset:(NSInteger)cursorPositionAfterChange];
|
||||
[textField setSelectedTextRange:[textField textRangeFromPosition:pos toPosition:pos]];
|
||||
|
||||
[self updateNavigationItems];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)textFieldDidChange:(id)sender
|
||||
{
|
||||
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
||||
|
||||
[self updateNavigationItems];
|
||||
}
|
||||
|
||||
#pragma mark - Events
|
||||
|
||||
- (void)nextButtonWasPressed
|
||||
{
|
||||
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
||||
|
||||
switch (self.mode) {
|
||||
case Enable2FAMode_Status:
|
||||
OWSFail(@"%@ status mode should not have a next button.", self.logTag);
|
||||
return;
|
||||
case Enable2FAMode_SelectPIN: {
|
||||
OWSAssert(self.hasValidPin);
|
||||
|
||||
OWS2FASettingsViewController *vc = [OWS2FASettingsViewController new];
|
||||
vc.mode = Enable2FAMode_ConfirmPIN;
|
||||
vc.candidatePin = self.pinTextfield.text;
|
||||
vc.root2FAViewController = self;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
break;
|
||||
}
|
||||
case Enable2FAMode_ConfirmPIN: {
|
||||
OWSAssert(self.hasValidPin);
|
||||
|
||||
if ([self.pinTextfield.text isEqualToString:self.candidatePin]) {
|
||||
[self tryToEnable2FA];
|
||||
} else {
|
||||
// Clear the PIN so that the user can try again.
|
||||
self.pinTextfield.text = nil;
|
||||
|
||||
[OWSAlerts
|
||||
showAlertWithTitle:NSLocalizedString(@"ALERT_ERROR_TITLE", @"")
|
||||
message:NSLocalizedString(@"ENABLE_2FA_VIEW_PIN_DOES_NOT_MATCH",
|
||||
@"Error indicating that the entered 'two-factor auth PINs' do not match.")];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)hasValidPin
|
||||
{
|
||||
const NSUInteger kMinPinLength = 4;
|
||||
return self.pinTextfield.text.length >= kMinPinLength;
|
||||
}
|
||||
|
||||
- (void)showEnable2FAWorkUI
|
||||
{
|
||||
OWSAssert(![OWS2FAManager.sharedManager is2FAEnabled]);
|
||||
|
||||
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
||||
|
||||
OWS2FASettingsViewController *vc = [OWS2FASettingsViewController new];
|
||||
vc.mode = Enable2FAMode_SelectPIN;
|
||||
vc.root2FAViewController = self;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)tryToDisable2FA
|
||||
{
|
||||
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
||||
|
||||
__weak OWS2FASettingsViewController *weakSelf = self;
|
||||
|
||||
[ModalActivityIndicatorViewController
|
||||
presentFromViewController:self
|
||||
canCancel:NO
|
||||
backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
|
||||
[OWS2FAManager.sharedManager disable2FAWithSuccess:^{
|
||||
[modalActivityIndicator dismissWithCompletion:^{
|
||||
// TODO: Should we show an alert?
|
||||
|
||||
[weakSelf updateTableContents];
|
||||
}];
|
||||
}
|
||||
failure:^(NSError *error) {
|
||||
[modalActivityIndicator dismissWithCompletion:^{
|
||||
[weakSelf updateTableContents];
|
||||
|
||||
[OWSAlerts
|
||||
showAlertWithTitle:NSLocalizedString(@"ALERT_ERROR_TITLE", @"")
|
||||
message:NSLocalizedString(@"ENABLE_2FA_VIEW_COULD_NOT_DISABLE_2FA",
|
||||
@"Error indicating that attempt to disable 'two-factor "
|
||||
@"auth' failed.")];
|
||||
}];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)tryToEnable2FA
|
||||
{
|
||||
OWSAssert(self.candidatePin.length > 0);
|
||||
|
||||
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
||||
|
||||
__weak OWS2FASettingsViewController *weakSelf = self;
|
||||
|
||||
[ModalActivityIndicatorViewController
|
||||
presentFromViewController:self
|
||||
canCancel:NO
|
||||
backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
|
||||
[OWS2FAManager.sharedManager enable2FAWithPin:self.candidatePin
|
||||
success:^{
|
||||
[modalActivityIndicator dismissWithCompletion:^{
|
||||
[weakSelf showCompleteUI];
|
||||
}];
|
||||
}
|
||||
failure:^(NSError *error) {
|
||||
[modalActivityIndicator dismissWithCompletion:^{
|
||||
// The client may have fallen out of sync with the service.
|
||||
// Try to get back to a known good state by disabling 2FA
|
||||
// whenever enabling it fails.
|
||||
[OWS2FAManager.sharedManager disable2FAWithSuccess:nil failure:nil];
|
||||
|
||||
[weakSelf updateTableContents];
|
||||
|
||||
[OWSAlerts
|
||||
showAlertWithTitle:NSLocalizedString(@"ALERT_ERROR_TITLE", @"")
|
||||
message:NSLocalizedString(@"ENABLE_2FA_VIEW_COULD_NOT_ENABLE_2FA",
|
||||
@"Error indicating that attempt to enable 'two-factor "
|
||||
@"auth' failed.")];
|
||||
}];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)showCompleteUI
|
||||
{
|
||||
OWSAssert([OWS2FAManager.sharedManager is2FAEnabled]);
|
||||
OWSAssert(self.root2FAViewController);
|
||||
|
||||
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
||||
|
||||
[self.navigationController popToViewController:self.root2FAViewController animated:NO];
|
||||
}
|
||||
|
||||
- (void)backButtonWasPressed
|
||||
{
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
//#import "RegistrationViewController.h"
|
||||
//#import "CodeVerificationViewController.h"
|
||||
//#import "CountryCodeViewController.h"
|
||||
//#import "PhoneNumber.h"
|
||||
//#import "PhoneNumberUtil.h"
|
||||
//#import "Signal-Swift.h"
|
||||
//#import "TSAccountManager.h"
|
||||
//#import "UIView+OWS.h"
|
||||
//#import "ViewControllerUtils.h"
|
||||
//#import <SAMKeychain/SAMKeychain.h>
|
||||
//#import <SignalMessaging/Environment.h>
|
||||
//#import <SignalMessaging/NSString+OWS.h>
|
||||
//
|
||||
// NS_ASSUME_NONNULL_BEGIN
|
||||
//
|
||||
//#ifdef DEBUG
|
||||
//
|
||||
// NSString *const kKeychainService_LastRegistered = @"kKeychainService_LastRegistered";
|
||||
// NSString *const kKeychainKey_LastRegisteredCountryCode = @"kKeychainKey_LastRegisteredCountryCode";
|
||||
// NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegisteredPhoneNumber";
|
||||
//
|
||||
//#endif
|
||||
//
|
||||
//@interface RegistrationViewController () <CountryCodeViewControllerDelegate, UITextFieldDelegate>
|
||||
//
|
||||
//@property (nonatomic) NSString *countryCode;
|
||||
//@property (nonatomic) NSString *callingCode;
|
||||
//
|
||||
//@property (nonatomic) UILabel *countryCodeLabel;
|
||||
//@property (nonatomic) UITextField *phoneNumberTextField;
|
||||
//@property (nonatomic) UILabel *examplePhoneNumberLabel;
|
||||
//@property (nonatomic) OWSFlatButton *activateButton;
|
||||
//@property (nonatomic) UIActivityIndicatorView *spinnerView;
|
||||
//
|
||||
//@end
|
||||
//
|
||||
//#pragma mark -
|
||||
//
|
||||
//@implementation RegistrationViewController
|
||||
//
|
||||
//- (void)loadView
|
||||
//{
|
||||
// [super loadView];
|
||||
//
|
||||
// [self createViews];
|
||||
//
|
||||
// // Do any additional setup after loading the view.
|
||||
// [self populateDefaultCountryNameAndCode];
|
||||
// [SignalApp.sharedApp setSignUpFlowNavigationController:self.navigationController];
|
||||
//}
|
||||
//
|
||||
//- (void)viewDidLoad {
|
||||
// [super viewDidLoad];
|
||||
//
|
||||
// OWSProdInfo([OWSAnalyticsEvents registrationBegan]);
|
||||
//}
|
||||
//
|
||||
//- (void)createViews
|
||||
//{
|
||||
// self.view.backgroundColor = [UIColor whiteColor];
|
||||
// self.view.userInteractionEnabled = YES;
|
||||
// [self.view
|
||||
// addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backgroundTapped:)]];
|
||||
//
|
||||
// UIView *headerWrapper = [UIView containerView];
|
||||
// [self.view addSubview:headerWrapper];
|
||||
// headerWrapper.backgroundColor = UIColor.ows_signalBrandBlueColor;
|
||||
//
|
||||
// UIView *headerContent = [UIView new];
|
||||
// [headerWrapper addSubview:headerContent];
|
||||
// [headerWrapper autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsZero excludingEdge:ALEdgeBottom];
|
||||
// [headerContent autoPinEdgeToSuperviewEdge:ALEdgeBottom];
|
||||
// [headerContent autoPinToTopLayoutGuideOfViewController:self withInset:0];
|
||||
// [headerContent autoPinWidthToSuperview];
|
||||
//
|
||||
// UILabel *headerLabel = [UILabel new];
|
||||
// headerLabel.text = NSLocalizedString(@"REGISTRATION_TITLE_LABEL", @"");
|
||||
// headerLabel.textColor = [UIColor whiteColor];
|
||||
// headerLabel.font = [UIFont ows_mediumFontWithSize:ScaleFromIPhone5To7Plus(20.f, 24.f)];
|
||||
// [headerContent addSubview:headerLabel];
|
||||
// [headerLabel autoHCenterInSuperview];
|
||||
// [headerLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:14.f];
|
||||
//
|
||||
// CGFloat screenHeight = MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
|
||||
// if (screenHeight < 568) {
|
||||
// // iPhone 4s or smaller.
|
||||
// [headerContent autoSetDimension:ALDimensionHeight toSize:20];
|
||||
// headerLabel.hidden = YES;
|
||||
// } else if (screenHeight < 667) {
|
||||
// // iPhone 5 or smaller.
|
||||
// [headerContent autoSetDimension:ALDimensionHeight toSize:80];
|
||||
// } else {
|
||||
// [headerContent autoSetDimension:ALDimensionHeight toSize:220];
|
||||
//
|
||||
// UIImage *logo = [UIImage imageNamed:@"logoSignal"];
|
||||
// OWSAssert(logo);
|
||||
// UIImageView *logoView = [UIImageView new];
|
||||
// logoView.image = logo;
|
||||
// [headerContent addSubview:logoView];
|
||||
// [logoView autoHCenterInSuperview];
|
||||
// [logoView autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:headerLabel withOffset:-14.f];
|
||||
// }
|
||||
//
|
||||
// const CGFloat kRowHeight = 60.f;
|
||||
// const CGFloat kRowHMargin = 20.f;
|
||||
// const CGFloat kSeparatorHeight = 1.f;
|
||||
// const CGFloat kExamplePhoneNumberVSpacing = 8.f;
|
||||
// const CGFloat fontSizePoints = ScaleFromIPhone5To7Plus(16.f, 20.f);
|
||||
//
|
||||
// UIView *contentView = [UIView containerView];
|
||||
// [contentView setHLayoutMargins:kRowHMargin];
|
||||
// contentView.backgroundColor = [UIColor whiteColor];
|
||||
// [self.view addSubview:contentView];
|
||||
// [contentView autoPinToBottomLayoutGuideOfViewController:self withInset:0];
|
||||
// [contentView autoPinWidthToSuperview];
|
||||
// [contentView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:headerContent];
|
||||
//
|
||||
// // Country
|
||||
// UIView *countryRow = [UIView containerView];
|
||||
// [contentView addSubview:countryRow];
|
||||
// [countryRow autoPinLeadingAndTrailingToSuperview];
|
||||
// [countryRow autoPinEdgeToSuperviewEdge:ALEdgeTop];
|
||||
// [countryRow autoSetDimension:ALDimensionHeight toSize:kRowHeight];
|
||||
// [countryRow
|
||||
// addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self
|
||||
// action:@selector(countryCodeRowWasTapped:)]];
|
||||
//
|
||||
// UILabel *countryNameLabel = [UILabel new];
|
||||
// countryNameLabel.text
|
||||
// = NSLocalizedString(@"REGISTRATION_DEFAULT_COUNTRY_NAME", @"Label for the country code field");
|
||||
// countryNameLabel.textColor = [UIColor blackColor];
|
||||
// countryNameLabel.font = [UIFont ows_mediumFontWithSize:fontSizePoints];
|
||||
// [countryRow addSubview:countryNameLabel];
|
||||
// [countryNameLabel autoVCenterInSuperview];
|
||||
// [countryNameLabel autoPinLeadingToSuperview];
|
||||
//
|
||||
// UILabel *countryCodeLabel = [UILabel new];
|
||||
// self.countryCodeLabel = countryCodeLabel;
|
||||
// countryCodeLabel.textColor = [UIColor ows_materialBlueColor];
|
||||
// countryCodeLabel.font = [UIFont ows_mediumFontWithSize:fontSizePoints + 2.f];
|
||||
// [countryRow addSubview:countryCodeLabel];
|
||||
// [countryCodeLabel autoVCenterInSuperview];
|
||||
// [countryCodeLabel autoPinTrailingToSuperview];
|
||||
//
|
||||
// UIView *separatorView1 = [UIView new];
|
||||
// separatorView1.backgroundColor = [UIColor colorWithWhite:0.75f alpha:1.f];
|
||||
// [contentView addSubview:separatorView1];
|
||||
// [separatorView1 autoPinWidthToSuperview];
|
||||
// [separatorView1 autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:countryRow];
|
||||
// [separatorView1 autoSetDimension:ALDimensionHeight toSize:kSeparatorHeight];
|
||||
//
|
||||
// // Phone Number
|
||||
// UIView *phoneNumberRow = [UIView containerView];
|
||||
// [contentView addSubview:phoneNumberRow];
|
||||
// [phoneNumberRow autoPinLeadingAndTrailingToSuperview];
|
||||
// [phoneNumberRow autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:separatorView1];
|
||||
// [phoneNumberRow autoSetDimension:ALDimensionHeight toSize:kRowHeight];
|
||||
//
|
||||
// UILabel *phoneNumberLabel = [UILabel new];
|
||||
// phoneNumberLabel.text
|
||||
// = NSLocalizedString(@"REGISTRATION_PHONENUMBER_BUTTON", @"Label for the phone number textfield");
|
||||
// phoneNumberLabel.textColor = [UIColor blackColor];
|
||||
// phoneNumberLabel.font = [UIFont ows_mediumFontWithSize:fontSizePoints];
|
||||
// [phoneNumberRow addSubview:phoneNumberLabel];
|
||||
// [phoneNumberLabel autoVCenterInSuperview];
|
||||
// [phoneNumberLabel autoPinLeadingToSuperview];
|
||||
//
|
||||
// UITextField *phoneNumberTextField = [UITextField new];
|
||||
// phoneNumberTextField.textAlignment = NSTextAlignmentRight;
|
||||
// phoneNumberTextField.delegate = self;
|
||||
// phoneNumberTextField.keyboardType = UIKeyboardTypeNumberPad;
|
||||
// phoneNumberTextField.placeholder = NSLocalizedString(
|
||||
// @"REGISTRATION_ENTERNUMBER_DEFAULT_TEXT", @"Placeholder text
|
||||
// for the phone number textfield");
|
||||
// self.phoneNumberTextField = phoneNumberTextField;
|
||||
// phoneNumberTextField.textColor = [UIColor ows_materialBlueColor];
|
||||
// phoneNumberTextField.font = [UIFont ows_mediumFontWithSize:fontSizePoints + 2];
|
||||
// [phoneNumberRow addSubview:phoneNumberTextField];
|
||||
// [phoneNumberTextField autoVCenterInSuperview];
|
||||
// [phoneNumberTextField autoPinTrailingToSuperview];
|
||||
//
|
||||
// UILabel *examplePhoneNumberLabel = [UILabel new];
|
||||
// self.examplePhoneNumberLabel = examplePhoneNumberLabel;
|
||||
// examplePhoneNumberLabel.font = [UIFont ows_regularFontWithSize:fontSizePoints - 2.f];
|
||||
// examplePhoneNumberLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f];
|
||||
// [contentView addSubview:examplePhoneNumberLabel];
|
||||
// [examplePhoneNumberLabel autoPinTrailingToSuperview];
|
||||
// [examplePhoneNumberLabel autoPinEdge:ALEdgeTop
|
||||
// toEdge:ALEdgeBottom
|
||||
// ofView:phoneNumberTextField
|
||||
// withOffset:kExamplePhoneNumberVSpacing];
|
||||
//
|
||||
// UIView *separatorView2 = [UIView new];
|
||||
// separatorView2.backgroundColor = [UIColor colorWithWhite:0.75f alpha:1.f];
|
||||
// [contentView addSubview:separatorView2];
|
||||
// [separatorView2 autoPinWidthToSuperview];
|
||||
// [separatorView2 autoPinEdge:ALEdgeTop
|
||||
// toEdge:ALEdgeBottom
|
||||
// ofView:phoneNumberRow
|
||||
// withOffset:examplePhoneNumberLabel.font.lineHeight];
|
||||
// [separatorView2 autoSetDimension:ALDimensionHeight toSize:kSeparatorHeight];
|
||||
//
|
||||
// // Activate Button
|
||||
// const CGFloat kActivateButtonHeight = 47.f;
|
||||
// // NOTE: We use ows_signalBrandBlueColor instead of ows_materialBlueColor
|
||||
// // throughout the onboarding flow to be consistent with the headers.
|
||||
// OWSFlatButton *activateButton = [OWSFlatButton buttonWithTitle:NSLocalizedString(@"REGISTRATION_VERIFY_DEVICE",
|
||||
// @"")
|
||||
// font:[OWSFlatButton fontForHeight:kActivateButtonHeight]
|
||||
// titleColor:[UIColor whiteColor]
|
||||
// backgroundColor:[UIColor ows_signalBrandBlueColor]
|
||||
// target:self
|
||||
// selector:@selector(sendCodeAction)];
|
||||
// self.activateButton = activateButton;
|
||||
// [contentView addSubview:activateButton];
|
||||
// [activateButton autoPinLeadingAndTrailingToSuperview];
|
||||
// [activateButton autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:separatorView2 withOffset:15];
|
||||
// [activateButton autoSetDimension:ALDimensionHeight toSize:kActivateButtonHeight];
|
||||
//
|
||||
// UIActivityIndicatorView *spinnerView =
|
||||
// [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
|
||||
// self.spinnerView = spinnerView;
|
||||
// [activateButton addSubview:spinnerView];
|
||||
// [spinnerView autoVCenterInSuperview];
|
||||
// [spinnerView autoSetDimension:ALDimensionWidth toSize:20.f];
|
||||
// [spinnerView autoSetDimension:ALDimensionHeight toSize:20.f];
|
||||
// [spinnerView autoPinTrailingToSuperviewWithMargin:20.f];
|
||||
// [spinnerView stopAnimating];
|
||||
//}
|
||||
//
|
||||
//- (void)viewDidAppear:(BOOL)animated {
|
||||
// [super viewDidAppear:animated];
|
||||
//
|
||||
// [self.activateButton setEnabled:YES];
|
||||
// [self.spinnerView stopAnimating];
|
||||
// [self.phoneNumberTextField becomeFirstResponder];
|
||||
//}
|
||||
//
|
||||
//#pragma mark - Country
|
||||
//
|
||||
//- (void)populateDefaultCountryNameAndCode {
|
||||
// NSString *countryCode = [PhoneNumber defaultCountryCode];
|
||||
//
|
||||
//#ifdef DEBUG
|
||||
// if ([self lastRegisteredCountryCode].length > 0) {
|
||||
// countryCode = [self lastRegisteredCountryCode];
|
||||
// }
|
||||
// self.phoneNumberTextField.text = [self lastRegisteredPhoneNumber];
|
||||
//#endif
|
||||
//
|
||||
// NSNumber *callingCode = [[PhoneNumberUtil sharedUtil].nbPhoneNumberUtil getCountryCodeForRegion:countryCode];
|
||||
// NSString *countryName = [PhoneNumberUtil countryNameFromCountryCode:countryCode];
|
||||
// [self updateCountryWithName:countryName
|
||||
// callingCode:[NSString stringWithFormat:@"%@%@",
|
||||
// COUNTRY_CODE_PREFIX,
|
||||
// callingCode]
|
||||
// countryCode:countryCode];
|
||||
//}
|
||||
//
|
||||
//- (void)updateCountryWithName:(NSString *)countryName
|
||||
// callingCode:(NSString *)callingCode
|
||||
// countryCode:(NSString *)countryCode {
|
||||
// OWSAssertIsOnMainThread();
|
||||
// OWSAssert(countryName.length > 0);
|
||||
// OWSAssert(callingCode.length > 0);
|
||||
// OWSAssert(countryCode.length > 0);
|
||||
//
|
||||
// _countryCode = countryCode;
|
||||
// _callingCode = callingCode;
|
||||
//
|
||||
// NSString *title = [NSString stringWithFormat:@"%@ (%@)",
|
||||
// callingCode,
|
||||
// countryCode.uppercaseString];
|
||||
// self.countryCodeLabel.text = title;
|
||||
// [self.countryCodeLabel setNeedsLayout];
|
||||
//
|
||||
// self.examplePhoneNumberLabel.text =
|
||||
// [ViewControllerUtils examplePhoneNumberForCountryCode:countryCode callingCode:callingCode];
|
||||
// [self.examplePhoneNumberLabel setNeedsLayout];
|
||||
//}
|
||||
//
|
||||
//#pragma mark - Actions
|
||||
//
|
||||
//- (void)sendCodeAction
|
||||
//{
|
||||
// NSString *phoneNumberText = [_phoneNumberTextField.text ows_stripped];
|
||||
// if (phoneNumberText.length < 1) {
|
||||
// [OWSAlerts
|
||||
// showAlertWithTitle:NSLocalizedString(@"REGISTRATION_VIEW_NO_PHONE_NUMBER_ALERT_TITLE",
|
||||
// @"Title of alert indicating that users needs to enter a phone number to
|
||||
// register.")
|
||||
// message:
|
||||
// NSLocalizedString(@"REGISTRATION_VIEW_NO_PHONE_NUMBER_ALERT_MESSAGE",
|
||||
// @"Message of alert indicating that users needs to enter a phone number to register.")];
|
||||
// return;
|
||||
// }
|
||||
// NSString *countryCode = self.countryCode;
|
||||
// NSString *phoneNumber = [NSString stringWithFormat:@"%@%@", _callingCode, phoneNumberText];
|
||||
// PhoneNumber *localNumber = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:phoneNumber];
|
||||
// NSString *parsedPhoneNumber = localNumber.toE164;
|
||||
// if (parsedPhoneNumber.length < 1) {
|
||||
// [OWSAlerts showAlertWithTitle:
|
||||
// NSLocalizedString(@"REGISTRATION_VIEW_INVALID_PHONE_NUMBER_ALERT_TITLE",
|
||||
// @"Title of alert indicating that users needs to enter a valid phone number to register.")
|
||||
// message:NSLocalizedString(@"REGISTRATION_VIEW_INVALID_PHONE_NUMBER_ALERT_MESSAGE",
|
||||
// @"Message of alert indicating that users needs to enter a
|
||||
// valid phone number "
|
||||
// @"to register.")];
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// [self.activateButton setEnabled:NO];
|
||||
// [self.spinnerView startAnimating];
|
||||
// [self.phoneNumberTextField resignFirstResponder];
|
||||
//
|
||||
// __weak RegistrationViewController *weakSelf = self;
|
||||
// [TSAccountManager registerWithPhoneNumber:parsedPhoneNumber
|
||||
// success:^{
|
||||
// OWSProdInfo([OWSAnalyticsEvents registrationRegisteredPhoneNumber]);
|
||||
//
|
||||
// [weakSelf.spinnerView stopAnimating];
|
||||
//
|
||||
// CodeVerificationViewController *vc = [CodeVerificationViewController new];
|
||||
// [weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
//
|
||||
//#ifdef DEBUG
|
||||
// [weakSelf setLastRegisteredCountryCode:countryCode];
|
||||
// [weakSelf setLastRegisteredPhoneNumber:phoneNumberText];
|
||||
//#endif
|
||||
// }
|
||||
// failure:^(NSError *error) {
|
||||
// if (error.code == 400) {
|
||||
// [OWSAlerts showAlertWithTitle:NSLocalizedString(@"REGISTRATION_ERROR",
|
||||
// nil)
|
||||
// message:NSLocalizedString(@"REGISTRATION_NON_VALID_NUMBER",
|
||||
// nil)];
|
||||
// } else {
|
||||
// [OWSAlerts showAlertWithTitle:error.localizedDescription
|
||||
// message:error.localizedRecoverySuggestion];
|
||||
// }
|
||||
//
|
||||
// [weakSelf.activateButton setEnabled:YES];
|
||||
// [weakSelf.spinnerView stopAnimating];
|
||||
// [weakSelf.phoneNumberTextField becomeFirstResponder];
|
||||
// }
|
||||
// smsVerification:YES];
|
||||
//}
|
||||
//
|
||||
//- (void)countryCodeRowWasTapped:(UIGestureRecognizer *)sender
|
||||
//{
|
||||
// if (sender.state == UIGestureRecognizerStateRecognized) {
|
||||
// [self changeCountryCodeTapped];
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//- (void)changeCountryCodeTapped
|
||||
//{
|
||||
// CountryCodeViewController *countryCodeController = [CountryCodeViewController new];
|
||||
// countryCodeController.countryCodeDelegate = self;
|
||||
// UINavigationController *navigationController =
|
||||
// [[UINavigationController alloc] initWithRootViewController:countryCodeController];
|
||||
// [self presentViewController:navigationController animated:YES completion:[UIUtil modalCompletionBlock]];
|
||||
//}
|
||||
//
|
||||
//- (void)backgroundTapped:(UIGestureRecognizer *)sender
|
||||
//{
|
||||
// if (sender.state == UIGestureRecognizerStateRecognized) {
|
||||
// [self.phoneNumberTextField becomeFirstResponder];
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//#pragma mark - CountryCodeViewControllerDelegate
|
||||
//
|
||||
//- (void)countryCodeViewController:(CountryCodeViewController *)vc
|
||||
// didSelectCountryCode:(NSString *)countryCode
|
||||
// countryName:(NSString *)countryName
|
||||
// callingCode:(NSString *)callingCode
|
||||
//{
|
||||
// OWSAssert(countryCode.length > 0);
|
||||
// OWSAssert(countryName.length > 0);
|
||||
// OWSAssert(callingCode.length > 0);
|
||||
//
|
||||
// [self updateCountryWithName:countryName callingCode:callingCode countryCode:countryCode];
|
||||
//
|
||||
// // Trigger the formatting logic with a no-op edit.
|
||||
// [self textField:self.phoneNumberTextField shouldChangeCharactersInRange:NSMakeRange(0, 0) replacementString:@""];
|
||||
//}
|
||||
//
|
||||
//#pragma mark - Keyboard notifications
|
||||
//
|
||||
//- (void)initializeKeyboardHandlers {
|
||||
// UITapGestureRecognizer *outsideTabRecognizer =
|
||||
// [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboardFromAppropriateSubView)];
|
||||
// [self.view addGestureRecognizer:outsideTabRecognizer];
|
||||
//}
|
||||
//
|
||||
//- (void)dismissKeyboardFromAppropriateSubView {
|
||||
// [self.view endEditing:NO];
|
||||
//}
|
||||
//
|
||||
//#pragma mark - UITextFieldDelegate
|
||||
//
|
||||
//- (BOOL)textField:(UITextField *)textField
|
||||
// shouldChangeCharactersInRange:(NSRange)range
|
||||
// replacementString:(NSString *)insertionText {
|
||||
//
|
||||
// [ViewControllerUtils phoneNumberTextField:textField
|
||||
// shouldChangeCharactersInRange:range
|
||||
// replacementString:insertionText
|
||||
// countryCode:_callingCode];
|
||||
//
|
||||
// return NO; // inform our caller that we took care of performing the change
|
||||
//}
|
||||
//
|
||||
//- (BOOL)textFieldShouldReturn:(UITextField *)textField {
|
||||
// [self sendCodeAction];
|
||||
// [textField resignFirstResponder];
|
||||
// return NO;
|
||||
//}
|
||||
//
|
||||
//#pragma mark - Debug
|
||||
//
|
||||
//#ifdef DEBUG
|
||||
//
|
||||
//- (NSString *_Nullable)debugValueForKey:(NSString *)key
|
||||
//{
|
||||
// OWSCAssert([NSThread isMainThread]);
|
||||
// OWSCAssert(key.length > 0);
|
||||
//
|
||||
// NSError *error;
|
||||
// NSString *value = [SAMKeychain passwordForService:kKeychainService_LastRegistered account:key error:&error];
|
||||
// if (value && !error) {
|
||||
// return value;
|
||||
// }
|
||||
// return nil;
|
||||
//}
|
||||
//
|
||||
//- (void)setDebugValue:(NSString *)value forKey:(NSString *)key
|
||||
//{
|
||||
// OWSCAssert([NSThread isMainThread]);
|
||||
// OWSCAssert(key.length > 0);
|
||||
// OWSCAssert(value.length > 0);
|
||||
//
|
||||
// NSError *error;
|
||||
// [SAMKeychain setAccessibilityType:kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly];
|
||||
// BOOL success = [SAMKeychain setPassword:value forService:kKeychainService_LastRegistered account:key
|
||||
// error:&error]; if (!success || error) {
|
||||
// DDLogError(@"%@ Error persisting 'last registered' value in keychain: %@", self.logTag, error);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//- (NSString *_Nullable)lastRegisteredCountryCode
|
||||
//{
|
||||
// return [self debugValueForKey:kKeychainKey_LastRegisteredCountryCode];
|
||||
//}
|
||||
//
|
||||
//- (void)setLastRegisteredCountryCode:(NSString *)value
|
||||
//{
|
||||
// [self setDebugValue:value forKey:kKeychainKey_LastRegisteredCountryCode];
|
||||
//}
|
||||
//
|
||||
//- (NSString *_Nullable)lastRegisteredPhoneNumber
|
||||
//{
|
||||
// return [self debugValueForKey:kKeychainKey_LastRegisteredPhoneNumber];
|
||||
//}
|
||||
//
|
||||
//- (void)setLastRegisteredPhoneNumber:(NSString *)value
|
||||
//{
|
||||
// [self setDebugValue:value forKey:kKeychainKey_LastRegisteredPhoneNumber];
|
||||
//}
|
||||
//
|
||||
//#endif
|
||||
//
|
||||
//@end
|
||||
//
|
||||
// NS_ASSUME_NONNULL_END
|
|
@ -1,9 +1,9 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSQRCodeScanningViewController.h"
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <ZXingObjC/ZXingObjC.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSQRCodeScanningViewController.h"
|
||||
|
@ -149,16 +149,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}
|
||||
}
|
||||
|
||||
+ (NSString *)tag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@]", self.class];
|
||||
}
|
||||
|
||||
- (NSString *)tag
|
||||
{
|
||||
return self.class.logTag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSTableViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface PrivacySettingsTableViewController : OWSTableViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#import "PrivacySettingsTableViewController.h"
|
||||
#import "BlockListViewController.h"
|
||||
#import "OWS2FASettingsViewController.h"
|
||||
#import "Signal-Swift.h"
|
||||
#import <SignalMessaging/Environment.h>
|
||||
#import <SignalMessaging/OWSPreferences.h>
|
||||
|
@ -20,6 +21,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
self.title = NSLocalizedString(@"SETTINGS_PRIVACY_TITLE", @"");
|
||||
|
||||
[self updateTableContents];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self enable2FA];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
|
@ -128,10 +133,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[twoFactorAuthSection
|
||||
addItem:[OWSTableItem
|
||||
disclosureItemWithText:
|
||||
(is2FAEnabled ? NSLocalizedString(@"SETTINGS_TWO_FACTOR_AUTH_ENABLE",
|
||||
@"Label for the 'enable two factor auth' item of the privacy settings.")
|
||||
: NSLocalizedString(@"SETTINGS_TWO_FACTOR_AUTH_DISABLE",
|
||||
@"Label for the 'disable two factor auth' item of the privacy settings."))
|
||||
(is2FAEnabled ? NSLocalizedString(@"SETTINGS_TWO_FACTOR_AUTH_DISABLE",
|
||||
@"Label for the 'disable two factor auth' item of the privacy settings.")
|
||||
: NSLocalizedString(@"SETTINGS_TWO_FACTOR_AUTH_ENABLE",
|
||||
@"Label for the 'enable two factor auth' item of the privacy settings."))
|
||||
actionBlock:^{
|
||||
if (is2FAEnabled) {
|
||||
[weakSelf disable2FA];
|
||||
|
@ -141,11 +146,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}]];
|
||||
[contents addSection:twoFactorAuthSection];
|
||||
|
||||
OWS2FAManager
|
||||
.h
|
||||
|
||||
self.contents
|
||||
= contents;
|
||||
self.contents = contents;
|
||||
}
|
||||
|
||||
#pragma mark - Events
|
||||
|
@ -156,7 +157,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
|
||||
- (void)clearHistoryLogs
|
||||
{
|
||||
UIAlertController *alertController =
|
||||
|
@ -242,6 +242,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
- (void)enable2FA
|
||||
{
|
||||
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
||||
|
||||
OWS2FASettingsViewController *vc = [OWS2FASettingsViewController new];
|
||||
vc.mode = Enable2FAMode_Status;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)disable2FA
|
||||
|
@ -249,18 +253,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
#pragma mark - Log util
|
||||
|
||||
+ (NSString *)tag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@]", self.class];
|
||||
}
|
||||
|
||||
- (NSString *)tag
|
||||
{
|
||||
return self.class.logTag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class HomeViewController;
|
||||
|
||||
@interface ProfileViewController : UIViewController
|
||||
@interface ProfileViewController : OWSViewController
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSConversationSettingsViewDelegate.h"
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -484,14 +484,4 @@ NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId = @"PushManager
|
|||
});
|
||||
}
|
||||
|
||||
+ (NSString *)tag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@]", self.class];
|
||||
}
|
||||
|
||||
- (NSString *)tag
|
||||
{
|
||||
return self.class.logTag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSBezierPathView.h"
|
||||
|
@ -93,13 +93,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
#pragma mark - Logging
|
||||
|
||||
+ (NSString *)tag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@]", self.class];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -643,6 +643,45 @@
|
|||
/* No comment provided by engineer. */
|
||||
"EMPTY_INBOX_TITLE" = "Squeaky Freaking Clean.";
|
||||
|
||||
/* Text field placeholder for 'two factor auth pin' when confirming a pin. */
|
||||
"ENABLE_2FA_VIEW_CONFIRM_PIN_DEFAULT_TEXT" = "••••••";
|
||||
|
||||
/* Indicates that user should confirm their 'two factor auth pin'. */
|
||||
"ENABLE_2FA_VIEW_CONFIRM_PIN_INSTRUCTIONS" = "Confirm your PIN.";
|
||||
|
||||
/* Error indicating that attempt to disable 'two-factor auth' failed. */
|
||||
"ENABLE_2FA_VIEW_COULD_NOT_DISABLE_2FA" = "Could not disable two-step verification.";
|
||||
|
||||
/* Error indicating that attempt to enable 'two-factor auth' failed. */
|
||||
"ENABLE_2FA_VIEW_COULD_NOT_ENABLE_2FA" = "Could not enable two-step verification.";
|
||||
|
||||
/* Label for the 'enable two-factor auth' item in the settings view */
|
||||
"ENABLE_2FA_VIEW_DISABLE_2FA" = "Disable";
|
||||
|
||||
/* Label for the 'enable two-factor auth' item in the settings view */
|
||||
"ENABLE_2FA_VIEW_ENABLE_2FA" = "Enable";
|
||||
|
||||
/* Label for the 'next' button in the 'enable two factor auth' views. */
|
||||
"ENABLE_2FA_VIEW_NEXT_BUTTON" = "Next";
|
||||
|
||||
/* Error indicating that the entered 'two-factor auth PINs' do not match. */
|
||||
"ENABLE_2FA_VIEW_PIN_DOES_NOT_MATCH" = "Pin does not match.";
|
||||
|
||||
/* Text field placeholder for 'two factor auth pin' when selecting a pin. */
|
||||
"ENABLE_2FA_VIEW_SELECT_PIN_DEFAULT_TEXT" = "******";
|
||||
|
||||
/* Indicates that user should select a 'two factor auth pin'. */
|
||||
"ENABLE_2FA_VIEW_SELECT_PIN_INSTRUCTIONS" = "Enter a PIN which you'll be asked for when you register your phone number with Signal. Your PIN must have at least 4 digits.";
|
||||
|
||||
/* Indicates that user has 'two factor auth pin' disabled. */
|
||||
"ENABLE_2FA_VIEW_STATUS_DISABLED_INSTRUCTIONS" = "For added security, enable two-step verification, which will require a PIN when registering your phone number with Signal again.";
|
||||
|
||||
/* Indicates that user has 'two factor auth pin' enabled. */
|
||||
"ENABLE_2FA_VIEW_STATUS_ENABLED_INSTRUCTIONS" = "Two-step verification is enabled. You'll need to enter your PIN when registering your phone number with Signal again.";
|
||||
|
||||
/* Title for the 'enable two factor auth PIN' views. */
|
||||
"ENABLE_2FA_VIEW_TITLE" = "Two-Step Verification";
|
||||
|
||||
/* Call setup status label */
|
||||
"END_CALL_RESPONDER_IS_BUSY" = "Busy.";
|
||||
|
||||
|
@ -1359,7 +1398,9 @@
|
|||
/* Label for the country code field */
|
||||
"REGISTRATION_DEFAULT_COUNTRY_NAME" = "Country Code";
|
||||
|
||||
/* Placeholder text for the phone number textfield */
|
||||
/* Placeholder text
|
||||
// for the phone number textfield
|
||||
Placeholder text for the phone number textfield */
|
||||
"REGISTRATION_ENTERNUMBER_DEFAULT_TEXT" = "Enter Number";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
|
@ -1389,7 +1430,9 @@
|
|||
/* No comment provided by engineer. */
|
||||
"REGISTRATION_VERIFY_DEVICE" = "Activate This Device";
|
||||
|
||||
/* Message of alert indicating that users needs to enter a valid phone number to register. */
|
||||
/* Message of alert indicating that users needs to enter a
|
||||
// valid phone number to register.
|
||||
Message of alert indicating that users needs to enter a valid phone number to register. */
|
||||
"REGISTRATION_VIEW_INVALID_PHONE_NUMBER_ALERT_MESSAGE" = "Please enter a valid phone number to register.";
|
||||
|
||||
/* Title of alert indicating that users needs to enter a valid phone number to register. */
|
||||
|
@ -1398,7 +1441,9 @@
|
|||
/* Message of alert indicating that users needs to enter a phone number to register. */
|
||||
"REGISTRATION_VIEW_NO_PHONE_NUMBER_ALERT_MESSAGE" = "Please enter a phone number to register.";
|
||||
|
||||
/* Title of alert indicating that users needs to enter a phone number to register. */
|
||||
/* Title of alert indicating that users needs to enter a phone number to
|
||||
// register.
|
||||
Title of alert indicating that users needs to enter a phone number to register. */
|
||||
"REGISTRATION_VIEW_NO_PHONE_NUMBER_ALERT_TITLE" = "No Phone Number";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
|
@ -1623,6 +1668,15 @@
|
|||
/* No comment provided by engineer. */
|
||||
"SETTINGS_SUPPORT" = "Support";
|
||||
|
||||
/* Label for the 'disable two factor auth' item of the privacy settings. */
|
||||
"SETTINGS_TWO_FACTOR_AUTH_DISABLE" = "Disable Two-Step Verification";
|
||||
|
||||
/* Label for the 'enable two factor auth' item of the privacy settings. */
|
||||
"SETTINGS_TWO_FACTOR_AUTH_ENABLE" = "Enable Two-Step Verification";
|
||||
|
||||
/* Title for the 'two factor auth' section of the privacy settings. */
|
||||
"SETTINGS_TWO_FACTOR_AUTH_TITLE" = "Two-Step Verification";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"SETTINGS_VERSION" = "Version";
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import "UIView+OWS.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSViewController.h"
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
|
||||
@class TSThread;
|
||||
|
||||
|
|
|
@ -381,23 +381,11 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
|
|||
|
||||
- (void)unsetRecordedAPNSTokens
|
||||
{
|
||||
DDLogWarn(@"%@ Forgetting recorded APNS tokens", self.tag);
|
||||
DDLogWarn(@"%@ Forgetting recorded APNS tokens", self.logTag);
|
||||
[self setValueForKey:OWSPreferencesKeyLastRecordedPushToken toValue:nil];
|
||||
[self setValueForKey:OWSPreferencesKeyLastRecordedVoipToken toValue:nil];
|
||||
}
|
||||
|
||||
#pragma mark - Logging
|
||||
|
||||
+ (NSString *)tag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@]", self.class];
|
||||
}
|
||||
|
||||
- (NSString *)tag
|
||||
{
|
||||
return self.class.tag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -215,18 +215,6 @@ NSString *const OWSMessageContentJobFinderExtensionGroup = @"OWSMessageContentJo
|
|||
[storage asyncRegisterExtension:[self databaseExtension] withName:OWSMessageContentJobFinderExtensionName];
|
||||
}
|
||||
|
||||
#pragma mark Logging
|
||||
|
||||
+ (NSString *)tag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@]", self.class];
|
||||
}
|
||||
|
||||
- (NSString *)tag
|
||||
{
|
||||
return self.class.logTag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - Queue Processing
|
||||
|
@ -365,18 +353,6 @@ NSString *const OWSMessageContentJobFinderExtensionGroup = @"OWSMessageContentJo
|
|||
}];
|
||||
}
|
||||
|
||||
#pragma mark Logging
|
||||
|
||||
+ (NSString *)tag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@]", self.class];
|
||||
}
|
||||
|
||||
- (NSString *)tag
|
||||
{
|
||||
return self.class.logTag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - OWSBatchMessageProcessor
|
||||
|
|
|
@ -339,18 +339,6 @@ NSString *const OWSMessageDecryptJobFinderExtensionGroup = @"OWSMessageProcessin
|
|||
}];
|
||||
}
|
||||
|
||||
#pragma mark Logging
|
||||
|
||||
+ (NSString *)tag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@]", self.class];
|
||||
}
|
||||
|
||||
- (NSString *)tag
|
||||
{
|
||||
return self.class.logTag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - OWSMessageReceiver
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSFingerprint.h"
|
||||
|
@ -309,16 +309,6 @@ static uint32_t const OWSFingerprintDefaultHashIterations = 5200;
|
|||
return qrImage;
|
||||
}
|
||||
|
||||
+ (NSString *)tag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@]", self.class];
|
||||
}
|
||||
|
||||
- (NSString *)tag
|
||||
{
|
||||
return self.class.logTag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -101,16 +101,4 @@
|
|||
return lastPreKeyId;
|
||||
}
|
||||
|
||||
#pragma mark - Logging
|
||||
|
||||
+ (NSString *)tag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@+PreKeyStore]", self.class];
|
||||
}
|
||||
|
||||
- (NSString *)tag
|
||||
{
|
||||
return self.class.logTag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -16,9 +16,11 @@ typedef void (^OWS2FAFailure)(NSError *error);
|
|||
|
||||
- (BOOL)is2FAEnabled;
|
||||
|
||||
- (void)enable2FAWithPin:(NSString *)pin success:(OWS2FASuccess)success failure:(OWS2FAFailure)failure;
|
||||
- (void)enable2FAWithPin:(NSString *)pin
|
||||
success:(nullable OWS2FASuccess)success
|
||||
failure:(nullable OWS2FAFailure)failure;
|
||||
|
||||
- (void)disable2FAWithSuccess:(OWS2FASuccess)success failure:(OWS2FAFailure)failure;
|
||||
- (void)disable2FAWithSuccess:(nullable OWS2FASuccess)success failure:(nullable OWS2FAFailure)failure;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -69,7 +69,12 @@ NSString *const kOWS2FAManager_IsEnabledKey = @"kOWS2FAManager_IsEnabledKey";
|
|||
defaultValue:NO];
|
||||
}
|
||||
|
||||
- (void)enable2FAWithPin:(NSString *)pin success:(OWS2FASuccess)success failure:(OWS2FAFailure)failure
|
||||
- (void)setIs2FAEnabled:(BOOL)value
|
||||
{
|
||||
[self.dbConnection setBool:value forKey:kOWS2FAManager_IsEnabledKey inCollection:kOWS2FAManager_Collection];
|
||||
}
|
||||
|
||||
- (void)enable2FAWithPin:(NSString *)pin success:(nullable OWS2FASuccess)success failure:(nullable OWS2FAFailure)failure
|
||||
{
|
||||
OWSAssert(pin.length > 0);
|
||||
OWSAssert(success);
|
||||
|
@ -78,25 +83,42 @@ NSString *const kOWS2FAManager_IsEnabledKey = @"kOWS2FAManager_IsEnabledKey";
|
|||
TSRequest *request = [OWSRequestFactory enable2FARequestWithPin:pin];
|
||||
[self.networkManager makeRequest:request
|
||||
success:^(NSURLSessionDataTask *task, id responseObject) {
|
||||
success();
|
||||
OWSAssertIsOnMainThread();
|
||||
|
||||
[self setIs2FAEnabled:YES];
|
||||
|
||||
if (success) {
|
||||
success();
|
||||
}
|
||||
}
|
||||
failure:^(NSURLSessionDataTask *task, NSError *error) {
|
||||
failure(error);
|
||||
OWSAssertIsOnMainThread();
|
||||
|
||||
if (failure) {
|
||||
failure(error);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)disable2FAWithSuccess:(OWS2FASuccess)success failure:(OWS2FAFailure)failure
|
||||
- (void)disable2FAWithSuccess:(nullable OWS2FASuccess)success failure:(nullable OWS2FAFailure)failure
|
||||
{
|
||||
OWSAssert(success);
|
||||
OWSAssert(failure);
|
||||
|
||||
TSRequest *request = [OWSRequestFactory disable2FARequest];
|
||||
[self.networkManager makeRequest:request
|
||||
success:^(NSURLSessionDataTask *task, id responseObject) {
|
||||
success();
|
||||
OWSAssertIsOnMainThread();
|
||||
|
||||
[self setIs2FAEnabled:NO];
|
||||
|
||||
if (success) {
|
||||
success();
|
||||
}
|
||||
}
|
||||
failure:^(NSURLSessionDataTask *task, NSError *error) {
|
||||
failure(error);
|
||||
OWSAssertIsOnMainThread();
|
||||
|
||||
if (failure) {
|
||||
failure(error);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue