浏览代码

Merge pull request #1735 from deltachat/remove_old_account_switch

remove account switch from settings
cyBerta 2 年之前
父节点
当前提交
9aeab158d8

+ 0 - 4
deltachat-ios.xcodeproj/project.pbxproj

@@ -7,7 +7,6 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
-		21CCE7C528E73AA500BC369E /* AccountSwitcherHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21CCE7C428E73AA500BC369E /* AccountSwitcherHandler.swift */; };
 		21D6C941260623F500D0755A /* NotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21D6C9392606190600D0755A /* NotificationManager.swift */; };
 		3008CB7224F93EB900E6A617 /* AudioMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3008CB7124F93EB900E6A617 /* AudioMessageCell.swift */; };
 		3008CB7424F9436C00E6A617 /* AudioPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3008CB7324F9436C00E6A617 /* AudioPlayerView.swift */; };
@@ -249,7 +248,6 @@
 
 /* Begin PBXFileReference section */
 		08432784282DC739B8EAC1E2 /* Pods-DcShare.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DcShare.debug.xcconfig"; path = "Pods/Target Support Files/Pods-DcShare/Pods-DcShare.debug.xcconfig"; sourceTree = "<group>"; };
-		21CCE7C428E73AA500BC369E /* AccountSwitcherHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSwitcherHandler.swift; sourceTree = "<group>"; };
 		21D6C9392606190600D0755A /* NotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationManager.swift; sourceTree = "<group>"; };
 		21EE28844E7A690D73BF5285 /* Pods-deltachat-iosTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-deltachat-iosTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-deltachat-iosTests/Pods-deltachat-iosTests.debug.xcconfig"; sourceTree = "<group>"; };
 		2F7009234DB9408201A6CDCB /* Pods_deltachat_iosTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_deltachat_iosTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1043,7 +1041,6 @@
 				AEC67A1B241CE9E4007DDBE1 /* AppStateRestorer.swift */,
 				AE8519E92272FDCA00ED86F0 /* DeviceContactsHandler.swift */,
 				AEE700242438E0E500D6992E /* ProgressAlertHandler.swift */,
-				21CCE7C428E73AA500BC369E /* AccountSwitcherHandler.swift */,
 			);
 			path = Handler;
 			sourceTree = "<group>";
@@ -1523,7 +1520,6 @@
 				30E348DF24F3F819005C93D1 /* ChatTableView.swift in Sources */,
 				30EF7308252F6A3300E2C54A /* PaddingTextView.swift in Sources */,
 				30E348E124F53772005C93D1 /* ImageTextCell.swift in Sources */,
-				21CCE7C528E73AA500BC369E /* AccountSwitcherHandler.swift in Sources */,
 				3008CB7624F95B6D00E6A617 /* AudioController.swift in Sources */,
 				3080A035277DE30100E74565 /* String+Extensions.swift in Sources */,
 				302B84CE2397F6CD001C261F /* URL+Extension.swift in Sources */,

+ 1 - 1
deltachat-ios/Controller/ChatListController.swift

@@ -1,7 +1,7 @@
 import UIKit
 import DcCore
 
-class ChatListController: UITableViewController, AccountSwitcherHandler {
+class ChatListController: UITableViewController {
     var viewModel: ChatListViewModel?
     let dcContext: DcContext
     internal let dcAccounts: DcAccounts

+ 5 - 15
deltachat-ios/Controller/SettingsController.swift

@@ -3,7 +3,7 @@ import DcCore
 import DBDebugToolkit
 import Intents
 
-internal final class SettingsViewController: UITableViewController, ProgressAlertHandler, AccountSwitcherHandler {
+internal final class SettingsViewController: UITableViewController, ProgressAlertHandler {
 
     private struct SectionConfigs {
         let headerTitle: String?
@@ -26,10 +26,9 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         case autodel = 11
         case mediaQuality = 12
         case downloadOnDemand = 13
-        case switchAccount = 14
-        case videoChat = 15
-        case connectivity = 16
-        case selectBackground = 17
+        case videoChat = 14
+        case connectivity = 15
+        case selectBackground = 16
     }
 
     private var dcContext: DcContext
@@ -194,14 +193,6 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         return cell
     }()
 
-    private lazy var switchAccountCell: ActionCell = {
-        let cell = ActionCell()
-        cell.tag = CellTags.switchAccount.rawValue
-        cell.actionTitle = String.localized("switch_account")
-        cell.selectionStyle = .default
-        return cell
-    }()
-
     private lazy var helpCell: ActionCell = {
         let cell = ActionCell()
         cell.tag = CellTags.help.rawValue
@@ -233,7 +224,7 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         let profileSection = SectionConfigs(
             headerTitle: String.localized("pref_profile_info_headline"),
             footerTitle: nil,
-            cells: [profileCell, switchAccountCell]
+            cells: [profileCell]
         )
         let preferencesSection = SectionConfigs(
             headerTitle: String.localized("pref_chats_and_media"),
@@ -367,7 +358,6 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         case .sendAutocryptMessage: sendAutocryptSetupMessage()
         case .exportBackup: createBackup()
         case .advanced: showAdvancedDialog()
-        case .switchAccount: showSwitchAccountMenu()
         case .help: showHelp()
         case .connectivity: showConnectivity()
         case .selectBackground: selectBackground()

+ 0 - 80
deltachat-ios/Handler/AccountSwitcherHandler.swift

@@ -1,80 +0,0 @@
-import Foundation
-import UIKit
-import DcCore
-import DBDebugToolkit
-import Intents
-
-protocol AccountSwitcherHandler: UIViewController {
-    var dcAccounts: DcAccounts { get }
-    func showSwitchAccountMenu()
-}
-
-extension AccountSwitcherHandler {
-    func showSwitchAccountMenu() {
-        let accountIds = dcAccounts.getAll()
-        let selectedAccountId = dcAccounts.getSelected().id
-        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
-
-        let prefs = UserDefaults.standard
-        // switch account
-        let menu = UIAlertController(title: String.localized("switch_account"), message: nil, preferredStyle: .safeActionSheet)
-        for accountId in accountIds {
-            let account = dcAccounts.get(id: accountId)
-            let newMessages = account.getFreshMessages().count
-            let messageBadge = newMessages == 0 ? "" : " [" + String(newMessages) + "]"
-            
-            var title = account.displaynameAndAddr
-            title = (selectedAccountId==accountId ? "✔︎ " : "") + title + messageBadge
-            menu.addAction(UIAlertAction(title: title, style: .default, handler: { [weak self] _ in
-                guard let self = self else { return }
-                prefs.setValue(selectedAccountId, forKey: Constants.Keys.lastSelectedAccountKey)
-                _ = self.dcAccounts.select(id: accountId)
-                appDelegate.reloadDcContext()
-            }))
-        }
-
-        // add account
-        menu.addAction(UIAlertAction(title: String.localized("add_account"), style: .default, handler: { [weak self] _ in
-            guard let self = self else { return }
-            prefs.setValue(selectedAccountId, forKey: Constants.Keys.lastSelectedAccountKey)
-            _ = self.dcAccounts.add()
-            appDelegate.reloadDcContext()
-        }))
-
-        // delete account
-        menu.addAction(UIAlertAction(title: String.localized("delete_account"), style: .destructive, handler: { [weak self] _ in
-            let confirm1 = UIAlertController(title: String.localized("delete_account_ask"), message: nil, preferredStyle: .safeActionSheet)
-            confirm1.addAction(UIAlertAction(title: String.localized("delete_account"), style: .destructive, handler: { [weak self] _ in
-                guard let self = self else { return }
-                let account = self.dcAccounts.get(id: selectedAccountId)
-                let confirm2 = UIAlertController(title: account.displaynameAndAddr,
-                    message: String.localized("forget_login_confirmation_desktop"), preferredStyle: .alert)
-                confirm2.addAction(UIAlertAction(title: String.localized("delete"), style: .destructive, handler: { [weak self] _ in
-                    guard let self = self else { return }
-                    appDelegate.locationManager.disableLocationStreamingInAllChats()
-                    self.dcAccounts.stopIo()
-                    _ = self.dcAccounts.remove(id: selectedAccountId)
-                    self.dcAccounts.startIo()
-                    KeychainManager.deleteAccountSecret(id: selectedAccountId)
-                    INInteraction.delete(with: "\(selectedAccountId)", completion: nil)
-                    if self.dcAccounts.getAll().isEmpty {
-                        _ = self.dcAccounts.add()
-                    } else {
-                        let lastSelectedAccountId = prefs.integer(forKey: Constants.Keys.lastSelectedAccountKey)
-                        if lastSelectedAccountId != 0 {
-                            _ = self.dcAccounts.select(id: lastSelectedAccountId)
-                        }
-                    }
-                    appDelegate.reloadDcContext()
-                }))
-                confirm2.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel))
-                self.present(confirm2, animated: true, completion: nil)
-            }))
-            confirm1.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel))
-            self?.present(confirm1, animated: true, completion: nil)
-        }))
-
-        menu.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
-        present(menu, animated: true, completion: nil)
-    }
-}