Skip to content

Commit f67d019

Browse files
authored
Merge pull request #406 from deltachat/delta_login
Delta login
2 parents 4378a6a + 4c5ff9c commit f67d019

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

deltachat-ios/AppDelegate.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
4747
if let params = url.queryParameters, let token = params["code"] {
4848
NotificationCenter.default.post(name: NSNotification.Name("oauthLoginApproved"), object: nil, userInfo: ["token": token])
4949
}
50+
51+
// Hack to format url properly
52+
let urlString = url.absoluteString
53+
.replacingOccurrences(of: "openpgp4fpr", with: "OPENPGP4FPR", options: .literal, range: nil)
54+
.replacingOccurrences(of: "%23", with: "#", options: .literal, range: nil)
55+
56+
self.appCoordinator.handleQRCode(urlString)
5057
return true
5158
}
5259

deltachat-ios/Controller/QrViewController.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ class QrViewController: UITableViewController, QrCodeReaderDelegate {
7777
}
7878

7979
private lazy var progressAlert: UIAlertController = {
80-
let alert = UIAlertController(title: String.localized("one_moment"), message: "TESTMESSAGE", preferredStyle: .alert)
80+
var title = String.localized("one_moment")+"\n\n"
81+
let alert = UIAlertController(title: title, message: nil, preferredStyle: .alert)
8182

8283
let rect = CGRect(x: 0, y: 0, width: 25, height: 25)
8384
let activityIndicator = UIActivityIndicatorView(frame: rect)
@@ -97,7 +98,12 @@ class QrViewController: UITableViewController, QrCodeReaderDelegate {
9798
let progressView = UIActivityIndicatorView(frame: rect)
9899
progressView.tintColor = .blue
99100
progressView.startAnimating()
101+
progressView.translatesAutoresizingMaskIntoConstraints = false
100102
self.progressAlert.view.addSubview(progressView)
103+
self.progressAlert.view.addConstraints([
104+
progressView.constraintCenterXTo(self.progressAlert.view),
105+
progressView.constraintAlignTopTo(self.progressAlert.view, paddingTop: 45)
106+
])
101107
})
102108
}
103109

@@ -138,8 +144,11 @@ class QrViewController: UITableViewController, QrCodeReaderDelegate {
138144
//QRCodeDelegate
139145
func handleQrCode(_ code: String) {
140146
//remove qr code scanner view
141-
if let ctrl = navigationController {
142-
ctrl.viewControllers.removeLast()
147+
if let ctrl = navigationController,
148+
let lastController = ctrl.viewControllers.last {
149+
if type(of: lastController) === QrCodeReaderController.self {
150+
ctrl.viewControllers.removeLast()
151+
}
143152
}
144153

145154
let qrParsed: DcLot = self.dcContext.checkQR(qrCode: code)

deltachat-ios/Coordinator/AppCoordinator.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ class AppCoordinator: NSObject, Coordinator {
9797
navController.pushViewController(chatVC, animated: true)
9898
}
9999

100+
func handleQRCode(_ code: String) {
101+
showTab(index: qrTab)
102+
if let navController = qrController as? UINavigationController,
103+
let topViewController = navController.topViewController,
104+
let qrViewController = topViewController as? QrViewController {
105+
qrViewController.handleQrCode(code)
106+
}
107+
}
108+
100109
func presentLoginController() {
101110
window.rootViewController = loginController
102111
window.makeKeyAndVisible()

deltachat-ios/Info.plist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@
2121
<key>CFBundleURLTypes</key>
2222
<array>
2323
<dict>
24+
<key>CFBundleTypeRole</key>
25+
<string>Editor</string>
26+
<key>CFBundleURLName</key>
27+
<string>chat.delta.qr</string>
2428
<key>CFBundleURLSchemes</key>
2529
<array>
2630
<string>chat.delta</string>
31+
<string>openpgp4fpr</string>
2732
</array>
2833
</dict>
2934
</array>

0 commit comments

Comments
 (0)