Bläddra i källkod

add option to open urls scanned from qr-codes

B. Petersen 5 år sedan
förälder
incheckning
ffd24f14c2
1 ändrade filer med 12 tillägg och 0 borttagningar
  1. 12 0
      deltachat-ios/Controller/QrViewController.swift

+ 12 - 0
deltachat-ios/Controller/QrViewController.swift

@@ -156,6 +156,18 @@ class QrViewController: UITableViewController, QrCodeReaderDelegate {
             alert.addAction(UIAlertAction(title: String.localized("ok"), style: .default, handler: nil))
             alert.addAction(UIAlertAction(title: String.localized("ok"), style: .default, handler: nil))
             present(alert, animated: true, completion: nil)
             present(alert, animated: true, completion: nil)
 
 
+        case DC_QR_URL:
+            let url = qrParsed.text1 ?? ""
+            let msg = String.localizedStringWithFormat(String.localized("qrscan_contains_url"), url)
+            let alert = UIAlertController(title: msg, message: nil, preferredStyle: .alert)
+            alert.addAction(UIAlertAction(title: String.localized("open"), style: .default, handler: { _ in
+                if let url = URL(string: url) {
+                    UIApplication.shared.open(url)
+                }
+            }))
+            alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .default, handler: nil))
+            present(alert, animated: true, completion: nil)
+
         default:
         default:
             var msg = String.localizedStringWithFormat(String.localized("qrscan_contains_text"), code)
             var msg = String.localizedStringWithFormat(String.localized("qrscan_contains_text"), code)
             if state == DC_QR_ERROR {
             if state == DC_QR_ERROR {