Add show QR code button to settings
This commit is contained in:
parent
0918015a65
commit
e72af6dec3
|
@ -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 = "<group>"; };
|
||||
B821F2F72272CED3002C88C0 /* AccountDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountDetailsViewController.swift; sourceTree = "<group>"; };
|
||||
B821F2F92272CEEE002C88C0 /* SeedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedViewController.swift; sourceTree = "<group>"; };
|
||||
B825848A230F94FE001B41CB /* QRCodeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRCodeViewController.swift; sourceTree = "<group>"; };
|
||||
B845B4D3230CD09000D759F0 /* LokiGroupChatPoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LokiGroupChatPoller.swift; sourceTree = "<group>"; };
|
||||
B846365A22B7418B00AF1514 /* Identicon+ObjC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Identicon+ObjC.swift"; sourceTree = "<group>"; };
|
||||
B89841E222B7579F00B1BDC6 /* NewConversationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewConversationViewController.swift; sourceTree = "<group>"; };
|
||||
|
@ -2615,6 +2617,7 @@
|
|||
B821F2F92272CEEE002C88C0 /* SeedViewController.swift */,
|
||||
24A830A12293CD0100F4CAC0 /* LokiP2PServer.swift */,
|
||||
B845B4D3230CD09000D759F0 /* LokiGroupChatPoller.swift */,
|
||||
B825848A230F94FE001B41CB /* QRCodeViewController.swift */,
|
||||
);
|
||||
path = Loki;
|
||||
sourceTree = "<group>";
|
||||
|
@ -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 */,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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", @"");
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue