Browse Source

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 years ago
parent
commit
cadd5c57ec

+ 4 - 2
iOSClient/Brand/NCBrand.swift

@@ -141,9 +141,10 @@ class NCBrandColor: NSObject {
         static var buttonRestore = UIImage()
 
         static var iconContacts = UIImage()
-        static var iconConversation = UIImage()
+        static var iconTalk = UIImage()
         static var iconCalendar = UIImage()
         static var iconDeck = UIImage()
+        static var iconMail = UIImage()
     }
 
     // Color
@@ -365,9 +366,10 @@ class NCBrandColor: NSObject {
         cacheImages.buttonRestore = UIImage(named: "restore")!.image(color: gray, size: 50)
 
         cacheImages.iconContacts = UIImage(named: "icon-contacts")!.image(color: brandElement, size: folderWidth)
-        cacheImages.iconConversation = UIImage(named: "icon-conversation")!.image(color: brandElement, size: folderWidth)
+        cacheImages.iconTalk = UIImage(named: "icon-talk")!.image(color: brandElement, size: folderWidth)
         cacheImages.iconCalendar = UIImage(named: "icon-calendar")!.image(color: brandElement, size: folderWidth)
         cacheImages.iconDeck = UIImage(named: "icon-deck")!.image(color: brandElement, size: folderWidth)
+        cacheImages.iconMail = UIImage(named: "icon-mail")!.image(color: brandElement, size: folderWidth)
     }
 
     #if !EXTENSION

+ 1 - 0
iOSClient/Data/NCDatabase.swift

@@ -384,6 +384,7 @@ class tableMetadata: Object, NCUserBaseUrl {
     @objc dynamic var fileNameWithoutExt = ""
     @objc dynamic var hasPreview: Bool = false
     @objc dynamic var iconName = ""
+    @objc dynamic var iconUrl = ""
     @objc dynamic var livePhoto: Bool = false
     @objc dynamic var mountType = ""
     @objc dynamic var name = ""

+ 5 - 2
iOSClient/Data/NCManageDatabase+Metadata.swift

@@ -164,7 +164,7 @@ extension NCManageDatabase {
         completion(metadataFolder, metadataFolders, metadatas)
     }
 
-    @objc func createMetadata(account: String, user: String, userId: String, fileName: String, fileNameView: String, ocId: String, serverUrl: String, urlBase: String, url: String, contentType: String, isLivePhoto: Bool = false, isUrl: Bool = false, name: String = "files", subline: String? = nil, iconName: String? = nil) -> tableMetadata {
+    @objc func createMetadata(account: String, user: String, userId: String, fileName: String, fileNameView: String, ocId: String, serverUrl: String, urlBase: String, url: String, contentType: String, isLivePhoto: Bool = false, isUrl: Bool = false, name: String = "files", subline: String? = nil, iconName: String? = nil, iconUrl: String? = nil) -> tableMetadata {
 
         let metadata = tableMetadata()
         if isUrl {
@@ -181,7 +181,10 @@ extension NCManageDatabase {
             metadata.iconName = iconName
             metadata.classFile = classFile
         }
-        
+        if let iconUrl = iconUrl {
+            metadata.iconUrl = iconUrl
+        }
+
         let fileName = fileName.trimmingCharacters(in: .whitespacesAndNewlines)
 
         metadata.account = account

+ 12 - 0
iOSClient/Images.xcassets/icon-mail.imageset/Contents.json

@@ -0,0 +1,12 @@
+{
+  "images" : [
+    {
+      "filename" : "icon-mail.svg",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 1 - 0
iOSClient/Images.xcassets/icon-mail.imageset/icon-mail.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V8l8 5 8-5v10zm-8-7L4 6h16l-8 5z"/></svg>

+ 0 - 0
iOSClient/Images.xcassets/icon-conversation.imageset/Contents.json → iOSClient/Images.xcassets/icon-talk.imageset/Contents.json


+ 0 - 0
iOSClient/Images.xcassets/icon-conversation.imageset/icon-conversation.svg → iOSClient/Images.xcassets/icon-talk.imageset/icon-conversation.svg


+ 29 - 9
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -1234,8 +1234,9 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
     @available(iOS 13.0, *)
     func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
 
-        if isEditMode { return nil }
         guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return nil }
+        if isEditMode || metadata.classFile == NCCommunicationCommon.typeClassFile.url.rawValue { return nil }
+
         let identifier = indexPath as NSCopying
         var image: UIImage?
         let cell = collectionView.cellForItem(at: indexPath)
@@ -1319,14 +1320,19 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 case let str where str.contains("contacts"):
                     (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconContacts
                 case let str where str.contains("conversation"):
-                    (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconConversation
+                    (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconTalk
                 case let str where str.contains("calendar"):
                     (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconCalendar
                 case let str where str.contains("deck"):
                     (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconDeck
+                case let str where str.contains("mail"):
+                    (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconMail
+                case let str where str.contains("talk"):
+                    (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconTalk
                 default:
                     (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.file
                 }
+                print(metadata.iconUrl)
             }
         }
 
@@ -1416,6 +1422,9 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             cell.imageItem.image = nil
             cell.imageItem.backgroundColor = nil
 
+            cell.hideButtonShare(false)
+            cell.hideButtonMore(false)
+
             // Progress
             var progress: Float = 0.0
             var totalBytes: Int64 = 0
@@ -1547,8 +1556,17 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             // E2EE
             if metadata.e2eEncrypted || isEncryptedFolder {
                 cell.hideButtonShare(true)
-            } else {
-                cell.hideButtonShare(false)
+            }
+
+            // URL
+            if metadata.classFile == NCCommunicationCommon.typeClassFile.url.rawValue {
+                cell.hideButtonShare(true)
+                cell.hideButtonMore(true)
+            }
+
+            // Disable Share Button
+            if appDelegate.disableSharesView {
+                cell.hideButtonShare(true)
             }
 
             // Remove last separator
@@ -1572,11 +1590,6 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             }
             cell.accessibilityValue = a11yValues.joined(separator: ", ")
 
-            // Disable Share Button
-            if appDelegate.disableSharesView {
-                cell.hideButtonShare(true)
-            }
-
             return cell
         }
 
@@ -1601,6 +1614,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             cell.imageItem.image = nil
             cell.imageItem.backgroundColor = nil
 
+            cell.hideButtonMore(false)
+
             // Progress
             var progress: Float = 0.0
             if let progressType = appDelegate.listProgress[metadata.ocId] {
@@ -1683,6 +1698,11 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: ""))
             }
 
+            // URL
+            if metadata.classFile == NCCommunicationCommon.typeClassFile.url.rawValue {
+                cell.hideButtonMore(true)
+            }
+
             // Edit mode
             if isEditMode {
                 cell.selectMode(true)

+ 1 - 1
iOSClient/NCGlobal.swift

@@ -112,7 +112,7 @@ class NCGlobal: NSObject {
     // Database Realm
     //
     let databaseDefault                             = "nextcloud.realm"
-    let databaseSchemaVersion: UInt64               = 224
+    let databaseSchemaVersion: UInt64               = 225
 
     // Intro selector
     //

+ 6 - 8
iOSClient/Networking/NCNetworking.swift

@@ -936,18 +936,14 @@ import Queuer
         }
 
         NCCommunication.shared.unifiedSearch(term: literal) { provider in
-            ["contacts", "files", "fulltextsearch", "talk-conversations",].contains(provider.id)
+            ["calendar", "circles", "collectives-page-content", "collectives", "collectives-pages", "comments", "contacts", "deck", "deck-comment", "discourse-search-post", "discourse-search-topic", "files", "fulltextsearch", "github-search-issues", "github-search-repos", "mail", "notes", "settings", "settings_apps", "talk-conversations", "talk-message", "talk-message-current", "tasks", "zammad-search"].contains(provider.id)
         } update: { partialResult, provider, errorCode, errorDescription in
             guard let partialResult = partialResult else { return }
             
             switch provider.id {
-            case "contacts", "talk-conversations":
+            case "calendar", "circles", "collectives-page-content", "collectives", "collectives-pages", "comments", "contacts", "deck", "deck-comment", "discourse-search-post", "discourse-search-topic", "github-search-issues", "github-search-repos", "mail", "notes", "settings", "settings_apps", "talk-conversations", "talk-message", "talk-message-current", "tasks", "zammad-search":
                 partialResult.entries.forEach({ entry in
-                    var iconName = entry.thumbnailURL
-                    if iconName.isEmpty {
-                        iconName = entry.icon
-                    }
-                    let metadata = NCManageDatabase.shared.createMetadata(account: urlBase.account, user: urlBase.user, userId: urlBase.userId, fileName: entry.title, fileNameView: entry.title, ocId: NSUUID().uuidString, serverUrl: urlBase.urlBase, urlBase: urlBase.urlBase, url: entry.resourceURL, contentType: "", isUrl: true, name: partialResult.name.lowercased(), subline: entry.subline, iconName: iconName)
+                    let metadata = NCManageDatabase.shared.createMetadata(account: urlBase.account, user: urlBase.user, userId: urlBase.userId, fileName: entry.title, fileNameView: entry.title, ocId: NSUUID().uuidString, serverUrl: urlBase.urlBase, urlBase: urlBase.urlBase, url: entry.resourceURL, contentType: "", isUrl: true, name: partialResult.name.lowercased(), subline: entry.subline, iconName: entry.icon, iconUrl: entry.thumbnailURL)
                     searchFiles.insert(metadata)
                 })
             case "files":
@@ -980,7 +976,9 @@ import Queuer
                         }
                     }
                 })
-            default: return     // unknown provider results
+            default:
+                print("unknown provider results " + provider.id)
+                return
             }
             update(searchFiles)
         } completion: { results, errorCode, errorDescription in

+ 9 - 0
iOSClient/Viewer/NCViewer.swift

@@ -43,6 +43,15 @@ class NCViewer: NSObject {
         var editor = editor
         var xxxxxxx = NCCommunicationCommon.shared.getInternalTypeIdentifier(typeIdentifier: metadata.contentType)
 
+        // URL
+        if metadata.classFile == NCCommunicationCommon.typeClassFile.url.rawValue {
+
+            if let url = URL(string: metadata.url) {
+                UIApplication.shared.open(url)
+            }
+            return
+        }
+
         // IMAGE AUDIO VIDEO
         if metadata.classFile == NCCommunicationCommon.typeClassFile.image.rawValue || metadata.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue || metadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue {