浏览代码

add aeap confirmation dialog

B. Petersen 3 年之前
父节点
当前提交
29086000be
共有 1 个文件被更改,包括 24 次插入8 次删除
  1. 24 8
      deltachat-ios/Controller/AccountSetupController.swift

+ 24 - 8
deltachat-ios/Controller/AccountSetupController.swift

@@ -482,17 +482,33 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
             return // handle case when either email or pw fields are empty
         }
 
-        let oAuthStarted = showOAuthAlertIfNeeded(emailAddress: emailAddress, handleCancel: loginButtonPressed)
-        // if canceled we will run this method again but this time oAuthStarted will be false
+        func loginButtonPressedContinue() {
+            let oAuthStarted = showOAuthAlertIfNeeded(emailAddress: emailAddress, handleCancel: loginButtonPressed)
+            // if canceled we will run this method again but this time oAuthStarted will be false
 
-        if oAuthStarted {
-            // the loginFlow will be handled by oAuth2
-            return
-        }
+            if oAuthStarted {
+                // the loginFlow will be handled by oAuth2
+                return
+            }
 
-        let password = passwordCell.getText() ?? "" // empty passwords are ok -> for oauth there is no password needed
+            let password = passwordCell.getText() ?? "" // empty passwords are ok -> for oauth there is no password needed
 
-        login(emailAddress: emailAddress, password: password)
+            login(emailAddress: emailAddress, password: password)
+        }
+
+        if dcContext.isConfigured(),
+           let oldAddress = dcContext.getConfig("configured_addr"),
+           oldAddress != emailAddress {
+            let msg = String.localizedStringWithFormat(String.localized("aeap_explanation"), oldAddress, emailAddress)
+            let alert = UIAlertController(title: msg, message: nil, preferredStyle: .safeActionSheet)
+            alert.addAction(UIAlertAction(title: String.localized("perm_continue"), style: .default, handler: { _ in
+                loginButtonPressedContinue()
+            }))
+            alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
+            self.present(alert, animated: true, completion: nil)
+        } else {
+            loginButtonPressedContinue()
+        }
     }
 
     private func updateProviderInfo() {