marinofaggiana 4 yıl önce
ebeveyn
işleme
ffad081c6f

+ 8 - 4
iOSClient/Main/NCFunctionCenter.swift

@@ -319,10 +319,10 @@ import NCCommunication
             
             if appDelegate.activeViewController is NCCollectionViewCommon {
                 let viewController: NCCollectionViewCommon = appDelegate.activeViewController as! NCCollectionViewCommon
-                let layout = viewController.layout
+                let layoutKey = viewController.layoutKey
                 let serverUrl = viewController.serverUrl
                 if serverUrl == metadata.serverUrl {
-                    NCUtility.shared.setBackgroundForView(key: layout, serverUrl: serverUrl, fillBackgroud: metadata.fileNameView, fillBackgroudContentMode: "")
+                    NCUtility.shared.setBackgroundForView(key: layoutKey, serverUrl: serverUrl, fillBackgroud: metadata.fileNameView, fillBackgroudContentMode: "")
                     viewController.setLayout()
                 }
             }
@@ -546,7 +546,7 @@ import NCCommunication
             }
         }
         
-        let saveBackground = UIAction(title: NSLocalizedString("_use_as_background", comment: ""), image: UIImage(systemName: "text.below.photo")) { action in
+        let saveBackground = UIAction(title: NSLocalizedString("_use_as_background_", comment: ""), image: UIImage(systemName: "text.below.photo")) { action in
             if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
                 self.saveBackground(metadata: metadata)
             } else {
@@ -620,7 +620,11 @@ import NCCommunication
         }
         
         if metadata.typeFile == NCGlobal.shared.metadataTypeFileImage && viewController is NCCollectionViewCommon {
-            children.insert(saveBackground, at: children.count-1)
+            let viewController: NCCollectionViewCommon = viewController as! NCCollectionViewCommon
+            let layoutKey = viewController.layoutKey
+            if layoutKey == NCGlobal.shared.layoutViewFiles {
+                children.insert(saveBackground, at: children.count-1)
+            }
         }
         
         return UIMenu(title: "", image: nil, identifier: nil, children: children)

+ 19 - 0
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -281,6 +281,25 @@ extension NCCollectionViewCommon {
             )
         }
         
+        //
+        // USE AS BACKGROUND
+        //
+        if metadata.typeFile == NCGlobal.shared.metadataTypeFileImage {
+            actions.append(
+                NCMenuAction(
+                    title: NSLocalizedString("_use_as_background_", comment: ""),
+                    icon: NCUtility.shared.loadImage(named: "text.below.photo"),
+                    action: { menuAction in
+                        if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
+                            NCFunctionCenter.shared.saveBackground(metadata: metadata)
+                        } else {
+                            NCOperationQueue.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorSaveBackground)
+                        }
+                    }
+                )
+            )
+        }
+        
         //
         // DELETE
         //

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

@@ -173,7 +173,7 @@
 "_privacy_"                 = "Privacy";
 "_source_code_"             = "Get source code";
 "_account_select_"          = "Select the account";
-"_use_as_background"        = "Use it as a background";
+"_use_as_background_"       = "Use it as a background";
 "_background_"              = "Background";
 
 /* User status */