Explorar o código

Dev : OnDevice

Marino Faggiana %!s(int64=6) %!d(string=hai) anos
pai
achega
e7c2c7ed14

+ 1 - 0
iOSClient/CCGlobal.h

@@ -190,6 +190,7 @@
 #define selectorLoadModelView                           @"loadModelView"
 #define selectorLoadViewImage                           @"loadViewImage"
 #define selectorLoadCopy                                @"loadCopy"
+#define selectorLoadOnDevice                            @"loadOnDevice"
 #define selectorMove                                    @"move"
 #define selectorOpenIn                                  @"openIn"
 #define selectorOpenWindowShare                         @"openWindowShare"

+ 52 - 0
iOSClient/Main/CCMain.m

@@ -3570,6 +3570,24 @@
                                     }];
         }
         
+        if (!lockDirectory && !isFolderEncrypted) {
+            
+            NSString *title, *serverUrl = [CCUtility stringAppendServerUrl:_serverUrl addFileName:self.metadata.fileName];
+            tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND onDevice == true", appDelegate.activeAccount, serverUrl]];
+            if (directory == nil) { title = NSLocalizedString(@"_set_available_offline_", nil); }
+            else { title = NSLocalizedString(@"_remove_available_offline_", nil); }
+            
+            [actionSheet addButtonWithTitle:title
+                                      image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"onDevice"] multiplier:2 color:[NCBrandColor sharedInstance].icon]
+                            backgroundColor:[NCBrandColor sharedInstance].backgroundView
+                                     height:50.0
+                                       type:AHKActionSheetButtonTypeDefault
+                                    handler:^(AHKActionSheet *as) {
+                                        if (directory == nil) { [[NCManageDatabase sharedInstance] setDirectoryWithServerUrl:serverUrl onDevice:true];
+                                        } else { [[NCManageDatabase sharedInstance] setDirectoryWithServerUrl:serverUrl onDevice:false]; }
+                                    }];
+        }
+        
         if (!([self.metadata.fileName isEqualToString:_autoUploadFileName] == YES && [serverUrl isEqualToString:_autoUploadDirectory] == YES)) {
             
             [actionSheet addButtonWithTitle:titoloLock
@@ -3738,6 +3756,40 @@
                                     }];
         }
         
+        if (!_metadataFolder.e2eEncrypted) {
+            
+            NSString *title;
+            tableLocalFile *localFile = [[NCManageDatabase sharedInstance] getTableLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", self.metadata.fileID]];
+
+            if (localFile == nil || localFile.onDevice == false) { title = NSLocalizedString(@"_set_available_offline_", nil); }
+            else { title = NSLocalizedString(@"_remove_available_offline_", nil); }
+            
+            [actionSheet addButtonWithTitle:title
+                                      image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"onDevice"] multiplier:2 color:[NCBrandColor sharedInstance].icon]
+                            backgroundColor:[NCBrandColor sharedInstance].backgroundView
+                                     height:50.0
+                                       type:AHKActionSheetButtonTypeDefault
+                                    handler:^(AHKActionSheet *as) {
+                                        
+                                        if (localFile == nil) {
+                                            self.metadata.session = k_download_session;
+                                            self.metadata.sessionError = @"";
+                                            self.metadata.sessionSelector = selectorLoadOnDevice;
+                                            self.metadata.status = k_metadataStatusWaitDownload;
+                                            
+                                            // Add Metadata for Download
+                                            (void)[[NCManageDatabase sharedInstance] addMetadata:self.metadata];
+                                            [appDelegate performSelectorOnMainThread:@selector(loadAutoDownloadUpload) withObject:nil waitUntilDone:YES];
+                                            
+                                            [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl fileID:self.metadata.fileID action:k_action_MOD];
+                                        } else if (localFile.onDevice == false) {
+                                            [[NCManageDatabase sharedInstance] setLocalFileWithFileID:self.metadata.fileID onDevice:true];
+                                        } else {
+                                            [[NCManageDatabase sharedInstance] setLocalFileWithFileID:self.metadata.fileID onDevice:false];
+                                        }
+                                    }];
+        }
+        
         [actionSheet addButtonWithTitle:NSLocalizedString(@"_delete_", nil)
                                   image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"delete"] multiplier:2 color:[UIColor redColor]]
                         backgroundColor:[NCBrandColor sharedInstance].backgroundView

+ 9 - 9
iOSClient/Main/CCMore.swift

@@ -114,15 +114,6 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLo
         item.url = "segueShares"
         functionMenu.append(item)
 
-        // ITEM : Scan
-        if #available(iOS 11.0, *) {
-            item = OCExternalSites.init()
-            item.name = "_scanned_images_"
-            item.icon = "scan"
-            item.url = "openStoryboardScan"
-            functionMenu.append(item)
-        }
-        
 #if targetEnvironment(simulator)
         // ITEM : OnDevice
         item = OCExternalSites.init()
@@ -132,6 +123,15 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLo
         functionMenu.append(item)
 #endif
         
+        // ITEM : Scan
+        if #available(iOS 11.0, *) {
+            item = OCExternalSites.init()
+            item.name = "_scanned_images_"
+            item.icon = "scan"
+            item.url = "openStoryboardScan"
+            functionMenu.append(item)
+        }
+        
         // ITEM : Trash
         let capabilities = NCManageDatabase.sharedInstance.getCapabilites()
         if capabilities != nil && capabilities!.versionMajor >= Int(k_trash_version_available) {

+ 6 - 0
iOSClient/Main/NCMainCommon.swift

@@ -767,6 +767,12 @@ class NCNetworkingMain: NSObject, CCNetworkingDelegate {
                 appDelegate.activeMain.copyFile(toPasteboard: metadata)
             }
             
+            // Set as available offline
+            if selector == selectorLoadOnDevice {
+                
+                NCManageDatabase.sharedInstance.setLocalFile(fileID: metadata.fileID, onDevice: true)
+            }
+            
             //selectorLoadViewImage
             if selector == selectorLoadViewImage {