B. Petersen 5 роки тому
батько
коміт
ec2d91ec7a

+ 21 - 3
deltachat-ios/Controller/SettingsController.swift

@@ -117,9 +117,6 @@ internal final class SettingsViewController: QuickTableViewController {
             Section(
                 title: String.localized("pref_communication"),
                 rows: [
-                    SwitchRow(text: String.localized("autocrypt_prefer_e2ee"),
-                              switchValue: DcConfig.e2eeEnabled,
-                              action: editCell(key: SVC.e2eeEnabled)),
                     SwitchRow(text: String.localized("pref_read_receipts"),
                               switchValue: DcConfig.mdnsEnabled,
                               action: editCell(key: SVC.readReceipts)),
@@ -146,6 +143,17 @@ internal final class SettingsViewController: QuickTableViewController {
                 footer: String.localized("pref_auto_folder_moves_explain")
             ),
 
+            Section(
+                title: String.localized("autocrypt"),
+                rows: [
+                    SwitchRow(text: String.localized("autocrypt_prefer_e2ee"),
+                              switchValue: DcConfig.e2eeEnabled,
+                              action: editCell(key: SVC.e2eeEnabled)),
+                    TapActionRow(text: String.localized("autocrypt_send_asm_title"), action: { [weak self] in self?.sendAsm($0) }),
+                ],
+                footer: String.localized("autocrypt_explain")
+            ),
+
             Section(
                 title: String.localized("pref_backup"),
                 rows: [
@@ -211,6 +219,16 @@ internal final class SettingsViewController: QuickTableViewController {
         present(alert, animated: true, completion: nil)
     }
 
+    private func sendAsm(_: Row) {
+        let alert = UIAlertController(title: String.localized("autocrypt_send_asm_explain_before"), message: nil, preferredStyle: .actionSheet)
+        alert.addAction(UIAlertAction(title: String.localized("autocrypt_send_asm_title"), style: .default, handler: { _ in
+            //dcContext.intiateKeyTransfer()
+            self.dismiss(animated: true, completion: nil)
+        }))
+        alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
+        present(alert, animated: true, completion: nil)
+    }
+
     private func configure(_: Row) {
         hudHandler.showHud(String.localized("configuring_account"))
         dc_configure(mailboxPointer)

+ 8 - 0
deltachat-ios/DC/Wrapper.swift

@@ -61,6 +61,14 @@ class DcContext {
         return "ErrGetMsgInfo"
     }
 
+    func intiateKeyTransfer() -> String? {
+        if let cString = dc_initiate_key_transfer(self.contextPointer) {
+            let swiftString = String(cString: cString)
+            free(cString)
+            return swiftString
+        }
+        return nil
+    }
 }
 
 class DcConfig {