Ver código fonte

body

Signed-off-by: marinofaggiana <marino.faggiana@nextcloud.com>
marinofaggiana 2 anos atrás
pai
commit
378f842d1d

+ 0 - 1
Widget/Dashboard/DashboardData.swift

@@ -76,4 +76,3 @@ func readDashboardData(completion: @escaping (_ dashboardData: [DashboardData],
 
     completion(dashboardDatasTest, false, getTitle(account: account), "\(Date().formatted())")
 }
-

+ 12 - 2
Widget/Nextcloud/NextcloudData.swift

@@ -142,7 +142,7 @@ func readNextcloudData(completion: @escaping (_ NextcloudDatas: [NextcloudData],
         </d:order>
     </d:orderby>
     <d:limit>
-        <d:nresults>5</d:nresults>
+        <d:nresults>20</d:nresults>
     </d:limit>
     </d:basicsearch>
     </d:searchrequest>
@@ -175,13 +175,23 @@ func readNextcloudData(completion: @escaping (_ NextcloudDatas: [NextcloudData],
         NCCommunication.shared.searchBodyRequest(serverUrl: account.urlBase, requestBody: requestBody, showHiddenFiles: CCUtility.getShowHiddenFiles()) { _, files, errorCode, errorDescription in
             var nextcloudDatas: [NextcloudData] = []
             for file in files {
+                guard !file.directory else { continue }
                 let subTitle = CCUtility.dateDiff(file.date as Date) + " · " + CCUtility.transformedSize(file.size)
                 let iconImagePath = CCUtility.getDirectoryProviderStorageIconOcId(file.ocId, etag: file.etag)!
                 //if FileManager().fileExists(atPath: iconImagePath) {
                 //    (cell as! NCCellProtocol).filePreviewImageView?.image =  UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
                 //}
-                let nextcloudData = NextcloudData.init(id: file.ocId, image: iconImagePath, title: file.fileName, subTitle: subTitle, url: URL(string: "https://nextcloud.com/")!)
+
+
+                // Example: nextcloud://open-file?path=Talk/IMG_0000123.jpg&user=marinofaggiana&link=https://cloud.nextcloud.com/f/123
+
+                let path = NCUtilityFileSystem.shared.getPath(path: file.path, user: file.user, fileName: file.fileName)
+                let link = file.urlBase + "/f/" + file.fileId
+                let urlString = "nextcloud://open-file?path=" + path + "&user=" + file.user + "&link=" + link
+                guard let url = URL(string: urlString) else { continue }
+                let nextcloudData = NextcloudData.init(id: file.ocId, image: iconImagePath, title: file.fileName, subTitle: subTitle, url: url)
                 nextcloudDatas.append(nextcloudData)
+                if nextcloudDatas.count == 5 { break}
             }
             if errorCode != 0 {
                 completion(nextcloudDatasTest, true, errorDescription)

+ 5 - 0
iOSClient/AppDelegate.swift

@@ -834,6 +834,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         var serverUrl: String = ""
         var matchedAccount: tableAccount?
 
+        /*
+         Example:
+         nextcloud://open-file?path=Talk/IMG_0000123.jpg&user=marinofaggiana&link=https://cloud.nextcloud.com/f/123
+         */
+
         if scheme == "nextcloud" && action == "open-file" {
 
             if !isSearchingMode, let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {

+ 1 - 1
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -1491,7 +1491,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             cell.fileTitleLabel?.text = metadata.fileName
             cell.fileTitleLabel?.lineBreakMode = .byTruncatingTail
             if metadata.name == NCGlobal.shared.appName {
-                cell.fileInfoLabel?.text = NSLocalizedString("_in_", comment: "") + " " + NCUtilityFileSystem.shared.getPath(metadata: metadata, withFileName: false)
+                cell.fileInfoLabel?.text = NSLocalizedString("_in_", comment: "") + " " + NCUtilityFileSystem.shared.getPath(path: metadata.path, user: metadata.user)
             } else {
                 cell.fileInfoLabel?.text = metadata.subline
                 cell.titleInfoTrailingFull()

+ 1 - 1
iOSClient/Main/NCFunctionCenter.swift

@@ -618,7 +618,7 @@ import Photos
 
         let copyPath = UIAction(title: NSLocalizedString("_copy_path_", comment: ""), image: UIImage(systemName: "doc.on.clipboard")) { _ in
             let board = UIPasteboard.general
-            board.string = NCUtilityFileSystem.shared.getPath(metadata: metadata, withFileName: true)
+            board.string = NCUtilityFileSystem.shared.getPath(path: metadata.path, user: metadata.user, fileName: metadata.fileName)
             NCContentPresenter.shared.messageNotification("", description: "_copied_path_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorNoError)
         }
 

+ 1 - 1
iOSClient/Share/NCSharePaging.swift

@@ -322,7 +322,7 @@ class NCSharePagingView: PagingView {
                 headerView.imageView.image = UIImage(named: "file")
             }
         }
-        headerView.path.text = NCUtilityFileSystem.shared.getPath(metadata: metadata, withFileName: true)
+        headerView.path.text = NCUtilityFileSystem.shared.getPath(path: metadata.path, user: metadata.user, fileName: metadata.fileName)
         headerView.path.textColor = NCBrandColor.shared.label
         headerView.path.trailingBuffer = headerView.path.frame.width
         if metadata.favorite {

+ 5 - 3
iOSClient/Utility/NCUtilityFileSystem.swift

@@ -165,10 +165,12 @@ class NCUtilityFileSystem: NSObject {
         return home
     }
 
-    @objc func getPath(metadata: tableMetadata, withFileName: Bool) -> String {
+    @objc func getPath(path: String, user: String, fileName: String? = nil) -> String {
 
-        var path = metadata.path.replacingOccurrences(of: "/remote.php/dav/files/"+metadata.user, with: "")
-        if withFileName { path += metadata.fileName }
+        var path = path.replacingOccurrences(of: "/remote.php/dav/files/" + user, with: "")
+        if let fileName = fileName {
+            path += fileName
+        }
         return path
     }