Browse Source

Version 6.1.1 (#3148)

Marino Faggiana 5 months ago
parent
commit
ab8a66f304

+ 4 - 4
Nextcloud.xcodeproj/project.pbxproj

@@ -5682,7 +5682,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 4;
+				CURRENT_PROJECT_VERSION = 1;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -5709,7 +5709,7 @@
 					"@executable_path/Frameworks",
 					"@executable_path/../../Frameworks",
 				);
-				MARKETING_VERSION = 6.1.0;
+				MARKETING_VERSION = 6.1.1;
 				ONLY_ACTIVE_ARCH = YES;
 				OTHER_CFLAGS = "-v";
 				OTHER_LDFLAGS = "";
@@ -5748,7 +5748,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 4;
+				CURRENT_PROJECT_VERSION = 1;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
@@ -5772,7 +5772,7 @@
 					"@executable_path/Frameworks",
 					"@executable_path/../../Frameworks",
 				);
-				MARKETING_VERSION = 6.1.0;
+				MARKETING_VERSION = 6.1.1;
 				ONLY_ACTIVE_ARCH = YES;
 				OTHER_CFLAGS = "-v";
 				OTHER_LDFLAGS = "";

+ 3 - 2
Share/NCShareExtension+Files.swift

@@ -28,8 +28,9 @@ import NextcloudKit
 
 extension NCShareExtension {
     @objc func reloadDatasource(withLoadFolder: Bool) {
+        let layoutForView = NCManageDatabase.shared.getLayoutForView(account: session.account, key: keyLayout, serverUrl: serverUrl) ?? NCDBLayoutForView()
         let predicate = NSPredicate(format: "account == %@ AND serverUrl == %@ AND directory == true", session.account, serverUrl)
-        let metadatas = self.database.getResultsMetadatasPredicate(predicate, layoutForView: NCDBLayoutForView())
+        let metadatas = self.database.getResultsMetadatasPredicate(predicate, layoutForView: layoutForView)
 
         self.dataSource = NCCollectionViewDataSource(metadatas: metadatas)
 
@@ -49,7 +50,7 @@ extension NCShareExtension {
 
         self.serverUrl += "/" + metadata.fileName
         self.reloadDatasource(withLoadFolder: true)
-        self.setNavigationBar(navigationTitle: metadata.fileName)
+        self.setNavigationBar(navigationTitle: metadata.fileNameView)
     }
 
     func loadFolder() {

+ 6 - 0
Share/NCShareExtension+NCAccountRequestDelegate.swift

@@ -65,6 +65,9 @@ extension NCShareExtension: NCAccountRequestDelegate {
         }
         self.account = account
 
+        // CAPABILITIES
+        database.setCapabilities(account: account)
+
         // COLORS
         NCBrandColor.shared.settingThemingColor(account: account)
         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeTheming, userInfo: ["account": account])
@@ -80,6 +83,9 @@ extension NCShareExtension: NCAccountRequestDelegate {
                                           nextcloudVersion: capabilities.capabilityServerVersionMajor,
                                           groupIdentifier: NCBrandOptions.shared.capabilitiesGroup)
 
+        // SESSION
+        NCSession.shared.appendSession(account: tableAccount.account, urlBase: tableAccount.urlBase, user: tableAccount.user, userId: tableAccount.userId)
+
         // get auto upload folder
         autoUploadFileName = self.database.getAccountAutoUploadFileName()
         autoUploadDirectory = self.database.getAccountAutoUploadDirectory(session: session)

+ 1 - 1
Share/NCShareExtension.swift

@@ -270,7 +270,7 @@ class NCShareExtension: UIViewController {
     }
 
     @objc func actionCreateFolder() {
-        let alertController = UIAlertController.createFolder(serverUrl: serverUrl, account: session.account) { error in
+        let alertController = UIAlertController.createFolder(serverUrl: serverUrl, session: session) { error in
             guard error != .success else { return }
             self.showAlert(title: "_error_createsubfolders_upload_", description: error.errorDescription)
         }

+ 21 - 21
iOSClient/Data/NCManageDatabase+Metadata.swift

@@ -1065,34 +1065,34 @@ extension NCManageDatabase {
         do {
             let realm = try Realm()
             var results = realm.objects(tableMetadata.self).filter(predicate).freeze()
-            if let layoutForView {
-                if layoutForView.sort == "fileName" {
-                    let sortedResults = results.sorted {
-                        // 1. favorite order
-                        if $0.favorite == $1.favorite {
-                            // 2. directory order TOP
-                            if layoutForView.directoryOnTop {
-                                if $0.directory == $1.directory {
-                                    // 3. natural fileName
-                                    return $0.fileNameView.localizedStandardCompare($1.fileNameView) == .orderedAscending
-                                } else {
-                                    return $0.directory && !$1.directory
-                                }
-                            } else {
+            let layout: NCDBLayoutForView = layoutForView ?? NCDBLayoutForView()
+
+            if layout.sort == "fileName" {
+                let sortedResults = results.sorted {
+                    // 1. favorite order
+                    if $0.favorite == $1.favorite {
+                        // 2. directory order TOP
+                        if layout.directoryOnTop {
+                            if $0.directory == $1.directory {
+                                // 3. natural fileName
                                 return $0.fileNameView.localizedStandardCompare($1.fileNameView) == .orderedAscending
+                            } else {
+                                return $0.directory && !$1.directory
                             }
                         } else {
-                            return $0.favorite && !$1.favorite
+                            return $0.fileNameView.localizedStandardCompare($1.fileNameView) == .orderedAscending
                         }
-                    }
-                    return sortedResults
-                } else {
-                    if layoutForView.directoryOnTop {
-                        results = results.sorted(byKeyPath: layoutForView.sort, ascending: layoutForView.ascending).sorted(byKeyPath: "directory", ascending: false).sorted(byKeyPath: "favorite", ascending: false)
                     } else {
-                        results = results.sorted(byKeyPath: layoutForView.sort, ascending: layoutForView.ascending).sorted(byKeyPath: "favorite", ascending: false)
+                        return $0.favorite && !$1.favorite
                     }
                 }
+                return sortedResults
+            } else {
+                if layout.directoryOnTop {
+                    results = results.sorted(byKeyPath: layout.sort, ascending: layout.ascending).sorted(byKeyPath: "favorite", ascending: false).sorted(byKeyPath: "directory", ascending: false)
+                } else {
+                    results = results.sorted(byKeyPath: layout.sort, ascending: layout.ascending).sorted(byKeyPath: "favorite", ascending: false)
+                }
             }
             return Array(results)
 

+ 9 - 24
iOSClient/Extensions/UIAlertController+Extension.swift

@@ -32,17 +32,13 @@ extension UIAlertController {
     ///   - urlBase: UrlBase object
     ///   - completion: If not` nil` it overrides the default behavior which shows an error using `NCContentPresenter`
     /// - Returns: The presentable alert controller
-    static func createFolder(serverUrl: String, account: String, markE2ee: Bool = false, sceneIdentifier: String? = nil, completion: ((_ error: NKError) -> Void)? = nil) -> UIAlertController {
+    static func createFolder(serverUrl: String, session: NCSession.Session, markE2ee: Bool = false, sceneIdentifier: String? = nil, completion: ((_ error: NKError) -> Void)? = nil) -> UIAlertController {
         let alertController = UIAlertController(title: NSLocalizedString("_create_folder_", comment: ""), message: nil, preferredStyle: .alert)
-        let session = NCSession.shared.getSession(account: account)
         let isDirectoryEncrypted = NCUtilityFileSystem().isDirectoryE2EE(session: session, serverUrl: serverUrl)
 
         let okAction = UIAlertAction(title: NSLocalizedString("_save_", comment: ""), style: .default, handler: { _ in
             guard let fileNameFolder = alertController.textFields?.first?.text else { return }
             if markE2ee {
-                if NCNetworking.shared.isOffline {
-                    return NCContentPresenter().showInfo(error: NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_offline_not_allowed_"))
-                }
                 Task {
                     let createFolderResults = await NCNetworking.shared.createFolder(serverUrlFileName: serverUrl + "/" + fileNameFolder, account: session.account)
                     if createFolderResults.error == .success {
@@ -55,28 +51,17 @@ extension UIAlertController {
                     }
                 }
             } else if isDirectoryEncrypted {
-                if NCNetworking.shared.isOffline {
-                    return NCContentPresenter().showInfo(error: NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_offline_not_allowed_"))
-                }
-                #if !EXTENSION
                 Task {
                     await NCNetworkingE2EECreateFolder().createFolder(fileName: fileNameFolder, serverUrl: serverUrl, withPush: true, sceneIdentifier: sceneIdentifier, session: session)
                 }
-                #endif
             } else {
-                let metadataForCreateFolder = NCManageDatabase.shared.createMetadata(fileName: fileNameFolder,
-                                                                                     fileNameView: fileNameFolder,
-                                                                                     ocId: NSUUID().uuidString,
-                                                                                     serverUrl: serverUrl,
-                                                                                     url: "",
-                                                                                     contentType: "httpd/unix-directory",
-                                                                                     directory: true,
-                                                                                     session: session,
-                                                                                     sceneIdentifier: sceneIdentifier)
-                metadataForCreateFolder.status = NCGlobal.shared.metadataStatusWaitCreateFolder
-                metadataForCreateFolder.sessionDate = Date()
-                NCManageDatabase.shared.addMetadata(metadataForCreateFolder)
-                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterCreateFolder, userInfo: ["ocId": metadataForCreateFolder.ocId, "serverUrl": metadataForCreateFolder.serverUrl, "account": metadataForCreateFolder.account, "withPush": true, "sceneIdentifier": sceneIdentifier as Any])
+                NCNetworking.shared.createFolder(fileName: fileNameFolder, serverUrl: serverUrl, overwrite: false, withPush: true, sceneIdentifier: sceneIdentifier, session: session) { error in
+                    if let completion = completion {
+                        DispatchQueue.main.async { completion(error) }
+                    } else if error != .success {
+                        NCContentPresenter().showError(error: error)
+                    } // else: successful, no action
+                }
             }
         })
 
@@ -96,7 +81,7 @@ extension UIAlertController {
                 guard let text = alertController.textFields?.first?.text else { return }
                 let folderName = text.trimmingCharacters(in: .whitespaces)
 
-                let textCheck = FileNameValidator.shared.checkFileName(folderName, account: account)
+                let textCheck = FileNameValidator.shared.checkFileName(folderName, account: session.account)
                 okAction.isEnabled = textCheck?.error == nil && !folderName.isEmpty
                 alertController.message = textCheck?.error.localizedDescription
             }

+ 4 - 0
iOSClient/Files/NCFiles.swift

@@ -120,6 +120,10 @@ class NCFiles: NCCollectionViewCommon {
     // MARK: - DataSource
 
     override func reloadDataSource() {
+        guard !isSearchingMode else {
+            return super.reloadDataSource()
+        }
+
         var predicate = self.defaultPredicate
         let predicateDirectory = NSPredicate(format: "account == %@ AND serverUrl == %@", session.account, self.serverUrl)
         let dataSourceMetadatas = self.dataSource.getMetadatas()

+ 7 - 0
iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift

@@ -143,6 +143,13 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             }
         }
 
+        // E2EE create preview
+        if self.isDirectoryEncrypted,
+           metadata.isImageOrVideo,
+           !utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag) {
+            utility.createImageFileFrom(metadata: metadata)
+        }
+
         // LAYOUT PHOTO
         if isLayoutPhoto {
             if metadata.isImageOrVideo {

+ 8 - 3
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -47,6 +47,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     var backgroundImageView = UIImageView()
     var serverUrl: String = ""
     var isEditMode = false
+    var isDirectoryEncrypted = false
     var fileSelect: [String] = []
     var metadataFolder: tableMetadata?
     var richWorkspaceText: String?
@@ -825,7 +826,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
                 NCKeychain().setPersonalFilesOnly(account: self.session.account, value: !personalFilesOnly)
 
-                self.reloadDataSource()
+                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl": self.serverUrl, "clearDataSource": true])
                 self.setNavigationRightItems()
             }
 
@@ -834,7 +835,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
                 NCKeychain().showDescription = !showDescriptionKeychain
 
-                self.reloadDataSource()
+                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl": self.serverUrl, "clearDataSource": true])
                 self.setNavigationRightItems()
             }
             showDescription.subtitle = richWorkspaceText == nil ? NSLocalizedString("_no_description_available_", comment: "") : ""
@@ -1038,7 +1039,11 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     // MARK: - DataSource
 
     @objc func reloadDataSource() {
-        guard !session.account.isEmpty, !self.isSearchingMode else { return }
+        if isSearchingMode {
+            isDirectoryEncrypted = false
+        } else {
+            isDirectoryEncrypted = NCUtilityFileSystem().isDirectoryE2EE(session: session, serverUrl: serverUrl)
+        }
 
         DispatchQueue.main.async {
             UIView.transition(with: self.collectionView,

+ 2 - 2
iOSClient/Menu/AppDelegate+Menu.swift

@@ -105,7 +105,7 @@ extension AppDelegate {
         actions.append(
             NCMenuAction(title: titleCreateFolder,
                          icon: imageCreateFolder, action: { _ in
-                             let alertController = UIAlertController.createFolder(serverUrl: serverUrl, account: session.account, sceneIdentifier: controller.sceneIdentifier)
+                             let alertController = UIAlertController.createFolder(serverUrl: serverUrl, session: session, sceneIdentifier: controller.sceneIdentifier)
                              controller.present(alertController, animated: true, completion: nil)
                          }
                         )
@@ -117,7 +117,7 @@ extension AppDelegate {
                 NCMenuAction(title: NSLocalizedString("_create_folder_e2ee_", comment: ""),
                              icon: NCImageCache.shared.getFolderEncrypted(account: session.account),
                              action: { _ in
-                                 let alertController = UIAlertController.createFolder(serverUrl: serverUrl, account: session.account, markE2ee: true, sceneIdentifier: controller.sceneIdentifier)
+                                 let alertController = UIAlertController.createFolder(serverUrl: serverUrl, session: session, markE2ee: true, sceneIdentifier: controller.sceneIdentifier)
                                  controller.present(alertController, animated: true, completion: nil)
                              })
             )

+ 1 - 1
iOSClient/Select/NCSelect.swift

@@ -213,7 +213,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
     }
 
     func createFolderButtonPressed(_ sender: UIButton) {
-        let alertController = UIAlertController.createFolder(serverUrl: serverUrl, account: session.account)
+        let alertController = UIAlertController.createFolder(serverUrl: serverUrl, session: session)
         self.present(alertController, animated: true, completion: nil)
     }
 

BIN
iOSClient/Supporting Files/ar.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/de.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/fr.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/gl.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/it.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/pl.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/sv.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/zh-Hant-TW.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/zh_HK.lproj/Localizable.strings