diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 9724c5aca..01e2a699c 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -560,6 +560,7 @@ B8162F0522892C5F00D46544 /* FriendRequestViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8162F0422892C5F00D46544 /* FriendRequestViewDelegate.swift */; }; B821F2F82272CED3002C88C0 /* AccountDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B821F2F72272CED3002C88C0 /* AccountDetailsViewController.swift */; }; B821F2FA2272CEEE002C88C0 /* SeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B821F2F92272CEEE002C88C0 /* SeedViewController.swift */; }; + B825848B230F94FE001B41CB /* QRCodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B825848A230F94FE001B41CB /* QRCodeViewController.swift */; }; B845B4D4230CD09100D759F0 /* LokiGroupChatPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = B845B4D3230CD09000D759F0 /* LokiGroupChatPoller.swift */; }; B846365B22B7418B00AF1514 /* Identicon+ObjC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B846365A22B7418B00AF1514 /* Identicon+ObjC.swift */; }; B89841E322B7579F00B1BDC6 /* NewConversationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B89841E222B7579F00B1BDC6 /* NewConversationViewController.swift */; }; @@ -1350,6 +1351,7 @@ B8162F0422892C5F00D46544 /* FriendRequestViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendRequestViewDelegate.swift; sourceTree = ""; }; B821F2F72272CED3002C88C0 /* AccountDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountDetailsViewController.swift; sourceTree = ""; }; B821F2F92272CEEE002C88C0 /* SeedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedViewController.swift; sourceTree = ""; }; + B825848A230F94FE001B41CB /* QRCodeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRCodeViewController.swift; sourceTree = ""; }; B845B4D3230CD09000D759F0 /* LokiGroupChatPoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LokiGroupChatPoller.swift; sourceTree = ""; }; B846365A22B7418B00AF1514 /* Identicon+ObjC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Identicon+ObjC.swift"; sourceTree = ""; }; B89841E222B7579F00B1BDC6 /* NewConversationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewConversationViewController.swift; sourceTree = ""; }; @@ -2615,6 +2617,7 @@ B821F2F92272CEEE002C88C0 /* SeedViewController.swift */, 24A830A12293CD0100F4CAC0 /* LokiP2PServer.swift */, B845B4D3230CD09000D759F0 /* LokiGroupChatPoller.swift */, + B825848A230F94FE001B41CB /* QRCodeViewController.swift */, ); path = Loki; sourceTree = ""; @@ -3647,6 +3650,7 @@ 4C2F454F214C00E1004871FF /* AvatarTableViewCell.swift in Sources */, 346E9D5421B040B700562252 /* RegistrationController.swift in Sources */, 340FC8AD204DAC8D007AEB0F /* OWSLinkedDevicesTableViewController.m in Sources */, + B825848B230F94FE001B41CB /* QRCodeViewController.swift in Sources */, 340FC8AA204DAC8D007AEB0F /* NotificationSettingsViewController.m in Sources */, 4C090A1B210FD9C7001FD7F9 /* HapticFeedback.swift in Sources */, 3496744F2076ACD000080B5F /* LongTextViewController.swift in Sources */, diff --git a/Signal/src/Loki/QRCodeViewController.swift b/Signal/src/Loki/QRCodeViewController.swift new file mode 100644 index 000000000..ee512ee9e --- /dev/null +++ b/Signal/src/Loki/QRCodeViewController.swift @@ -0,0 +1,39 @@ + +final class QRCodeViewController : OWSViewController { + + public override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .portrait} + public override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent} + + override func viewDidLoad() { + super.viewDidLoad() + let stackView = UIStackView(arrangedSubviews: []) + stackView.axis = .vertical + stackView.spacing = 32 + stackView.alignment = .center + stackView.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(stackView) + NSLayoutConstraint.activate([ + stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 32), + stackView.topAnchor.constraint(equalTo: view.topAnchor, constant: 24), + view.trailingAnchor.constraint(equalTo: stackView.trailingAnchor, constant: 32) + ]) + let label = UILabel() + label.font = UIFont.ows_dynamicTypeSubheadlineClamped + label.text = NSLocalizedString("This is your personal QR code. Other people can scan it to start a secure conversation with you.", comment: "") + label.numberOfLines = 0 + label.textAlignment = .center + label.lineBreakMode = .byWordWrapping + label.textColor = UIColor.ows_white + stackView.addArrangedSubview(label) + let imageView = UIImageView() + let hexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey + let data = hexEncodedPublicKey.data(using: .utf8) + let filter = CIFilter(name: "CIQRCodeGenerator")! + filter.setValue(data, forKey: "inputMessage") + let qrCodeAsCIImage = filter.outputImage! + let scaledQRCodeAsCIImage = qrCodeAsCIImage.transformed(by: CGAffineTransform(scaleX: 6.4, y: 6.4)) + let qrCode = UIImage(ciImage: scaledQRCodeAsCIImage) + imageView.image = qrCode + stackView.addArrangedSubview(imageView) + } +} diff --git a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m index 952fa894a..893354032 100644 --- a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m @@ -239,6 +239,7 @@ #endif [section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Share Public Key", @"") actionBlock:^{ [weakSelf sharePublicKey]; }]]; + [section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Show QR Code", @"") actionBlock:^{ [weakSelf showQRCode]; }]]; [section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Show Seed", @"") actionBlock:^{ [weakSelf showSeed]; }]]; [section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Clear All Data", @"") actionBlock:^{ [weakSelf clearAllData]; }]]; @@ -503,6 +504,12 @@ [self presentViewController:shareVC animated:YES completion:nil]; } +- (void)showQRCode +{ + QRCodeViewController *qrCodeVC = [QRCodeViewController new]; + [self.navigationController pushViewController:qrCodeVC animated:YES]; +} + - (void)showSeed { NSString *title = NSLocalizedString(@"Your Seed", @""); diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index d3ba71b67..043b9612c 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -2607,3 +2607,4 @@ "Update Required" = "Update Required"; "This version of Loki Messenger is no longer supported. Please press OK to reset your account and migrate to the latest version." = "This version of Loki Messenger is no longer supported. Please press OK to reset your account and migrate to the latest version."; "Loki Public Chat" = "Loki Public Chat"; +"Show QR Code" = "Show QR Code";