From 4577d574e2cf6394913a3f30743bf678f06976ca Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Tue, 19 Nov 2019 10:05:20 +1100 Subject: [PATCH 1/7] Update version number --- Signal.xcodeproj/project.pbxproj | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index da4d2b673..7429af9b2 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -4088,7 +4088,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 21; + CURRENT_PROJECT_VERSION = 22; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -4102,7 +4102,7 @@ INFOPLIST_FILE = SignalShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.0; + MARKETING_VERSION = 1.5.0; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -4150,7 +4150,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 21; + CURRENT_PROJECT_VERSION = 22; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -4169,7 +4169,7 @@ INFOPLIST_FILE = SignalShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.0; + MARKETING_VERSION = 1.5.0; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -4223,7 +4223,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.4.0; + MARKETING_VERSION = 1.5.0; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -4297,7 +4297,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.4.0; + MARKETING_VERSION = 1.5.0; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -4482,7 +4482,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 21; + CURRENT_PROJECT_VERSION = 22; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4517,7 +4517,7 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - MARKETING_VERSION = 1.4.0; + MARKETING_VERSION = 1.5.0; OTHER_LDFLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; PRODUCT_NAME = "Loki Messenger"; @@ -4549,7 +4549,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 21; + CURRENT_PROJECT_VERSION = 22; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4584,7 +4584,7 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - MARKETING_VERSION = 1.4.0; + MARKETING_VERSION = 1.5.0; OTHER_LDFLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; PRODUCT_NAME = "Loki Messenger"; From 4afeba866b8bf8d27f39d89a5a3234bd3f65beca Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Tue, 19 Nov 2019 14:35:38 +1100 Subject: [PATCH 2/7] Convert ScanQRCodeVC to Swift --- Signal.xcodeproj/project.pbxproj | 10 ++- .../Loki/Messaging/NewConversationVC.swift | 6 +- Signal/src/Loki/Messaging/ScanQRCodeVC.h | 12 ---- Signal/src/Loki/Messaging/ScanQRCodeVC.m | 62 ------------------- Signal/src/Loki/Messaging/ScanQRCodeVC.swift | 50 +++++++++++++++ Signal/src/Signal-Bridging-Header.h | 2 +- 6 files changed, 58 insertions(+), 84 deletions(-) delete mode 100644 Signal/src/Loki/Messaging/ScanQRCodeVC.h delete mode 100644 Signal/src/Loki/Messaging/ScanQRCodeVC.m create mode 100644 Signal/src/Loki/Messaging/ScanQRCodeVC.swift diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 7429af9b2..7d31ab871 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -564,7 +564,6 @@ B8162F0522892C5F00D46544 /* FriendRequestViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8162F0422892C5F00D46544 /* FriendRequestViewDelegate.swift */; }; B821F2F82272CED3002C88C0 /* DisplayNameVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B821F2F72272CED3002C88C0 /* DisplayNameVC.swift */; }; B821F2FA2272CEEE002C88C0 /* SeedVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B821F2F92272CEEE002C88C0 /* SeedVC.swift */; }; - B8258493230FA5E9001B41CB /* ScanQRCodeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = B8258492230FA5E9001B41CB /* ScanQRCodeVC.m */; }; B82584A02315024B001B41CB /* LokiRSSFeedPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = B825849F2315024B001B41CB /* LokiRSSFeedPoller.swift */; }; B846365B22B7418B00AF1514 /* Identicon+ObjC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B846365A22B7418B00AF1514 /* Identicon+ObjC.swift */; }; B84664F5235022F30083A1CD /* MentionUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = B84664F4235022F30083A1CD /* MentionUtilities.swift */; }; @@ -576,6 +575,7 @@ B891105C2320872800F15FCC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B891105B2320872800F15FCC /* GoogleService-Info.plist */; }; B891105E2320872800F15FCC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B891105B2320872800F15FCC /* GoogleService-Info.plist */; }; B891105F2320872800F15FCC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B891105B2320872800F15FCC /* GoogleService-Info.plist */; }; + B893063F2383961A005EAA8E /* ScanQRCodeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B893063E2383961A005EAA8E /* ScanQRCodeVC.swift */; }; B894D0712339D6F300B4D94D /* DeviceLinkingModalDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B894D0702339D6F300B4D94D /* DeviceLinkingModalDelegate.swift */; }; B894D0752339EDCF00B4D94D /* NukeDataModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = B894D0742339EDCF00B4D94D /* NukeDataModal.swift */; }; B89841E322B7579F00B1BDC6 /* NewConversationVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B89841E222B7579F00B1BDC6 /* NewConversationVC.swift */; }; @@ -1375,8 +1375,6 @@ B8162F0422892C5F00D46544 /* FriendRequestViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendRequestViewDelegate.swift; sourceTree = ""; }; B821F2F72272CED3002C88C0 /* DisplayNameVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayNameVC.swift; sourceTree = ""; }; B821F2F92272CEEE002C88C0 /* SeedVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedVC.swift; sourceTree = ""; }; - B8258491230FA5DA001B41CB /* ScanQRCodeVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScanQRCodeVC.h; sourceTree = ""; }; - B8258492230FA5E9001B41CB /* ScanQRCodeVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScanQRCodeVC.m; sourceTree = ""; }; B825849F2315024B001B41CB /* LokiRSSFeedPoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LokiRSSFeedPoller.swift; sourceTree = ""; }; B846365A22B7418B00AF1514 /* Identicon+ObjC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Identicon+ObjC.swift"; sourceTree = ""; }; B84664F4235022F30083A1CD /* MentionUtilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MentionUtilities.swift; sourceTree = ""; }; @@ -1386,6 +1384,7 @@ B885D5F3233491AB00EE0D8E /* DeviceLinkingModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceLinkingModal.swift; sourceTree = ""; }; B885D5F52334A32100EE0D8E /* UIView+Constraint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Constraint.swift"; sourceTree = ""; }; B891105B2320872800F15FCC /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; + B893063E2383961A005EAA8E /* ScanQRCodeVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanQRCodeVC.swift; sourceTree = ""; }; B894D0702339D6F300B4D94D /* DeviceLinkingModalDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceLinkingModalDelegate.swift; sourceTree = ""; }; B894D0742339EDCF00B4D94D /* NukeDataModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NukeDataModal.swift; sourceTree = ""; }; B89841E222B7579F00B1BDC6 /* NewConversationVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewConversationVC.swift; sourceTree = ""; }; @@ -2708,8 +2707,7 @@ B8B26C90234D8CBD004ED98C /* MentionCandidateSelectionViewDelegate.swift */, B89841E222B7579F00B1BDC6 /* NewConversationVC.swift */, 24BD2608234DA2050008EB0A /* NewPublicChatVC.swift */, - B8258491230FA5DA001B41CB /* ScanQRCodeVC.h */, - B8258492230FA5E9001B41CB /* ScanQRCodeVC.m */, + B893063E2383961A005EAA8E /* ScanQRCodeVC.swift */, ); path = Messaging; sourceTree = ""; @@ -3734,6 +3732,7 @@ 34D99C931F2937CC00D284D6 /* OWSAnalytics.swift in Sources */, 340FC8B8204DAC8D007AEB0F /* AddToGroupViewController.m in Sources */, 341F2C0F1F2B8AE700D07D6B /* DebugUIMisc.m in Sources */, + B893063F2383961A005EAA8E /* ScanQRCodeVC.swift in Sources */, 340FC8AF204DAC8D007AEB0F /* OWSLinkDeviceViewController.m in Sources */, 34E3EF0D1EFC235B007F6822 /* DebugUIDiskUsage.m in Sources */, 454A84042059C787008B8C75 /* MediaTileViewController.swift in Sources */, @@ -3930,7 +3929,6 @@ B86BD08423399ACF000F5AE3 /* Modal.swift in Sources */, 34D1F0861F8678AA0066283D /* ConversationViewController.m in Sources */, 3427C64320F500E000EEC730 /* OWSMessageTimerView.m in Sources */, - B8258493230FA5E9001B41CB /* ScanQRCodeVC.m in Sources */, B90418E6183E9DD40038554A /* DateUtil.m in Sources */, 3448E15E221333F5004B052E /* OnboardingController.swift in Sources */, 340FC8BD204DAC8D007AEB0F /* ShowGroupMembersViewController.m in Sources */, diff --git a/Signal/src/Loki/Messaging/NewConversationVC.swift b/Signal/src/Loki/Messaging/NewConversationVC.swift index ba63e612d..7fed92b34 100644 --- a/Signal/src/Loki/Messaging/NewConversationVC.swift +++ b/Signal/src/Loki/Messaging/NewConversationVC.swift @@ -81,9 +81,9 @@ final class NewConversationVC : OWSViewController, OWSQRScannerDelegate { @objc private func scanQRCode() { ows_ask(forCameraPermissions: { [weak self] hasCameraAccess in if hasCameraAccess { - let scanQRCodeVC = ScanQRCodeVC() - scanQRCodeVC.delegate = self - self?.navigationController!.pushViewController(scanQRCodeVC, animated: true) + let scanQRCodeWrapperVC = ScanQRCodeWrapperVC() + scanQRCodeWrapperVC.delegate = self + self?.navigationController!.pushViewController(scanQRCodeWrapperVC, animated: true) } else { // Do nothing } diff --git a/Signal/src/Loki/Messaging/ScanQRCodeVC.h b/Signal/src/Loki/Messaging/ScanQRCodeVC.h deleted file mode 100644 index c4a50a564..000000000 --- a/Signal/src/Loki/Messaging/ScanQRCodeVC.h +++ /dev/null @@ -1,12 +0,0 @@ -#import -#import "OWSQRCodeScanningViewController.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface ScanQRCodeVC : OWSViewController - -@property (nonatomic, weak) UIViewController *delegate; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Signal/src/Loki/Messaging/ScanQRCodeVC.m b/Signal/src/Loki/Messaging/ScanQRCodeVC.m deleted file mode 100644 index c035dd0e3..000000000 --- a/Signal/src/Loki/Messaging/ScanQRCodeVC.m +++ /dev/null @@ -1,62 +0,0 @@ -#import "ScanQRCodeVC.h" -#import "Session-Swift.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface ScanQRCodeVC () - -@property (nonatomic) OWSQRCodeScanningViewController *qrCodeScanningVC; - -@end - -@implementation ScanQRCodeVC - -- (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } - -- (void)viewDidLoad -{ - [super viewDidLoad]; - // Background color - self.view.backgroundColor = Theme.backgroundColor; - // QR code scanning VC - self.qrCodeScanningVC = [OWSQRCodeScanningViewController new]; - self.qrCodeScanningVC.scanDelegate = self.delegate; - [self.view addSubview:self.qrCodeScanningVC.view]; - [self.qrCodeScanningVC.view autoPinEdgeToSuperviewEdge:ALEdgeLeading]; - [self.qrCodeScanningVC.view autoPinEdgeToSuperviewEdge:ALEdgeTrailing]; - [self.qrCodeScanningVC.view autoPinToTopLayoutGuideOfViewController:self withInset:0.0]; - [self.qrCodeScanningVC.view autoPinToSquareAspectRatio]; - // Explanation label - UILabel *explanationLabel = [UILabel new]; - explanationLabel.text = NSLocalizedString(@"Scan the QR code of the person you'd like to securely message. They can find their QR code by going into Loki Messenger's in-app settings and clicking \"Show QR Code\".", @""); - explanationLabel.textColor = Theme.primaryColor; - explanationLabel.font = UIFont.ows_dynamicTypeSubheadlineClampedFont; - explanationLabel.numberOfLines = 0; - explanationLabel.lineBreakMode = NSLineBreakByWordWrapping; - explanationLabel.textAlignment = NSTextAlignmentCenter; - // Bottom view - UIView *bottomView = [UIView new]; - [self.view addSubview:bottomView]; - [bottomView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.qrCodeScanningVC.view]; - [bottomView autoPinEdgeToSuperviewEdge:ALEdgeLeading]; - [bottomView autoPinEdgeToSuperviewEdge:ALEdgeTrailing]; - [bottomView autoPinEdgeToSuperviewEdge:ALEdgeBottom]; - [bottomView addSubview:explanationLabel]; - [explanationLabel autoPinWidthToSuperviewWithMargin:32]; - [explanationLabel autoPinHeightToSuperviewWithMargin:32]; - // Title - self.title = NSLocalizedString(@"Scan QR Code", ""); -} - -- (void)viewDidAppear:(BOOL)animated -{ - [super viewDidAppear:animated]; - [UIDevice.currentDevice ows_setOrientation:UIInterfaceOrientationPortrait]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self.qrCodeScanningVC startCapture]; - }); -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/Signal/src/Loki/Messaging/ScanQRCodeVC.swift b/Signal/src/Loki/Messaging/ScanQRCodeVC.swift new file mode 100644 index 000000000..1db307b45 --- /dev/null +++ b/Signal/src/Loki/Messaging/ScanQRCodeVC.swift @@ -0,0 +1,50 @@ + +final class ScanQRCodeWrapperVC : UIViewController { + var delegate: (UIViewController & OWSQRScannerDelegate)? = nil + private let scanQRCodeVC = OWSQRCodeScanningViewController() + + // MARK: Settings + override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .portrait } + + // MARK: Lifecycle + override func viewDidLoad() { + // Background color + view.backgroundColor = Theme.backgroundColor + // Scan QR code VC + scanQRCodeVC.scanDelegate = delegate + let scanQRCodeVCView = scanQRCodeVC.view! + view.addSubview(scanQRCodeVCView) + scanQRCodeVCView.pin(.leading, to: .leading, of: view) + scanQRCodeVCView.pin(.trailing, to: .trailing, of: view) + scanQRCodeVCView.autoPin(toTopLayoutGuideOf: self, withInset: 0) + scanQRCodeVCView.autoPinToSquareAspectRatio() + // Bottom view + let bottomView = UIView() + view.addSubview(bottomView) + bottomView.pin(.top, to: .bottom, of: scanQRCodeVCView) + bottomView.pin(.leading, to: .leading, of: view) + bottomView.pin(.trailing, to: .trailing, of: view) + bottomView.pin(.bottom, to: .bottom, of: view) + // Explanation label + let explanationLabel = UILabel() + explanationLabel.text = NSLocalizedString("Scan the QR code of the person you'd like to securely message. They can find their QR code by going into Loki Messenger's in-app settings and clicking \"Show QR Code\".", comment: "") + explanationLabel.textColor = Theme.primaryColor + explanationLabel.font = .ows_dynamicTypeSubheadlineClamped + explanationLabel.numberOfLines = 0 + explanationLabel.lineBreakMode = .byWordWrapping + explanationLabel.textAlignment = .center + bottomView.addSubview(explanationLabel) + explanationLabel.autoPinWidthToSuperview(withMargin: 32) + explanationLabel.autoPinHeightToSuperview(withMargin: 32) + // Title + title = NSLocalizedString("Scan QR Code", comment: "") + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + UIDevice.current.ows_setOrientation(.portrait) + DispatchQueue.main.async { [weak self] in + self?.scanQRCodeVC.startCapture() + } + } +} diff --git a/Signal/src/Signal-Bridging-Header.h b/Signal/src/Signal-Bridging-Header.h index 4e2f57b67..90a923fac 100644 --- a/Signal/src/Signal-Bridging-Header.h +++ b/Signal/src/Signal-Bridging-Header.h @@ -44,7 +44,7 @@ #import "PrivacySettingsTableViewController.h" #import "ProfileViewController.h" #import "RemoteVideoView.h" -#import "ScanQRCodeVC.h" +#import "OWSQRCodeScanningViewController.h" #import "SignalApp.h" #import "UIViewController+Permissions.h" #import "ViewControllerUtils.h" From ade1fc32391dc5d13e38523c8f3b77e12f91c974 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Tue, 19 Nov 2019 14:41:56 +1100 Subject: [PATCH 3/7] Update ScanQRCodeWrapperVC for multi device QR code scanning --- .../src/Loki/Messaging/NewConversationVC.swift | 3 ++- Signal/src/Loki/Messaging/ScanQRCodeVC.swift | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Signal/src/Loki/Messaging/NewConversationVC.swift b/Signal/src/Loki/Messaging/NewConversationVC.swift index 7fed92b34..b8080c125 100644 --- a/Signal/src/Loki/Messaging/NewConversationVC.swift +++ b/Signal/src/Loki/Messaging/NewConversationVC.swift @@ -81,7 +81,8 @@ final class NewConversationVC : OWSViewController, OWSQRScannerDelegate { @objc private func scanQRCode() { ows_ask(forCameraPermissions: { [weak self] hasCameraAccess in if hasCameraAccess { - let scanQRCodeWrapperVC = ScanQRCodeWrapperVC() + let message = NSLocalizedString("Scan the QR code of the person you'd like to securely message. They can find their QR code by going into Loki Messenger's in-app settings and clicking \"Show QR Code\".", comment: "") + let scanQRCodeWrapperVC = ScanQRCodeWrapperVC(message: message) scanQRCodeWrapperVC.delegate = self self?.navigationController!.pushViewController(scanQRCodeWrapperVC, animated: true) } else { diff --git a/Signal/src/Loki/Messaging/ScanQRCodeVC.swift b/Signal/src/Loki/Messaging/ScanQRCodeVC.swift index 1db307b45..5e56e4988 100644 --- a/Signal/src/Loki/Messaging/ScanQRCodeVC.swift +++ b/Signal/src/Loki/Messaging/ScanQRCodeVC.swift @@ -1,12 +1,26 @@ final class ScanQRCodeWrapperVC : UIViewController { var delegate: (UIViewController & OWSQRScannerDelegate)? = nil + private let message: String private let scanQRCodeVC = OWSQRCodeScanningViewController() // MARK: Settings override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .portrait } // MARK: Lifecycle + init(message: String) { + self.message = message + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + preconditionFailure("Use init(title:) instead.") + } + + override init(nibName: String?, bundle: Bundle?) { + preconditionFailure("Use init(title:) instead.") + } + override func viewDidLoad() { // Background color view.backgroundColor = Theme.backgroundColor @@ -27,7 +41,7 @@ final class ScanQRCodeWrapperVC : UIViewController { bottomView.pin(.bottom, to: .bottom, of: view) // Explanation label let explanationLabel = UILabel() - explanationLabel.text = NSLocalizedString("Scan the QR code of the person you'd like to securely message. They can find their QR code by going into Loki Messenger's in-app settings and clicking \"Show QR Code\".", comment: "") + explanationLabel.text = message explanationLabel.textColor = Theme.primaryColor explanationLabel.font = .ows_dynamicTypeSubheadlineClamped explanationLabel.numberOfLines = 0 From b607df0c4e3678795e39398ffdb2afedd6bf2c58 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Tue, 19 Nov 2019 15:45:08 +1100 Subject: [PATCH 4/7] Update SeedVC for multi device QR code scanning --- Signal/src/Loki/Onboarding/SeedVC.swift | 177 ++++++------------ Signal/src/Loki/Settings/SeedModal.swift | 2 +- .../OnboardingSplashViewController.swift | 5 +- .../translations/en.lproj/Localizable.strings | 8 +- 4 files changed, 69 insertions(+), 123 deletions(-) diff --git a/Signal/src/Loki/Onboarding/SeedVC.swift b/Signal/src/Loki/Onboarding/SeedVC.swift index 89db696e6..a78a0f2ec 100644 --- a/Signal/src/Loki/Onboarding/SeedVC.swift +++ b/Signal/src/Loki/Onboarding/SeedVC.swift @@ -1,21 +1,19 @@ -// TODO: Split this into multiple VCs - -final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate { +final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate, OWSQRScannerDelegate { private var mode: Mode = .register { didSet { if mode != oldValue { handleModeChanged() } } } private var seed: Data! { didSet { updateMnemonic() } } private var mnemonic: String! { didSet { handleMnemonicChanged() } } // MARK: Components private lazy var registerStackView: UIStackView = { - let result = UIStackView(arrangedSubviews: [ explanationLabel1, UIView.spacer(withHeight: 32), mnemonicLabel, UIView.spacer(withHeight: 24), copyButton, restoreButton1, linkButton1 ]) + let result = UIStackView(arrangedSubviews: [ explanationLabel1, UIView.spacer(withHeight: 32), mnemonicLabel, UIView.spacer(withHeight: 24), copyButton, restoreButton, linkButton1 ]) result.accessibilityIdentifier = "onboarding.keyPairStep.registerStackView" result.axis = .vertical return result }() private lazy var explanationLabel1: UILabel = { - let result = createExplanationLabel(text: NSLocalizedString("Please save the seed below in a safe location. It can be used to restore your account if you lose access, or to migrate to a new device.", comment: "")) + let result = createExplanationLabel(text: NSLocalizedString("Please save the seed below in a safe location. It can be used to restore your account if you lose access, or to migrate your account to a new device.", comment: "")) result.accessibilityIdentifier = "onboarding.keyPairStep.explanationLabel1" result.textColor = Theme.primaryColor var fontTraits = result.font.fontDescriptor.symbolicTraits @@ -41,22 +39,22 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate { return result }() - private lazy var restoreButton1: OWSFlatButton = { + private lazy var restoreButton: OWSFlatButton = { let result = createLinkButton(title: NSLocalizedString("Restore Using Seed", comment: ""), selector: #selector(handleSwitchModeButton1Tapped)) - result.accessibilityIdentifier = "onboarding.keyPairStep.restoreButton1" + result.accessibilityIdentifier = "onboarding.keyPairStep.restoreButton" result.setBackgroundColors(upColor: .clear, downColor: .clear) return result }() private lazy var linkButton1: OWSFlatButton = { - let result = createLinkButton(title: NSLocalizedString("Link Device", comment: ""), selector: #selector(handleSwitchModeButton2Tapped)) + let result = createLinkButton(title: NSLocalizedString("Link Device", comment: ""), selector: #selector(handleLinkButtonTapped)) result.accessibilityIdentifier = "onboarding.keyPairStep.linkButton1" result.setBackgroundColors(upColor: .clear, downColor: .clear) return result }() private lazy var restoreStackView: UIStackView = { - let result = UIStackView(arrangedSubviews: [ explanationLabel2, UIView.spacer(withHeight: 32), errorLabel1, errorLabel1Spacer, mnemonicTextField, UIView.spacer(withHeight: 24), registerButton1, linkButton2 ]) + let result = UIStackView(arrangedSubviews: [ explanationLabel2, UIView.spacer(withHeight: 32), errorLabel, errorLabelSpacer, mnemonicTextField, UIView.spacer(withHeight: 24), registerButton, linkButton2 ]) result.accessibilityIdentifier = "onboarding.keyPairStep.restoreStackView" result.axis = .vertical return result @@ -72,9 +70,9 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate { return result }() - private lazy var errorLabel1: UILabel = { + private lazy var errorLabel: UILabel = { let result = createExplanationLabel(text: "") - result.accessibilityIdentifier = "onboarding.keyPairStep.errorLabel1" + result.accessibilityIdentifier = "onboarding.keyPairStep.errorLabel" result.textColor = UIColor.red var fontTraits = result.font.fontDescriptor.symbolicTraits fontTraits.insert(.traitBold) @@ -82,7 +80,7 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate { return result }() - private lazy var errorLabel1Spacer: UIView = { + private lazy var errorLabelSpacer: UIView = { let result = UIView.spacer(withHeight: 32) result.isHidden = true return result @@ -102,90 +100,28 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate { return result }() - private lazy var registerButton1: OWSFlatButton = { + private lazy var registerButton: OWSFlatButton = { let result = createLinkButton(title: NSLocalizedString("Register a New Account", comment: ""), selector: #selector(handleSwitchModeButton1Tapped)) - result.accessibilityIdentifier = "onboarding.keyPairStep.registerButton1" + result.accessibilityIdentifier = "onboarding.keyPairStep.registerButton" result.setBackgroundColors(upColor: .clear, downColor: .clear) return result }() private lazy var linkButton2: OWSFlatButton = { - let result = createLinkButton(title: NSLocalizedString("Link Device", comment: ""), selector: #selector(handleSwitchModeButton2Tapped)) + let result = createLinkButton(title: NSLocalizedString("Link Device", comment: ""), selector: #selector(handleLinkButtonTapped)) result.accessibilityIdentifier = "onboarding.keyPairStep.linkButton2" result.setBackgroundColors(upColor: .clear, downColor: .clear) return result }() - private lazy var linkStackView: UIStackView = { - let result = UIStackView(arrangedSubviews: [ explanationLabel3, UIView.spacer(withHeight: 32), errorLabel2, errorLabel2Spacer, masterHexEncodedPublicKeyTextField, UIView.spacer(withHeight: 24), registerButton2, restoreButton2 ]) - result.accessibilityIdentifier = "onboarding.keyPairStep.linkStackView" - result.axis = .vertical - return result - }() - - private lazy var explanationLabel3: UILabel = { - let result = createExplanationLabel(text: NSLocalizedString("Link to an existing device by going into its in-app settings and clicking \"Link Device\".", comment: "")) - result.accessibilityIdentifier = "onboarding.keyPairStep.explanationLabel3" - result.textColor = Theme.primaryColor - var fontTraits = result.font.fontDescriptor.symbolicTraits - fontTraits.insert(.traitBold) - result.font = UIFont(descriptor: result.font.fontDescriptor.withSymbolicTraits(fontTraits)!, size: result.font.pointSize) - return result - }() - - private lazy var errorLabel2: UILabel = { - let result = createExplanationLabel(text: "") - result.accessibilityIdentifier = "onboarding.keyPairStep.errorLabel2" - result.textColor = UIColor.red - var fontTraits = result.font.fontDescriptor.symbolicTraits - fontTraits.insert(.traitBold) - result.font = UIFont(descriptor: result.font.fontDescriptor.withSymbolicTraits(fontTraits)!, size: 12) - return result - }() - - private lazy var errorLabel2Spacer: UIView = { - let result = UIView.spacer(withHeight: 32) - result.isHidden = true - return result - }() - - private lazy var masterHexEncodedPublicKeyTextField: UITextField = { - let result = UITextField(frame: CGRect.zero) - result.textColor = Theme.primaryColor - result.font = UIFont.ows_dynamicTypeBodyClamped - result.textAlignment = .center - let placeholder = NSMutableAttributedString(string: NSLocalizedString("Enter the Other Device's Public Key", comment: "")) - placeholder.addAttribute(.foregroundColor, value: Theme.placeholderColor, range: NSRange(location: 0, length: placeholder.length)) - result.attributedPlaceholder = placeholder - result.tintColor = UIColor.lokiGreen() - result.accessibilityIdentifier = "onboarding.keyPairStep.masterHexEncodedPublicKeyTextField" - result.keyboardAppearance = .dark - return result - }() - - private lazy var registerButton2: OWSFlatButton = { - let result = createLinkButton(title: NSLocalizedString("Register a New Account", comment: ""), selector: #selector(handleSwitchModeButton1Tapped)) - result.accessibilityIdentifier = "onboarding.keyPairStep.registerButton2" - result.setBackgroundColors(upColor: .clear, downColor: .clear) - return result - }() - - private lazy var restoreButton2: OWSFlatButton = { - let result = createLinkButton(title: NSLocalizedString("Restore Using Seed", comment: ""), selector: #selector(handleSwitchModeButton2Tapped)) - result.accessibilityIdentifier = "onboarding.keyPairStep.restoreButton2" - result.setBackgroundColors(upColor: .clear, downColor: .clear) - return result - }() - - // Shared private lazy var mainButton: OWSFlatButton = { - let result = createButton(title: "", selector: #selector(handleMainButtonTapped)) + let result = createButton(title: "", selector: #selector(proceed(with:))) result.accessibilityIdentifier = "onboarding.keyPairStep.mainButton" return result }() // MARK: Types - enum Mode { case register, restore, link } + enum Mode { case register, restore } // MARK: Lifecycle override func viewDidLoad() { @@ -207,7 +143,6 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate { let mainView = UIView(frame: CGRect.zero) mainView.addSubview(restoreStackView) mainView.addSubview(registerStackView) - mainView.addSubview(linkStackView) let mainStackView = UIStackView(arrangedSubviews: [ titleLabel, mainView, mainButton ]) mainStackView.axis = .vertical mainStackView.layoutMargins = UIEdgeInsets(top: 32, left: 32, bottom: 32, right: 32) @@ -221,8 +156,6 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate { registerStackView.autoVCenterInSuperview() restoreStackView.autoPinWidthToSuperview() restoreStackView.autoVCenterInSuperview() - linkStackView.autoPinWidthToSuperview() - linkStackView.autoVCenterInSuperview() } // MARK: General @@ -237,9 +170,8 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate { private func handleModeChanged() { let (activeStackView, otherStackViews) = { () -> (UIStackView, [UIStackView]) in switch mode { - case .register: return (registerStackView, [ restoreStackView, linkStackView ]) - case .restore: return (restoreStackView, [ registerStackView, linkStackView ]) - case .link: return (linkStackView, [ registerStackView, restoreStackView ]) + case .register: return (registerStackView, [ restoreStackView ]) + case .restore: return (restoreStackView, [ registerStackView ]) } }() UIView.animate(withDuration: 0.25) { @@ -250,14 +182,12 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate { switch mode { case .register: return NSLocalizedString("Register", comment: "") case .restore: return NSLocalizedString("Restore", comment: "") - case .link: return NSLocalizedString("Link", comment: "") } }() UIView.transition(with: mainButton, duration: 0.25, options: .transitionCrossDissolve, animations: { self.mainButton.setTitle(mainButtonTitle) }, completion: nil) if mode != .restore { mnemonicTextField.resignFirstResponder() } - if mode != .link { masterHexEncodedPublicKeyTextField.resignFirstResponder() } } private func updateSeed() { @@ -287,39 +217,54 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate { switch mode { case .register: mode = .restore case .restore: mode = .register - case .link: mode = .register } } - @objc private func handleSwitchModeButton2Tapped() { - switch mode { - case .register: mode = .link - case .restore: mode = .link - case .link: mode = .restore + @objc private func handleLinkButtonTapped() { + ows_ask(forCameraPermissions: { [weak self] hasCameraAccess in + guard let self = self else { return } + if hasCameraAccess { + let message = NSLocalizedString("something something something", comment: "") + let scanQRCodeWrapperVC = ScanQRCodeWrapperVC(message: message) + scanQRCodeWrapperVC.delegate = self + self.present(scanQRCodeWrapperVC, animated: true, completion: nil) + } else { + // Do nothing + } + }) + } + + func controller(_ controller: OWSQRCodeScanningViewController, didDetectQRCodeWith string: String) { + dismiss(animated: true, completion: nil) + DispatchQueue.main.async { [weak self] in + self?.proceed(with: string) } } - @objc private func handleMainButtonTapped() { + @objc private func proceed(with masterHexEncodedPublicKey: String? = nil) { var seed: Data - let mode = self.mode - switch mode { - case .register: seed = self.seed - case .restore: - let mnemonic = mnemonicTextField.text! - do { - let hexEncodedSeed = try Mnemonic.decode(mnemonic: mnemonic) - seed = Data(hex: hexEncodedSeed) - } catch let error { - let error = error as? Mnemonic.DecodingError ?? Mnemonic.DecodingError.generic - errorLabel1Spacer.isHidden = false - return errorLabel1.text = error.errorDescription - } - case .link: + if let masterHexEncodedPublicKey = masterHexEncodedPublicKey { seed = self.seed - let masterHexEncodedPublicKey = masterHexEncodedPublicKeyTextField.text!.trimmingCharacters(in: CharacterSet.whitespaces) if !ECKeyPair.isValidHexEncodedPublicKey(candidate: masterHexEncodedPublicKey) { - errorLabel2Spacer.isHidden = false - return errorLabel2.text = NSLocalizedString("Invalid public key", comment: "") + let alert = UIAlertController(title: NSLocalizedString("Invalid QR Code", comment: ""), message: NSLocalizedString("Please make sure the QR code you scanned is correct and try again.", comment: ""), preferredStyle: .alert) + alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: ""), accessibilityIdentifier: nil, style: .default, handler: nil)) + return present(alert, animated: true, completion: nil) + } + Analytics.shared.track("Device Linking Attempted") + } else { + let mode = self.mode + switch mode { + case .register: seed = self.seed + case .restore: + let mnemonic = mnemonicTextField.text! + do { + let hexEncodedSeed = try Mnemonic.decode(mnemonic: mnemonic) + seed = Data(hex: hexEncodedSeed) + } catch let error { + let error = error as? Mnemonic.DecodingError ?? Mnemonic.DecodingError.generic + errorLabelSpacer.isHidden = false + return errorLabel.text = error.errorDescription + } } } // Use KVC to access dbConnection even though it's private @@ -335,10 +280,8 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate { switch mode { case .register: Analytics.shared.track("Seed Created") case .restore: Analytics.shared.track("Seed Restored") - case .link: Analytics.shared.track("Device Linking Attempted") } - if mode == .link { - let masterHexEncodedPublicKey = masterHexEncodedPublicKeyTextField.text!.trimmingCharacters(in: CharacterSet.whitespaces) + if let masterHexEncodedPublicKey = masterHexEncodedPublicKey { TSAccountManager.sharedInstance().didRegister() setUserInteractionEnabled(false) let _ = LokiStorageAPI.getDeviceLinks(associatedWith: masterHexEncodedPublicKey).done(on: DispatchQueue.main) { [weak self] deviceLinks in @@ -384,8 +327,8 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate { // MARK: Convenience private func setUserInteractionEnabled(_ isEnabled: Bool) { - registerButton2.isUserInteractionEnabled = isEnabled - restoreButton2.isUserInteractionEnabled = isEnabled - mainButton.isUserInteractionEnabled = isEnabled + [ copyButton, restoreButton, linkButton1, registerButton, linkButton2, mainButton ].forEach { + $0.isUserInteractionEnabled = isEnabled + } } } diff --git a/Signal/src/Loki/Settings/SeedModal.swift b/Signal/src/Loki/Settings/SeedModal.swift index 5d9cf30c1..3040cbc7c 100644 --- a/Signal/src/Loki/Settings/SeedModal.swift +++ b/Signal/src/Loki/Settings/SeedModal.swift @@ -32,7 +32,7 @@ final class SeedModal : Modal { let subtitleLabel = UILabel() subtitleLabel.textColor = Theme.primaryColor subtitleLabel.font = UIFont.ows_dynamicTypeCaption1Clamped - subtitleLabel.text = NSLocalizedString("This is your personal secret. It can be used to restore your account if you lose access, or to migrate to a new device.", comment: "") + subtitleLabel.text = NSLocalizedString("This is your personal secret. It can be used to restore your account if you lose access, or to migrate your account to a new device.", comment: "") subtitleLabel.numberOfLines = 0 subtitleLabel.lineBreakMode = .byWordWrapping subtitleLabel.textAlignment = .center diff --git a/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift index 0dc05bae6..d393b1ee1 100644 --- a/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift +++ b/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift @@ -31,9 +31,10 @@ public class OnboardingSplashViewController: OnboardingBaseViewController { lokiLogoContainer.addSubview(lokiLogoImageView) let betaTermsLabel = UILabel() - betaTermsLabel.text = NSLocalizedString("Loki Messenger is currently in beta. For development purposes the beta version collects basic usage statistics and crash logs. In addition, the beta version doesn't provide full privacy and shouldn't be used to transmit sensitive information.", comment: "") + betaTermsLabel.text = NSLocalizedString("Loki Messenger is currently in beta. For development purposes the beta version collects basic usage statistics and crash logs. In addition, the beta version doesn't yet provide full privacy and shouldn't be used to transmit sensitive information.", comment: "") betaTermsLabel.textColor = .white - betaTermsLabel.font = .ows_dynamicTypeSubheadlineClamped + let font = UIFont.ows_dynamicTypeCaption1Clamped + betaTermsLabel.font = UIFont(descriptor: font.fontDescriptor.withSymbolicTraits(.traitBold)!, size: font.pointSize) betaTermsLabel.numberOfLines = 0 betaTermsLabel.textAlignment = .center betaTermsLabel.lineBreakMode = .byWordWrapping diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 74254155f..a0bf2ffbb 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -2552,7 +2552,7 @@ "Password (Optional)" = "Password (Optional)"; "Next" = "Next"; "Add" = "Add"; -"Please save the seed below in a safe location. It can be used to restore your account if you lose access, or to migrate to a new device." = "Please save the seed below in a safe location. It can be used to restore your account if you lose access, or to migrate to a new device."; +"Please save the seed below in a safe location. It can be used to restore your account if you lose access, or to migrate your account to a new device." = "Please save the seed below in a safe location. It can be used to restore your account if you lose access, or to migrate your account to a new device."; "Restore your account by entering your seed below." = "Restore your account by entering your seed below."; "Copy" = "Copy"; "Copied ✓" = "Copied ✓"; @@ -2621,7 +2621,7 @@ "Loki" = "Loki"; "Can't Start Conversation" = "Can't Start Conversation"; "Please enter the public key of the person you'd like to message." = "Please enter the public key of the person you'd like to message."; -"Loki Messenger is currently in beta. For development purposes the beta version collects basic usage statistics and crash logs. In addition, the beta version doesn't provide full privacy and shouldn't be used to transmit sensitive information." = "Loki Messenger is currently in beta. For development purposes the beta version collects basic usage statistics and crash logs. In addition, the beta version doesn't provide full privacy and shouldn't be used to transmit sensitive information."; +"Loki Messenger is currently in beta. For development purposes the beta version collects basic usage statistics and crash logs. In addition, the beta version doesn't yet provide full privacy and shouldn't be used to transmit sensitive information." = "Loki Messenger is currently in beta. For development purposes the beta version collects basic usage statistics and crash logs. In addition, the beta version doesn't yet provide full privacy and shouldn't be used to transmit sensitive information."; "Copy Public Key" = "Copy Public Key"; "Link Device" = "Link Device"; "Waiting for Device" = "Waiting for Device"; @@ -2633,7 +2633,7 @@ "Link to an existing device by going into its in-app settings and clicking \"Link Device\"." = "Link to an existing device by going into its in-app settings and clicking \"Link Device\"."; "Authorize" = "Authorize"; "Enter the Other Device's Public Key" = "Enter the Other Device's Public Key"; -"This is your personal secret. It can be used to restore your account if you lose access, or to migrate to a new device." = "This is your personal secret. It can be used to restore your account if you lose access, or to migrate to a new device."; +"This is your personal secret. It can be used to restore your account if you lose access, or to migrate your account to a new device." = "This is your personal secret. It can be used to restore your account if you lose access, or to migrate your account to a new device."; "Device Link Authorized" = "Device Link Authorized"; "Your device has been linked successfully" = "Your device has been linked successfully"; "Link" = "Link"; @@ -2650,3 +2650,5 @@ "Please pick a display name that consists of only a-z, A-Z, 0-9 and _ characters" = "Please pick a display name that consists of only a-z, A-Z, 0-9 and _ characters"; "Multi Device Limit Reached" = "Multi Device Limit Reached"; "It's currently not allowed to link more than one device." = "It's currently not allowed to link more than one device."; +"Invalid QR Code" = "Invalid QR Code"; +"Please make sure the QR code you scanned is correct and try again." = "Please make sure the QR code you scanned is correct and try again."; From a1d33b24cf8b7148a7bad66f8153ab0ff0a14c32 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Tue, 19 Nov 2019 15:46:50 +1100 Subject: [PATCH 5/7] Fix incorrect file name --- Signal.xcodeproj/project.pbxproj | 8 ++++---- .../{ScanQRCodeVC.swift => ScanQRCodeWrapperVC.swift} | 0 2 files changed, 4 insertions(+), 4 deletions(-) rename Signal/src/Loki/Messaging/{ScanQRCodeVC.swift => ScanQRCodeWrapperVC.swift} (100%) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 7d31ab871..7f8ffe8a8 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -575,7 +575,7 @@ B891105C2320872800F15FCC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B891105B2320872800F15FCC /* GoogleService-Info.plist */; }; B891105E2320872800F15FCC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B891105B2320872800F15FCC /* GoogleService-Info.plist */; }; B891105F2320872800F15FCC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B891105B2320872800F15FCC /* GoogleService-Info.plist */; }; - B893063F2383961A005EAA8E /* ScanQRCodeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B893063E2383961A005EAA8E /* ScanQRCodeVC.swift */; }; + B893063F2383961A005EAA8E /* ScanQRCodeWrapperVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B893063E2383961A005EAA8E /* ScanQRCodeWrapperVC.swift */; }; B894D0712339D6F300B4D94D /* DeviceLinkingModalDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B894D0702339D6F300B4D94D /* DeviceLinkingModalDelegate.swift */; }; B894D0752339EDCF00B4D94D /* NukeDataModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = B894D0742339EDCF00B4D94D /* NukeDataModal.swift */; }; B89841E322B7579F00B1BDC6 /* NewConversationVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B89841E222B7579F00B1BDC6 /* NewConversationVC.swift */; }; @@ -1384,7 +1384,7 @@ B885D5F3233491AB00EE0D8E /* DeviceLinkingModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceLinkingModal.swift; sourceTree = ""; }; B885D5F52334A32100EE0D8E /* UIView+Constraint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Constraint.swift"; sourceTree = ""; }; B891105B2320872800F15FCC /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; - B893063E2383961A005EAA8E /* ScanQRCodeVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanQRCodeVC.swift; sourceTree = ""; }; + B893063E2383961A005EAA8E /* ScanQRCodeWrapperVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanQRCodeWrapperVC.swift; sourceTree = ""; }; B894D0702339D6F300B4D94D /* DeviceLinkingModalDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceLinkingModalDelegate.swift; sourceTree = ""; }; B894D0742339EDCF00B4D94D /* NukeDataModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NukeDataModal.swift; sourceTree = ""; }; B89841E222B7579F00B1BDC6 /* NewConversationVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewConversationVC.swift; sourceTree = ""; }; @@ -2707,7 +2707,7 @@ B8B26C90234D8CBD004ED98C /* MentionCandidateSelectionViewDelegate.swift */, B89841E222B7579F00B1BDC6 /* NewConversationVC.swift */, 24BD2608234DA2050008EB0A /* NewPublicChatVC.swift */, - B893063E2383961A005EAA8E /* ScanQRCodeVC.swift */, + B893063E2383961A005EAA8E /* ScanQRCodeWrapperVC.swift */, ); path = Messaging; sourceTree = ""; @@ -3732,7 +3732,7 @@ 34D99C931F2937CC00D284D6 /* OWSAnalytics.swift in Sources */, 340FC8B8204DAC8D007AEB0F /* AddToGroupViewController.m in Sources */, 341F2C0F1F2B8AE700D07D6B /* DebugUIMisc.m in Sources */, - B893063F2383961A005EAA8E /* ScanQRCodeVC.swift in Sources */, + B893063F2383961A005EAA8E /* ScanQRCodeWrapperVC.swift in Sources */, 340FC8AF204DAC8D007AEB0F /* OWSLinkDeviceViewController.m in Sources */, 34E3EF0D1EFC235B007F6822 /* DebugUIDiskUsage.m in Sources */, 454A84042059C787008B8C75 /* MediaTileViewController.swift in Sources */, diff --git a/Signal/src/Loki/Messaging/ScanQRCodeVC.swift b/Signal/src/Loki/Messaging/ScanQRCodeWrapperVC.swift similarity index 100% rename from Signal/src/Loki/Messaging/ScanQRCodeVC.swift rename to Signal/src/Loki/Messaging/ScanQRCodeWrapperVC.swift From 4fd2faffe4636226ad8dd0b0a7a8dd247dd9fed5 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Tue, 19 Nov 2019 16:02:45 +1100 Subject: [PATCH 6/7] Fix crash --- Signal/src/Loki/Onboarding/SeedVC.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Signal/src/Loki/Onboarding/SeedVC.swift b/Signal/src/Loki/Onboarding/SeedVC.swift index a78a0f2ec..334aed685 100644 --- a/Signal/src/Loki/Onboarding/SeedVC.swift +++ b/Signal/src/Loki/Onboarding/SeedVC.swift @@ -115,7 +115,7 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate, O }() private lazy var mainButton: OWSFlatButton = { - let result = createButton(title: "", selector: #selector(proceed(with:))) + let result = createButton(title: "", selector: #selector(objc_proceed)) result.accessibilityIdentifier = "onboarding.keyPairStep.mainButton" return result }() @@ -241,7 +241,11 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate, O } } - @objc private func proceed(with masterHexEncodedPublicKey: String? = nil) { + @objc private func objc_proceed() { + proceed() + } + + private func proceed(with masterHexEncodedPublicKey: String? = nil) { var seed: Data if let masterHexEncodedPublicKey = masterHexEncodedPublicKey { seed = self.seed From 5e80e0d13a925bb48540dae130c3e2e73f458bec Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Tue, 19 Nov 2019 16:18:29 +1100 Subject: [PATCH 7/7] Clean --- Signal/src/Loki/Messaging/ScanQRCodeWrapperVC.swift | 10 ++++++++++ Signal/src/Loki/Onboarding/SeedVC.swift | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Signal/src/Loki/Messaging/ScanQRCodeWrapperVC.swift b/Signal/src/Loki/Messaging/ScanQRCodeWrapperVC.swift index 5e56e4988..dede72043 100644 --- a/Signal/src/Loki/Messaging/ScanQRCodeWrapperVC.swift +++ b/Signal/src/Loki/Messaging/ScanQRCodeWrapperVC.swift @@ -1,6 +1,7 @@ final class ScanQRCodeWrapperVC : UIViewController { var delegate: (UIViewController & OWSQRScannerDelegate)? = nil + var isPresentedModally = false private let message: String private let scanQRCodeVC = OWSQRCodeScanningViewController() @@ -22,6 +23,10 @@ final class ScanQRCodeWrapperVC : UIViewController { } override func viewDidLoad() { + // Navigation bar + if isPresentedModally { + navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: #selector(objc_dismiss)) + } // Background color view.backgroundColor = Theme.backgroundColor // Scan QR code VC @@ -61,4 +66,9 @@ final class ScanQRCodeWrapperVC : UIViewController { self?.scanQRCodeVC.startCapture() } } + + // MARK: Interaction + @objc private func objc_dismiss() { + presentingViewController?.dismiss(animated: true, completion: nil) + } } diff --git a/Signal/src/Loki/Onboarding/SeedVC.swift b/Signal/src/Loki/Onboarding/SeedVC.swift index 334aed685..8972c5406 100644 --- a/Signal/src/Loki/Onboarding/SeedVC.swift +++ b/Signal/src/Loki/Onboarding/SeedVC.swift @@ -224,10 +224,12 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate, O ows_ask(forCameraPermissions: { [weak self] hasCameraAccess in guard let self = self else { return } if hasCameraAccess { - let message = NSLocalizedString("something something something", comment: "") + let message = NSLocalizedString("Link to an existing device by going into its in-app settings and clicking \"Link Device\".", comment: "") let scanQRCodeWrapperVC = ScanQRCodeWrapperVC(message: message) scanQRCodeWrapperVC.delegate = self - self.present(scanQRCodeWrapperVC, animated: true, completion: nil) + scanQRCodeWrapperVC.isPresentedModally = true + let navigationVC = OWSNavigationController(rootViewController: scanQRCodeWrapperVC) + self.present(navigationVC, animated: true, completion: nil) } else { // Do nothing }