marinofaggiana 4 年 前
コミット
2e6d411dcd

+ 7 - 1
iOSClient/AppDelegate.swift

@@ -34,10 +34,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     var activeViewController: UIViewController?
     var activeViewerVideo: NCViewerVideo?
     
+    struct progressType {
+        var progress: Float
+        var totalBytes: Int64
+        var totalBytesExpected: Int64
+    }
+    
     var listFilesVC: [String:NCFiles] = [:]
     var listFavoriteVC: [String:NCFavorite] = [:]
     var listOfflineVC: [String:NCOffline] = [:]
-    var listProgressMetadata: [String:tableMetadata] = [:]
+    var listProgress: [String:progressType] = [:]
     
     var disableSharesView: Bool = false
     var documentPickerViewController: NCDocumentPickerViewController?

+ 0 - 1
iOSClient/Login/CCLogin.m

@@ -22,7 +22,6 @@
 //
 
 #import "CCLogin.h"
-#import "AppDelegate.h"
 #import "CCUtility.h"
 #import "NSNotificationCenter+MainThread.h"
 #import "NCBridgeSwift.h"

+ 12 - 9
iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift

@@ -231,7 +231,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
     @objc func initializeMain() {
         
-        if appDelegate.account == nil || appDelegate.account.count == 0 { return }
+        if appDelegate.account == "" { return }
         
         if searchController?.isActive ?? false {
             searchController?.isActive = false
@@ -506,8 +506,11 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                 let status = userInfo["status"] as? Int ?? NCBrandGlobal.shared.metadataStatusNormal
                 let totalBytes = userInfo["totalBytes"] as? Int64 ?? 0
                 let totalBytesExpected = userInfo["totalBytesExpected"] as? Int64 ?? 0
+                        
+                let progressType = AppDelegate.progressType(progress: progress, totalBytes: totalBytes, totalBytesExpected: totalBytesExpected)
+                appDelegate.listProgress[ocId] = progressType
                 
-                appDelegate.listProgressMetadata.setObject([progress as NSNumber, totalBytes as NSNumber, totalBytesExpected as NSNumber], forKey: userInfo["ocId"] as? NSString ?? "")
+                //appDelegate.listProgressMetadata.setObject([progress as NSNumber, totalBytes as NSNumber, totalBytesExpected as NSNumber], forKey: userInfo["ocId"] as? NSString ?? "")
                 
                 if let index = dataSource.getIndexMetadata(ocId: ocId) {
                     if let cell = collectionView?.cellForItem(at: IndexPath(row: index, section: 0)) {
@@ -778,7 +781,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     
     @objc func reloadDataSource() {
         
-        if appDelegate.account == nil || appDelegate.account.count == 0 { return }
+        if appDelegate.account == "" { return }
         
         // Get richWorkspace Text
         let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl))
@@ -800,7 +803,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     }
     @objc func networkSearch() {
         
-        if appDelegate.account == nil || appDelegate.account.count == 0 { return }
+        if appDelegate.account == "" { return }
         
         if literalSearch?.count ?? 0 > 1 {
         
@@ -1267,7 +1270,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 cell.imageShared.image = NCCollectionCommon.images.cellCanShareImage
             }
             if metadata.ownerId.count > 0 && metadata.ownerId != appDelegate.userID {
-                let fileNameUser = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase) + "-" + metadata.ownerId + ".png"
+                var fileNameUser = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase) + "-" + metadata.ownerId
+                fileNameUser = fileNameUser + ".png"
                 if FileManager.default.fileExists(atPath: fileNameUser) {
                     cell.imageShared.avatar()
                     cell.imageShared.image = UIImage(contentsOfFile: fileNameUser)
@@ -1284,10 +1288,9 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             // Transfer
             var progress: Float = 0.0
             var totalBytes: Int64 = 0
-            let progressArray = appDelegate.listProgressMetadata.object(forKey: metadata.ocId) as? NSArray
-            if progressArray != nil && progressArray?.count == 3 {
-                progress = progressArray?.object(at: 0) as? Float ?? 0
-                totalBytes = progressArray?.object(at: 1) as? Int64 ?? 0
+            if let progressType = appDelegate.listProgress[metadata.ocId] {
+                progress = progressType.progress
+                totalBytes = progressType.totalBytes
             }
             if metadata.status == NCBrandGlobal.shared.metadataStatusInDownload || metadata.status == NCBrandGlobal.shared.metadataStatusDownloading ||  metadata.status >= NCBrandGlobal.shared.metadataStatusTypeUpload {
                 cell.progressView.isHidden = false

+ 2 - 2
iOSClient/PushNotification/NCPushNotification.m

@@ -21,14 +21,14 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-#import "AppDelegate.h"
 #import "NCBridgeSwift.h"
 #import "NCPushNotification.h"
 #import "NCPushNotificationEncryption.h"
+#import "CCUtility.h"
 
 @interface NCPushNotification ()
 {
-    AppDelegate *appDelegate;
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
 }
 @end
 

+ 0 - 1
iOSClient/Settings/Acknowledgements.m

@@ -22,7 +22,6 @@
 //
 
 #import "Acknowledgements.h"
-#import "AppDelegate.h"
 
 @interface Acknowledgements ()
 {

+ 1 - 1
iOSClient/Settings/CCManageAccount.m

@@ -22,10 +22,10 @@
 //
 
 #import "CCManageAccount.h"
-#import "AppDelegate.h"
 #import "CCLogin.h"
 #import "NSNotificationCenter+MainThread.h"
 #import "NCBridgeSwift.h"
+#import "CCUtility.h"
 
 #define actionSheetCancellaAccount 1
 

+ 0 - 1
iOSClient/Settings/CCManageAutoUpload.m

@@ -22,7 +22,6 @@
 //
 
 #import "CCManageAutoUpload.h"
-#import "AppDelegate.h"
 #import "NCBridgeSwift.h"
 
 @interface CCManageAutoUpload () <NCSelectDelegate>

+ 1 - 1
iOSClient/Settings/NCManageEndToEndEncryption.m

@@ -22,10 +22,10 @@
 //
 
 #import "NCManageEndToEndEncryption.h"
-#import "AppDelegate.h"
 #import "NSNotificationCenter+MainThread.h"
 #import <TOPasscodeViewController/TOPasscodeViewController.h>
 #import "NCBridgeSwift.h"
+#import "CCUtility.h"
 
 @interface NCManageEndToEndEncryption () <NCEndToEndInitializeDelegate, TOPasscodeViewControllerDelegate>
 {

+ 0 - 1
iOSClient/Settings/NCSettings.m

@@ -22,7 +22,6 @@
 //
 
 #import "NCSettings.h"
-#import "AppDelegate.h"
 #import "CCAdvanced.h"
 #import "CCManageAccount.h"
 #import "CCManageAutoUpload.h"

+ 0 - 6
iOSClient/Settings/NCSettingsBundleHelper.swift

@@ -24,12 +24,6 @@
 import Foundation
 
 class NCSettingsBundleHelper: NSObject {
-    struct SettingsBundleKeys {
-        static let AppVersionKey = "version_preference"
-    }
-    
-    class func checkAndExecuteSettings() {
-    }
     
     @objc class func setVersionAndBuildNumber() {
         let version = NCUtility.shared.getVersionApp() as String

+ 4 - 5
iOSClient/Transfers/NCTransfers.swift

@@ -207,11 +207,10 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate  {
         
         // Transfer
         var progress: Float = 0.0
-        var totalBytes: Int64 = 0        
-        let progressArray = appDelegate.listProgressMetadata.object(forKey: metadata.ocId) as? NSArray
-        if progressArray != nil && progressArray?.count == 3 {
-            progress = progressArray?.object(at: 0) as? Float ?? 0
-            totalBytes = progressArray?.object(at: 1) as? Int64 ?? 0
+        var totalBytes: Int64 = 0
+        if let progressType = appDelegate.listProgress[metadata.ocId] {
+            progress = progressType.progress
+            totalBytes = progressType.totalBytes
         }
         
         if metadata.status == NCBrandGlobal.shared.metadataStatusInDownload || metadata.status == NCBrandGlobal.shared.metadataStatusDownloading ||  metadata.status >= NCBrandGlobal.shared.metadataStatusTypeUpload {