diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index a45b68fa2a..a06324d8c1 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/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 = ""; diff --git a/Share/NCShareExtension+Files.swift b/Share/NCShareExtension+Files.swift index b84189ce28..cdf71420bc 100644 --- a/Share/NCShareExtension+Files.swift +++ b/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() { diff --git a/Share/NCShareExtension+NCAccountRequestDelegate.swift b/Share/NCShareExtension+NCAccountRequestDelegate.swift index 7d4a084112..a64f425b12 100644 --- a/Share/NCShareExtension+NCAccountRequestDelegate.swift +++ b/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) diff --git a/Share/NCShareExtension.swift b/Share/NCShareExtension.swift index cae085e73c..05ac2e6bb2 100644 --- a/Share/NCShareExtension.swift +++ b/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) } diff --git a/iOSClient/Data/NCManageDatabase+Metadata.swift b/iOSClient/Data/NCManageDatabase+Metadata.swift index c6beee66c1..3daeabbf47 100644 --- a/iOSClient/Data/NCManageDatabase+Metadata.swift +++ b/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) diff --git a/iOSClient/Extensions/UIAlertController+Extension.swift b/iOSClient/Extensions/UIAlertController+Extension.swift index f808e585a7..d6b7efd5c1 100644 --- a/iOSClient/Extensions/UIAlertController+Extension.swift +++ b/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 } diff --git a/iOSClient/Files/NCFiles.swift b/iOSClient/Files/NCFiles.swift index 66443a5785..08bb1b7186 100644 --- a/iOSClient/Files/NCFiles.swift +++ b/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() diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift index 664ed2765d..60b5d852ed 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift +++ b/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 { diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index a366556fe5..7468064034 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/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, diff --git a/iOSClient/Menu/AppDelegate+Menu.swift b/iOSClient/Menu/AppDelegate+Menu.swift index 06710c40da..c8bce52be1 100644 --- a/iOSClient/Menu/AppDelegate+Menu.swift +++ b/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) }) ) diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index abde11d752..172fe243b2 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/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) } diff --git a/iOSClient/Supporting Files/ar.lproj/Localizable.strings b/iOSClient/Supporting Files/ar.lproj/Localizable.strings index 18398544dd..0906974793 100644 Binary files a/iOSClient/Supporting Files/ar.lproj/Localizable.strings and b/iOSClient/Supporting Files/ar.lproj/Localizable.strings differ diff --git a/iOSClient/Supporting Files/de.lproj/Localizable.strings b/iOSClient/Supporting Files/de.lproj/Localizable.strings index 681188dc8d..4872099d80 100644 Binary files a/iOSClient/Supporting Files/de.lproj/Localizable.strings and b/iOSClient/Supporting Files/de.lproj/Localizable.strings differ diff --git a/iOSClient/Supporting Files/fr.lproj/Localizable.strings b/iOSClient/Supporting Files/fr.lproj/Localizable.strings index 48d31147e3..cd6d6f6350 100644 Binary files a/iOSClient/Supporting Files/fr.lproj/Localizable.strings and b/iOSClient/Supporting Files/fr.lproj/Localizable.strings differ diff --git a/iOSClient/Supporting Files/gl.lproj/Localizable.strings b/iOSClient/Supporting Files/gl.lproj/Localizable.strings index 628590b139..153b488785 100644 Binary files a/iOSClient/Supporting Files/gl.lproj/Localizable.strings and b/iOSClient/Supporting Files/gl.lproj/Localizable.strings differ diff --git a/iOSClient/Supporting Files/it.lproj/Localizable.strings b/iOSClient/Supporting Files/it.lproj/Localizable.strings index dece9ed041..f89e9fdeb3 100644 Binary files a/iOSClient/Supporting Files/it.lproj/Localizable.strings and b/iOSClient/Supporting Files/it.lproj/Localizable.strings differ diff --git a/iOSClient/Supporting Files/pl.lproj/Localizable.strings b/iOSClient/Supporting Files/pl.lproj/Localizable.strings index eb1a4ad851..ac5a09c081 100644 Binary files a/iOSClient/Supporting Files/pl.lproj/Localizable.strings and b/iOSClient/Supporting Files/pl.lproj/Localizable.strings differ diff --git a/iOSClient/Supporting Files/sv.lproj/Localizable.strings b/iOSClient/Supporting Files/sv.lproj/Localizable.strings index 694f8b80df..47562072bb 100644 Binary files a/iOSClient/Supporting Files/sv.lproj/Localizable.strings and b/iOSClient/Supporting Files/sv.lproj/Localizable.strings differ diff --git a/iOSClient/Supporting Files/zh-Hant-TW.lproj/Localizable.strings b/iOSClient/Supporting Files/zh-Hant-TW.lproj/Localizable.strings index 717581b18b..7920eaabf5 100644 Binary files a/iOSClient/Supporting Files/zh-Hant-TW.lproj/Localizable.strings and b/iOSClient/Supporting Files/zh-Hant-TW.lproj/Localizable.strings differ diff --git a/iOSClient/Supporting Files/zh_HK.lproj/Localizable.strings b/iOSClient/Supporting Files/zh_HK.lproj/Localizable.strings index 1d130e3d74..92880bea91 100644 Binary files a/iOSClient/Supporting Files/zh_HK.lproj/Localizable.strings and b/iOSClient/Supporting Files/zh_HK.lproj/Localizable.strings differ