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

change Account Request view

marinofaggiana 4 жил өмнө
parent
commit
91753b8836

+ 4 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -297,6 +297,8 @@
 		F7CBC31C24F78E79004D3812 /* NCSortMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7CBC31B24F78E79004D3812 /* NCSortMenu.swift */; };
 		F7D1612023CF19E30039EBBF /* NCViewerRichWorkspace.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7D1611F23CF19E30039EBBF /* NCViewerRichWorkspace.storyboard */; };
 		F7D2C773246470CA008513AE /* XLForm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7D2C772246470CA008513AE /* XLForm.framework */; };
+		F7D57C8626317BDA00DE301D /* NCAccountRequest.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7CA212C25F1333200826ABB /* NCAccountRequest.storyboard */; };
+		F7D57C8B26317BDE00DE301D /* NCAccountRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7CA212B25F1333200826ABB /* NCAccountRequest.swift */; };
 		F7D96FCC246ED7E200536D73 /* NCNetworkingCheckRemoteUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7D96FCB246ED7E100536D73 /* NCNetworkingCheckRemoteUser.swift */; };
 		F7DBC37C23325E02001A85BA /* NCAppConfigView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7DBC37B23325E01001A85BA /* NCAppConfigView.swift */; };
 		F7DBD82C23E46A4700ECB7C6 /* MarkdownKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7DBD82B23E46A4700ECB7C6 /* MarkdownKit.framework */; };
@@ -1808,6 +1810,7 @@
 				F7148059262ED52200693E51 /* NCSectionHeaderMenu.xib in Resources */,
 				F714803B262EBE3900693E51 /* MainInterface.storyboard in Resources */,
 				F7148054262ED51000693E51 /* NCListCell.xib in Resources */,
+				F7D57C8626317BDA00DE301D /* NCAccountRequest.storyboard in Resources */,
 				F7EDE515262DC2CD00414FE6 /* NCSelectCommandViewSelect+CreateFolder.xib in Resources */,
 				F7145A1A1D12E3B700CAFEEC /* Images.xcassets in Resources */,
 				F7EDE50A262DA9D600414FE6 /* NCSelectCommandViewSelect.xib in Resources */,
@@ -1987,6 +1990,7 @@
 				F7B8CD96261AF401007C1359 /* NCNetworkingChunkedUpload.swift in Sources */,
 				F7BAADC91ED5A87C00B7EAD4 /* NCDatabase.swift in Sources */,
 				F7EDE4F4262D7C9A00414FE6 /* NCOperationQueue.swift in Sources */,
+				F7D57C8B26317BDE00DE301D /* NCAccountRequest.swift in Sources */,
 				F780710A1EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m in Sources */,
 				F79EC77F26316193004E59D6 /* NCRenameFile.swift in Sources */,
 				F7EDE4EA262D7C6C00414FE6 /* NCSortMenu.swift in Sources */,

+ 16 - 11
iOSClient/Account Request/NCAccountRequest.swift

@@ -24,6 +24,17 @@
 import Foundation
 import NCCommunication
 
+public protocol NCAccountRequestDelegate {
+    func accountRequestAddAccount()
+    func changeAccountRequestAddAccount()
+}
+
+// optional func
+public extension NCAccountRequestDelegate {
+    func accountRequestAddAccount() {}
+    func changeAccountRequestAddAccount() {}
+}
+
 class NCAccountRequest: UIViewController {
 
     @IBOutlet weak var titleLabel: UILabel!
@@ -34,10 +45,9 @@ class NCAccountRequest: UIViewController {
     public let heightCell: CGFloat = 80
     public var enableTimerProgress: Bool = true
     public var enableAddAccount: Bool = false
-    public var viewController: UIViewController?
     public var dismissDidEnterBackground: Bool = false
+    public var delegate: NCAccountRequestDelegate?
 
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
     private var timer: Timer?
     private var time: Float = 0
     private let secondsAutoDismiss: Float = 3
@@ -149,21 +159,16 @@ extension NCAccountRequest: UITableViewDelegate {
         if indexPath.row == accounts.count {
             
             dismiss(animated: true)
-            appDelegate.openLogin(viewController: viewController, selector: NCGlobal.shared.introLogin, openLoginWeb: false)
+            delegate?.accountRequestAddAccount()
             
         } else {
         
             let account = accounts[indexPath.row]
-            if account.account != appDelegate.account {
+            let activeAccount = NCManageDatabase.shared.getAccountActive()
+            if account.account != activeAccount?.account {
                 NCManageDatabase.shared.setAccountActive(account.account)
                 dismiss(animated: true) {
-                    
-                    NCOperationQueue.shared.cancelAllQueue()
-                    NCNetworking.shared.cancelAllTask()
-                    
-                    self.appDelegate.settingAccount(account.account, urlBase: account.urlBase, user: account.user, userId: account.userId, password: CCUtility.getPassword(account.account))
-                    
-                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+                    self.delegate?.changeAccountRequestAddAccount()
                 }
             } else {
                 dismiss(animated: true)

+ 14 - 1
iOSClient/AppDelegate.swift

@@ -29,7 +29,7 @@ import LocalAuthentication
 import Firebase
 
 @UIApplicationMain
-class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, TOPasscodeViewControllerDelegate {
+class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, TOPasscodeViewControllerDelegate, NCAccountRequestDelegate {
 
     var backgroundSessionCompletionHandler: (() -> Void)?
     var window: UIWindow?
@@ -604,6 +604,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     
     // MARK: - Account Request
     
+    func changeAccountRequestAddAccount() {
+        if let activeAccount = NCManageDatabase.shared.getAccountActive() {
+            
+            NCOperationQueue.shared.cancelAllQueue()
+            NCNetworking.shared.cancelAllTask()
+            
+            settingAccount(activeAccount.account, urlBase: activeAccount.urlBase, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account))
+            
+            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+        }
+    }
+    
     func requestAccount(startTimer: Bool) {
               
         let accounts = NCManageDatabase.shared.getAllAccount()
@@ -616,6 +628,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                 vcAccountRequest.enableTimerProgress = true
                 vcAccountRequest.enableAddAccount = false
                 vcAccountRequest.dismissDidEnterBackground = false
+                vcAccountRequest.delegate = self
                 
                 let screenHeighMax = UIScreen.main.bounds.height - (UIScreen.main.bounds.height/5)
                 let numberCell = accounts.count

+ 18 - 2
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -24,7 +24,7 @@
 import Foundation
 import NCCommunication
 
-class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, UIAdaptivePresentationControllerDelegate, NCEmptyDataSetDelegate, UIContextMenuInteractionDelegate  {
+class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, UIAdaptivePresentationControllerDelegate, NCEmptyDataSetDelegate, UIContextMenuInteractionDelegate, NCAccountRequestDelegate  {
     
     @IBOutlet weak var collectionView: UICollectionView!
 
@@ -663,6 +663,22 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         self.collectionView.reloadData()
     }
     
+    func changeAccountRequestAddAccount() {
+        if let activeAccount = NCManageDatabase.shared.getAccountActive() {
+            
+            NCOperationQueue.shared.cancelAllQueue()
+            NCNetworking.shared.cancelAllTask()
+            
+            appDelegate.settingAccount(activeAccount.account, urlBase: activeAccount.urlBase, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account))
+            
+            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+        }
+    }
+    
+    func accountRequestAddAccount() {
+        appDelegate.openLogin(viewController: self, selector: NCGlobal.shared.introLogin, openLoginWeb: false)
+    }
+    
     @objc func profileButtonTapped(sender: Any) {
         
         let accounts = NCManageDatabase.shared.getAllAccountOrderAlias()
@@ -673,7 +689,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                 vcAccountRequest.accounts = accounts
                 vcAccountRequest.enableTimerProgress = false
                 vcAccountRequest.enableAddAccount = true
-                vcAccountRequest.viewController = self
+                vcAccountRequest.delegate = self
                 vcAccountRequest.dismissDidEnterBackground = true
 
                 let screenHeighMax = UIScreen.main.bounds.height - (UIScreen.main.bounds.height/5)

+ 1 - 1
iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift

@@ -197,7 +197,7 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
                                         let components = disposition.components(separatedBy: "filename=")
                                         if let filename = components.last?.replacingOccurrences(of: "\"", with: "") {
                                             item = CCUtility.getDirectoryUserData() + "/" + filename
-                                            NCUtilityFileSystem.shared.moveFile(atPath: fileNameLocalPath, toPath: item)
+                                            _ = NCUtilityFileSystem.shared.moveFile(atPath: fileNameLocalPath, toPath: item)
                                         }
                                     }
                                 }