Эх сурвалжийг харах

bring belonging code together

B. Petersen 6 жил өмнө
parent
commit
ba1426389d

+ 50 - 51
deltachat-ios/Controller/AccountSetupController.swift

@@ -7,12 +7,14 @@ class AccountSetupController: UITableViewController {
     weak var coordinator: AccountSetupCoordinator?
 
     private var skipOauth = false
-
     private var backupProgressObserver: Any?
     private var configureProgressObserver: Any?
     private var oauth2Observer: Any?
 
-    lazy var configProgressIndicator: UICircularProgressRing = {
+
+    // the progress dialog
+
+    private lazy var configProgressIndicator: UICircularProgressRing = {
         let progress = UICircularProgressRing()
         progress.style = UICircularRingStyle.inside
         progress.outerRingColor = UIColor.clear
@@ -25,8 +27,8 @@ class AccountSetupController: UITableViewController {
         return progress
     }()
 
-    lazy var configProgressAlert: UIAlertController = {
-        let alert = UIAlertController(title: String.localized("configuring_account"), message: "\n\n\n", preferredStyle: .alert)
+    private lazy var configProgressAlert: UIAlertController = {
+        let alert = UIAlertController(title: String.localized("one_moment"), message: "\n\n\n", preferredStyle: .alert)
         // temp workaround: add 3 newlines to let alertbox grow to fit progressview
         let progressView = configProgressIndicator
         progressView.translatesAutoresizingMaskIntoConstraints = false
@@ -39,6 +41,50 @@ class AccountSetupController: UITableViewController {
         return alert
     }()
 
+    private func showProgressHud() {
+        configProgressAlert.actions[0].isEnabled = true
+        configProgressIndicator.alpha = 1
+        configProgressIndicator.value = 0
+        present(configProgressAlert, animated: true, completion: nil)
+    }
+
+    private func updateProgressHud(error message: String?) {
+        configProgressAlert.title = String.localized("login_error_title")
+        configProgressAlert.message = message
+        configProgressIndicator.alpha = 0
+    }
+
+    private func updateProgressHudSuccess(callback: (()->())?) {
+        configProgressAlert.actions[0].isEnabled = false
+        configProgressIndicator.alpha = 0
+        configProgressAlert.title = String.localized("login_successful_title")
+        configProgressAlert.message = String.localized("login_successful_message")
+        loginButton.isEnabled = dc_is_configured(mailboxPointer) == 0
+        DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
+            self.configProgressAlert.dismiss(animated: true) {
+                self.handleLoginSuccess()
+            }
+        })
+    }
+
+    private func updateProgressHudValue(value: Int?) {
+        if let value = value {
+            print("progress hud: \(value)")
+            configProgressIndicator.value = CGFloat(value / 10)
+        }
+    }
+
+    private func loginCancelled(_ action: UIAlertAction) {
+        DcConfig.addr = nil
+        DcConfig.mailPw = nil
+        DispatchQueue.global(qos: .background).async {
+            dc_stop_ongoing_process(mailboxPointer)        // this function freezes UI so execute in background thread
+        }
+    }
+
+
+    // account setup
+
     private lazy var emailCell: TextFieldCell = {
         let cell = TextFieldCell.makeEmailCell(delegate: self)
         cell.textField.tag = 0
@@ -641,50 +687,3 @@ class AdvancedSectionHeader: UIView {
         handleTap?(toggleButton)
     }
 }
-
-extension AccountSetupController {
-
-    func showProgressHud() {
-        configProgressAlert.actions[0].isEnabled = true
-        configProgressAlert.title = String.localized("configuring_account")
-        configProgressAlert.message = "\n\n\n"	// workaround to create space for progress indicator
-        configProgressIndicator.alpha = 1
-        configProgressIndicator.value = 0
-        present(configProgressAlert, animated: true, completion: nil)
-
-    }
-
-    func updateProgressHud(error message: String?) {
-        configProgressAlert.title = String.localized("login_error_title")
-        configProgressAlert.message = message
-        configProgressIndicator.alpha = 0
-    }
-
-    func updateProgressHudSuccess(callback: (()->())?) {
-        configProgressAlert.actions[0].isEnabled = false
-        configProgressIndicator.alpha = 0
-        configProgressAlert.title = String.localized("login_successful_title")
-        configProgressAlert.message = String.localized("login_successful_message")
-        loginButton.isEnabled = dc_is_configured(mailboxPointer) == 0
-        DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
-            self.configProgressAlert.dismiss(animated: true) {
-                self.handleLoginSuccess()
-            }
-        })
-    }
-
-    private func updateProgressHudValue(value: Int?) {
-        if let value = value {
-            print("progress hud: \(value)")
-            configProgressIndicator.value = CGFloat(value / 10)
-        }
-    }
-
-    func loginCancelled(_ action: UIAlertAction) {
-        DcConfig.addr = nil
-        DcConfig.mailPw = nil
-        DispatchQueue.global(qos: .background).async {
-            dc_stop_ongoing_process(mailboxPointer)		// this function freezes UI so execute in background thread
-        }
-    }
-}

+ 15 - 18
deltachat-ios/DC/events.swift

@@ -52,6 +52,21 @@ public func callbackSwift(event: CInt, data1: CUnsignedLong, data2: CUnsignedLon
             }
         }
 
+    case DC_EVENT_IMEX_PROGRESS:
+        let nc = NotificationCenter.default
+        DispatchQueue.main.async {
+            nc.post(
+                name: dcNotificationBackupProgress,
+                object: nil,
+                userInfo: [
+                    "progress": Int(data1),
+                    "error": Int(data1) == 0,
+                    "done": Int(data1) == 1000,
+                    "errorMessage": AppDelegate.lastErrorDuringConfig as Any,
+                ]
+            )
+        }
+
     case DC_EVENT_ERROR_NETWORK:
         let msg = String(cString: data2String)
         if data1 == 1 {
@@ -130,24 +145,6 @@ public func callbackSwift(event: CInt, data1: CUnsignedLong, data2: CUnsignedLon
     case DC_EVENT_MSG_DELIVERED:
         logger.info("message delivered: \(data1)-\(data2)")
 
-    case DC_EVENT_IMEX_PROGRESS:
-        let nc = NotificationCenter.default
-        DispatchQueue.main.async {
-            nc.post(
-                name: dcNotificationBackupProgress,
-                object: nil,
-                userInfo: [
-                    "progress": Int(data1),
-                    "error": Int(data1) == 0,
-                    "done": Int(data1) == 1000,
-                    "errorMessage": AppDelegate.lastErrorDuringConfig as Any,
-                ]
-            )
-        }
-
-    case DC_EVENT_IMEX_FILE_WRITTEN:
-        logger.info("backup file written: \(String(cString: data1String))")
-
     case DC_EVENT_SECUREJOIN_INVITER_PROGRESS:
         logger.info("securejoin inviter progress \(data1)")
 

+ 0 - 4
deltachat-ios/Helper/Constants.swift

@@ -1,10 +1,6 @@
 import UIKit
 
 struct Constants {
-    // see: https://core.telegram.org/blackberry/chat
-    static let chatColors: [UIColor] = [
-        "#ee4928", "#41a903", "#e09602", "#0f94ed",
-        "#8f3bf7", "#fc4380", "#00a1c4", "#eb7002"].map { s in UIColor(hexString: s) }
     struct Color {
         static let bubble = UIColor(netHex: 0xEFFFDE)
     }

+ 0 - 1
deltachat-ios/en.lproj/Localizable.strings

@@ -632,7 +632,6 @@
 "imap_password" = "your IMAP password";
 "success" = "Success";
 "videos" = "Videos";
-"configuring_account" = "Configuring Account";
 "hide" = "Hide";
 "login_error_title" = "Unable to login!";
 "login_successful_title" = "Login successful!";

+ 0 - 1
tools/untranslated.xml

@@ -7,7 +7,6 @@
     <string name="imap_password">your IMAP password</string>
     <string name="success">Success</string>
     <string name="videos">Videos</string>
-    <string name="configuring_account">Configuring Account</string>
     <string name="hide">Hide</string>
     <string name="login_error_title">Unable to login!</string>
     <string name="login_successful_title">Login successful!</string>