Browse Source

improvements (#2594)

* improvements

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

* lint

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

* improvements notificationCenterInitialize

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

* cleaning

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

* build 7

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

---------

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 1 year ago
parent
commit
c996034c3f

+ 2 - 2
Nextcloud.xcodeproj/project.pbxproj

@@ -4670,7 +4670,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 6;
+				CURRENT_PROJECT_VERSION = 7;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -4735,7 +4735,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 6;
+				CURRENT_PROJECT_VERSION = 7;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;

+ 1 - 11
iOSClient/Activity/NCActivity.swift

@@ -101,13 +101,11 @@ class NCActivity: UIViewController, NCSharePagingContent {
 
         navigationController?.setFileAppreance()
 
-        NotificationCenter.default.addObserver(self, selector: #selector(initialize), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
-        initialize()
+        fetchAll(isInitial: true)
     }
 
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
-        NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
     }
 
     override func viewWillLayoutSubviews() {
@@ -119,14 +117,6 @@ class NCActivity: UIViewController, NCSharePagingContent {
         viewContainerConstraint.constant = height
     }
 
-    // MARK: - NotificationCenter
-
-    @objc func initialize() {
-        loadDataSource()
-        fetchAll(isInitial: true)
-        view.setNeedsLayout()
-    }
-
     func makeTableFooterView() -> UIView {
         let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 100))
         view.backgroundColor = .clear

+ 3 - 8
iOSClient/Data/NCManageDatabase+Metadata.swift

@@ -251,16 +251,11 @@ extension tableMetadata {
     // Return if is sharable
     func isSharable() -> Bool {
         guard NCGlobal.shared.capabilityFileSharingApiEnabled else { return false }
-
-        if NCGlobal.shared.capabilityE2EEApiVersion == NCGlobal.shared.e2eeVersionV20, isDirectoryE2EE {
-            return e2eEncrypted
-        } else if !e2eEncrypted && !isDirectoryE2EE {
-            return true
-        } else if NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion26 && directory {
+        if isDirectoryE2EE || e2eEncrypted {
+            guard directory, NCGlobal.shared.capabilityE2EEEnabled else { return false }
             return true
-        } else {
-            return false
         }
+        return true
     }
 }
 

+ 33 - 15
iOSClient/Files/NCFiles.swift

@@ -46,6 +46,39 @@ class NCFiles: NCCollectionViewCommon {
         emptyDescription = "_no_file_pull_down_"
     }
 
+    override func viewDidLoad() {
+        super.viewDidLoad()
+
+        if isRoot {
+            NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil, queue: nil) { _ in
+
+                self.navigationController?.popToRootViewController(animated: false)
+
+                self.serverUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: self.appDelegate.urlBase, userId: self.appDelegate.userId)
+                self.appDelegate.activeServerUrl = self.serverUrl
+
+                self.isSearchingMode = false
+                self.isEditMode = false
+                self.selectOcId.removeAll()
+                self.selectIndexPath.removeAll()
+
+                self.layoutForView = NCManageDatabase.shared.getLayoutForView(account: self.appDelegate.account, key: self.layoutKey, serverUrl: self.serverUrl)
+                self.gridLayout.itemForLine = CGFloat(self.layoutForView?.itemForLine ?? 3)
+                if self.layoutForView?.layout == NCGlobal.shared.layoutList {
+                    self.collectionView?.collectionViewLayout = self.listLayout
+                } else {
+                    self.collectionView?.collectionViewLayout = self.gridLayout
+                }
+
+                self.titleCurrentFolder = self.getNavigationTitle()
+                self.setNavigationItem()
+
+                self.reloadDataSource(isForced: false)
+                self.reloadDataSourceNetwork()
+            }
+        }
+    }
+
     override func viewWillAppear(_ animated: Bool) {
 
         if isRoot {
@@ -53,7 +86,6 @@ class NCFiles: NCCollectionViewCommon {
             titleCurrentFolder = getNavigationTitle()
         }
         super.viewWillAppear(animated)
-
         navigationController?.setFileAppreance()
     }
 
@@ -64,20 +96,6 @@ class NCFiles: NCCollectionViewCommon {
         fileNameOpen = nil
     }
 
-    // MARK: - NotificationCenter
-
-    override func initialize() {
-
-        if isRoot {
-            serverUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId)
-            titleCurrentFolder = getNavigationTitle()
-        }
-        super.initialize()
-
-        reloadDataSource(isForced: false)
-        reloadDataSourceNetwork()
-    }
-
     // MARK: - DataSource + NC Endpoint
     //
     // forced: do no make the etag of directory test (default)

+ 12 - 50
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -156,8 +156,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
         tipView = EasyTipView(text: NSLocalizedString("_tip_accountrequest_", comment: ""), preferences: preferences, delegate: self)
 
-        // Notification
-        NotificationCenter.default.addObserver(self, selector: #selector(initialize), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
     }
 
@@ -276,49 +274,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
     // MARK: - NotificationCenter
 
-    @objc func initialize() {
-        guard !appDelegate.account.isEmpty else { return }
-
-        // Search
-        if searchController?.isActive ?? false || isSearchingMode {
-            searchController?.isActive = false
-            isSearchingMode = false
-        }
-
-        // Select
-        if isEditMode {
-            isEditMode = !isEditMode
-            selectOcId.removeAll()
-            selectIndexPath.removeAll()
-        }
-
-        if self.view?.window != nil {
-            if serverUrl == "" {
-                appDelegate.activeServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId)
-            } else {
-                appDelegate.activeServerUrl = serverUrl
-            }
-
-            appDelegate.listFilesVC.removeAll()
-            appDelegate.listFavoriteVC.removeAll()
-            appDelegate.listOfflineVC.removeAll()
-        }
-
-        if serverUrl != "" {
-            self.navigationController?.popToRootViewController(animated: false)
-        }
-
-        layoutForView = NCManageDatabase.shared.getLayoutForView(account: appDelegate.account, key: layoutKey, serverUrl: serverUrl)
-        gridLayout.itemForLine = CGFloat(layoutForView?.itemForLine ?? 3)
-        if layoutForView?.layout == NCGlobal.shared.layoutList {
-            collectionView?.collectionViewLayout = listLayout
-        } else {
-            collectionView?.collectionViewLayout = gridLayout
-        }
-
-        setNavigationItem()
-    }
-
     @objc func applicationWillResignActive(_ notification: NSNotification) {
         self.refreshControl.endRefreshing()
     }
@@ -1294,11 +1249,18 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
             return
         }
 
-        if metadata.e2eEncrypted && !CCUtility.isEnd(toEndEnabled: appDelegate.account) {
-            let e2ee = NCEndToEndInitialize()
-            e2ee.delegate = self
-            e2ee.initEndToEndEncryption()
-            return
+        if metadata.e2eEncrypted {
+            if NCGlobal.shared.capabilityE2EEEnabled {
+                if !CCUtility.isEnd(toEndEnabled: appDelegate.account) {
+                    let e2ee = NCEndToEndInitialize()
+                    e2ee.delegate = self
+                    e2ee.initEndToEndEncryption()
+                    return
+                }
+            } else {
+                NCContentPresenter.shared.showInfo(error: NKError(errorCode: NCGlobal.shared.errorE2EENotEnabled, errorDescription: "_e2e_server_disabled_"))
+                return
+            }
         }
 
         if metadata.directory {

+ 0 - 14
iOSClient/Media/NCMedia.swift

@@ -91,9 +91,6 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
         // Empty
         emptyDataSet = NCEmptyDataSet(view: collectionView, offset: 0, delegate: self)
 
-        // Notification
-        NotificationCenter.default.addObserver(self, selector: #selector(initialize), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
-
         mediaCommandView = Bundle.main.loadNibNamed("NCMediaCommandView", owner: self, options: nil)?.first as? NCMediaCommandView
         self.view.addSubview(mediaCommandView!)
         mediaCommandView?.mediaView = self
@@ -160,17 +157,6 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
 
     // MARK: - NotificationCenter
 
-    @objc func initialize() {
-
-        self.reloadDataSourceWithCompletion { _ in
-            self.timerSearchNewMedia?.invalidate()
-            self.timerSearchNewMedia = Timer.scheduledTimer(timeInterval: self.timeIntervalSearchNewMedia, target: self, selector: #selector(self.searchNewMediaTimer), userInfo: nil, repeats: false)
-            DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
-                self.mediaCommandTitle()
-            }
-        }
-    }
-
     @objc func deleteFile(_ notification: NSNotification) {
 
         guard let userInfo = notification.userInfo as NSDictionary?,

+ 0 - 9
iOSClient/More/NCMore.swift

@@ -74,9 +74,6 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         let tapQuota = UITapGestureRecognizer(target: self, action: #selector(tapLabelQuotaExternalSite))
         labelQuotaExternalSite.isUserInteractionEnabled = true
         labelQuotaExternalSite.addGestureRecognizer(tapQuota)
-
-        // Notification
-        NotificationCenter.default.addObserver(self, selector: #selector(initialize), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
     }
 
     override func viewWillAppear(_ animated: Bool) {
@@ -89,12 +86,6 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         tableView.reloadData()
     }
 
-    // MARK: - NotificationCenter
-
-    @objc func initialize() {
-        loadItems()
-    }
-
     // MARK: -
 
     func loadItems() {

+ 0 - 16
iOSClient/Notification/NCNotification.swift

@@ -65,30 +65,14 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
         super.viewWillAppear(animated)
 
         appDelegate.activeViewController = self
-
         navigationController?.setFileAppreance()
-
-        NotificationCenter.default.addObserver(self, selector: #selector(initialize), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
-
         getNetwokingNotification()
     }
 
-    override func viewWillDisappear(_ animated: Bool) {
-        super.viewWillDisappear(animated)
-
-        NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
-    }
-
     @objc func viewClose() {
         self.dismiss(animated: true, completion: nil)
     }
 
-    // MARK: - NotificationCenter
-
-    @objc func initialize() {
-        getNetwokingNotification()
-    }
-
     // MARK: - Empty
 
     func emptyDataSetView(_ view: NCEmptyView) {

+ 1 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -697,6 +697,7 @@
 "_e2e_settings_start_"              = "Start end-to-end encryption";
 "_e2e_settings_not_available_"      = "End-to-end encryption not available";
 "_e2e_settings_activated_"          = "End-to-end encryption activated";
+"_e2e_server_disabled_"             = "End-to-end encryption app disabled on server";
 "_e2e_settings_view_passphrase_"    = "All 12 words together make a very strong password, letting only you view and make use of your encrypted files. Please write it down and keep it somewhere safe.";
 "_e2e_settings_read_passphrase_"    = "Read passphrase";
 "_e2e_settings_lock_not_active_"    = "Lock not active, go back to \"Settings\" and activate it";

+ 1 - 2
iOSClient/Utility/CCUtility.m

@@ -364,7 +364,6 @@
 
 + (BOOL)isEndToEndEnabled:(NSString *)account
 {
-    BOOL isE2EEEnabled = [[NCGlobal shared] capabilityE2EEEnabled];
     NSString* versionE2EE = [[NCGlobal shared] capabilityE2EEApiVersion];
 
     NSString *certificate = [self getEndToEndCertificate:account];
@@ -372,7 +371,7 @@
     NSString *privateKey = [self getEndToEndPrivateKey:account];
     NSString *passphrase = [self getEndToEndPassphrase:account];
             
-    if (passphrase.length > 0 && privateKey.length > 0 && certificate.length > 0 && publicKey.length > 0 && isE2EEEnabled && [NCGlobal.shared.e2eeVersions containsObject:versionE2EE]) {
+    if (passphrase.length > 0 && privateKey.length > 0 && certificate.length > 0 && publicKey.length > 0 && [NCGlobal.shared.e2eeVersions containsObject:versionE2EE]) {
         return YES;
     } else {
         return NO;