marinofaggiana 5 years ago
parent
commit
f76125f205

+ 0 - 3
Cartfile

@@ -17,9 +17,6 @@ github "rechsteiner/Parchment" "v1.7.0"
 github "WenchaoD/FSCalendar" "2.8.0"
 github "AssistoLab/DropDown" "v2.3.13"
 github "krzyzanowskim/OpenSSL" "1.0.218"
-github "Alamofire/Alamofire" "5.0.0-rc.2"
-github "https://github.com/yahoojapan/SwiftyXMLParser" "5.1.0"
-github "SwiftyJSON/SwiftyJSON" "5.0.0"
 
 github "https://github.com/marinofaggiana/FastScroll" "master"
 github "https://github.com/marinofaggiana/AFNetworking" "master"

+ 0 - 1
iOSClient/Brand/iOSClient.plist

@@ -120,7 +120,6 @@
 		<string>audio</string>
 		<string>fetch</string>
 		<string>remote-notification</string>
-		<string>voip</string>
 	</array>
 	<key>UIFileSharingEnabled</key>
 	<true/>

+ 1 - 0
iOSClient/CCGlobal.h

@@ -193,6 +193,7 @@
 #define selectorDownloadSynchronize                     @"downloadSynchronize"
 #define selectorDownloadEditPhoto                       @"downloadEditPhoto"
 #define selectorLoadFileView                            @"loadFileView"
+#define selectorLoadFileInternalView                    @"loadFileInternalView"
 #define selectorLoadViewImage                           @"loadViewImage"
 #define selectorLoadCopy                                @"loadCopy"
 #define selectorLoadOffline                             @"loadOffline"

+ 1 - 1
iOSClient/Favorites/CCFavorites.h

@@ -46,7 +46,7 @@
 
 @property (nonatomic, weak) CCDetail *detailViewController;
 
-- (void)shouldPerformSegue:(tableMetadata *)metadata;
+- (void)shouldPerformSegue:(tableMetadata *)metadata selector:(NSString *)selector;
 - (void)reloadDatasource:(NSString *)ocId action:(NSInteger)action;
 - (void)listingFavorites;
 

+ 2 - 2
iOSClient/Favorites/CCFavorites.m

@@ -747,7 +747,7 @@
                     
                 if (([self.metadata.typeFile isEqualToString: k_metadataTypeFile_video] || [self.metadata.typeFile isEqualToString: k_metadataTypeFile_audio] || [_metadata.typeFile isEqualToString: k_metadataTypeFile_image]) && self.metadata.e2eEncrypted == NO) {
                         
-                    [self shouldPerformSegue:self.metadata];
+                    [self shouldPerformSegue:self.metadata selector:@""];
                         
                 } else {
                         
@@ -786,7 +786,7 @@
 #pragma mark ===== Navigation ====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)shouldPerformSegue:(tableMetadata *)metadata
+- (void)shouldPerformSegue:(tableMetadata *)metadata selector:(NSString *)selector
 {
     // if i am in background -> exit
     if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) return;

+ 2 - 0
iOSClient/Main/CCDetail.h

@@ -38,6 +38,8 @@
 @interface CCDetail : UIViewController <MWPhotoBrowserDelegate, ReaderViewControllerDelegate>
 
 @property (nonatomic, strong) tableMetadata *metadataDetail;
+@property (nonatomic, strong) NSString *selectorDetail;
+
 @property (nonatomic, strong) NSDate *dateFilterQuery;
 
 - (void)viewFile;

+ 22 - 0
iOSClient/Main/CCDetail.m

@@ -192,6 +192,16 @@
         [[NCViewerMedia sharedInstance] viewMedia:self.metadataDetail detail:self];
     }
     
+    // DOCUMENT - INTERNAL VIEWER
+    if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_document] && [self.selectorDetail isEqualToString:selectorLoadFileInternalView]) {
+        
+        self.edgesForExtendedLayout = UIRectEdgeBottom;
+        [self createToolbar];
+        [[NCViewerDocumentWeb sharedInstance] viewDocumentWebAt:self.metadataDetail detail:self];
+        
+        return;
+    }
+    
     // DOCUMENT
     if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_document]) {
                 
@@ -216,6 +226,18 @@
                 NSString *fileNamePath = [CCUtility returnFileNamePathFromFileName:self.metadataDetail.fileName serverUrl:self.metadataDetail.serverUrl activeUrl:appDelegate.activeUrl];
                 [[NCCommunication sharedInstance] NCTextOpenFileWithUrlString:appDelegate.activeUrl fileNamePath:fileNamePath editor: @"text" account:self.metadataDetail.account completionHandler:^(NSString *account, NSString *url, NSInteger errorCode, NSString *errorMessage) {
                     
+                    if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
+                        
+                        
+                    } else {
+                        
+                        [[NCUtility sharedInstance] stopActivityIndicator];
+                        
+                        self.edgesForExtendedLayout = UIRectEdgeBottom;
+                        [self createToolbar];
+                        [[NCViewerDocumentWeb sharedInstance] viewDocumentWebAt:self.metadataDetail detail:self];
+                    }
+                    
                 }];
                 
             }

+ 3 - 1
iOSClient/Main/CCMain.h

@@ -50,6 +50,8 @@
 @property (nonatomic, weak) IBOutlet UITableView *tableView;
 @property (nonatomic, strong) tableMetadata *metadata;
 @property (nonatomic, strong) tableMetadata *metadataForPushDetail;
+@property (nonatomic, strong) NSString *selectorForPushDetail;
+
 @property (nonatomic, strong) NSString *serverUrl;
 @property (nonatomic, strong) NSString *titleMain;
 @property (nonatomic, weak) CCDetail *detailViewController;
@@ -62,7 +64,7 @@
 
 @property BOOL isSelectedMode;
 
-- (void)shouldPerformSegue:(tableMetadata *)metadata;
+- (void)shouldPerformSegue:(tableMetadata *)metadata selector:(NSString *)selector;
 - (void)performSegueDirectoryWithControlPasscode:(BOOL)controlPasscode metadata:(tableMetadata *)metadata blinkFileNamePath:(NSString *)blinkFileNamePath;
 
 - (void)saveToPhotoAlbum:(tableMetadata *)metadata;

+ 34 - 19
iOSClient/Main/CCMain.m

@@ -2449,6 +2449,7 @@
         
         CGPoint touchPoint = [recognizer locationInView:self.tableView];
         NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:touchPoint];
+        NSMutableArray *items = [NSMutableArray new];
         
         if ([self indexPathIsValid:indexPath])
             self.metadata = [[NCMainCommon sharedInstance] getMetadataFromSectionDataSourceIndexPath:indexPath sectionDataSource:sectionDataSource];
@@ -2459,21 +2460,18 @@
         
         UIMenuController *menuController = [UIMenuController sharedMenuController];
         
-        UIMenuItem *copyFileItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"_copy_file_", nil) action:@selector(copyFile:)];
-        UIMenuItem *copyFilesItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"_copy_files_", nil) action:@selector(copyFiles:)];
-
-        UIMenuItem *openinFileItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"_open_in_", nil) action:@selector(openinFile:)];
-        
-        UIMenuItem *pasteFileItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"_paste_file_", nil) action:@selector(pasteFile:)];
-        
-        UIMenuItem *pasteFilesItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"_paste_files_", nil) action:@selector(pasteFiles:)];
-        
-        if ([NCBrandOptions sharedInstance].disable_openin_file) {
-            [menuController setMenuItems:[NSArray arrayWithObjects:copyFileItem, copyFilesItem, pasteFileItem, pasteFilesItem, nil]];
-        } else {
-            [menuController setMenuItems:[NSArray arrayWithObjects:copyFileItem, copyFilesItem, openinFileItem, pasteFileItem, pasteFilesItem, nil]];
+        [items addObject:[[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"_copy_file_", nil) action:@selector(copyFile:)]];
+        [items addObject:[[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"_copy_files_", nil) action:@selector(copyFiles:)]];
+        if ([NCBrandOptions sharedInstance].disable_openin_file == false) {
+            [items addObject:[[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"_open_in_", nil) action:@selector(openinFile:)]];
         }
-        
+        if ([self.metadata.typeFile isEqualToString: k_metadataTypeFile_document]) {
+            [items addObject:[[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"_open_internal_view_", nil) action:@selector(openInternalViewer:)]];
+        }
+        [items addObject:[[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"_paste_file_", nil) action:@selector(pasteFile:)]];
+        [items addObject:[[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"_paste_files_", nil) action:@selector(pasteFiles:)]];
+
+        [menuController setMenuItems:items];
         [menuController setTargetRect:CGRectMake(touchPoint.x, touchPoint.y, 0.0f, 0.0f) inView:self.tableView];
         [menuController setMenuVisible:YES animated:YES];
     }
@@ -2493,7 +2491,7 @@
     // NO In Session mode (download/upload)
     // NO Template
     
-    if (@selector(copyFile:) == action || @selector(openinFile:) == action) {
+    if (@selector(copyFile:) == action || @selector(openinFile:) == action || @selector(openInternalViewer:) == action) {
         
         if (_isSelectedMode == NO && self.metadata && !self.metadata.directory && self.metadata.status == k_metadataStatusNormal) return YES;
         else return NO;
@@ -2661,6 +2659,21 @@
     [[NCMainCommon sharedInstance] downloadOpenInMetadata:self.metadata];
 }
 
+/************************************ OPEN INTERNAL VIEWER ... ******************************/
+- (void)openInternalViewer:(id)sender
+{
+    self.metadata.session = k_download_session;
+    self.metadata.sessionError = @"";
+    self.metadata.sessionSelector = selectorLoadFileInternalView;
+    self.metadata.status = k_metadataStatusWaitDownload;
+    
+    // Add Metadata for Download
+    (void)[[NCManageDatabase sharedInstance] addMetadata:self.metadata];
+    [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:self.metadata.ocId action:k_action_MOD];
+    
+    [appDelegate startLoadAutoDownloadUpload];
+}
+
 /************************************ PASTE ************************************/
 
 - (void)pasteFile:(id)sender
@@ -3890,12 +3903,12 @@
             
                 if (([self.metadata.typeFile isEqualToString: k_metadataTypeFile_video] || [self.metadata.typeFile isEqualToString: k_metadataTypeFile_audio] || [self.metadata.typeFile isEqualToString: k_metadataTypeFile_image]) && _metadataFolder.e2eEncrypted == NO) {
                     
-                    [self shouldPerformSegue:self.metadata];
+                    [self shouldPerformSegue:self.metadata selector:@""];
                     
                 } else if ([self.metadata.typeFile isEqualToString: k_metadataTypeFile_document] && [[NCUtility sharedInstance] isDirectEditing:self.metadata] != nil) {
                     
                     if (appDelegate.reachability.isReachable) {
-                        [self shouldPerformSegue:self.metadata];
+                        [self shouldPerformSegue:self.metadata selector:@""];
                     } else {
                         [appDelegate messageNotification:@"_info_" description:@"_go_online_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo errorCode:0];
                     }
@@ -3903,7 +3916,7 @@
                 } else if ([self.metadata.typeFile isEqualToString: k_metadataTypeFile_document] && [[NCUtility sharedInstance] isRichDocument:self.metadata]) {
                     
                     if (appDelegate.reachability.isReachable) {
-                        [self shouldPerformSegue:self.metadata];
+                        [self shouldPerformSegue:self.metadata selector:@""];
                     } else {
                         [appDelegate messageNotification:@"_info_" description:@"_go_online_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo errorCode:0];
                     }
@@ -3978,7 +3991,7 @@
 #pragma mark ===== Navigation ====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)shouldPerformSegue:(tableMetadata *)metadata
+- (void)shouldPerformSegue:(tableMetadata *)metadata selector:(NSString *)selector
 {
     // if background return
     if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) return;
@@ -3992,6 +4005,7 @@
     
     // Metadata for push detail
     self.metadataForPushDetail = metadata;
+    self.selectorForPushDetail = selector;
     
     [self performSegueWithIdentifier:@"segueDetail" sender:self];
 }
@@ -4030,6 +4044,7 @@
     }
     
     _detailViewController.metadataDetail = metadata;
+    _detailViewController.selectorDetail = self.selectorForPushDetail;
     _detailViewController.photoDataSource = photoDataSource;
     _detailViewController.dateFilterQuery = nil;
     

+ 1 - 1
iOSClient/Main/Create cloud/NCCreateFormUploadRichdocuments.swift

@@ -274,7 +274,7 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate, U
                     self.dismiss(animated: true, completion: {
                         let metadata = CCUtility.createMetadata(withAccount: self.appDelegate.activeAccount, date: Date(), directory: false, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, fileName: (fileNameForm as! NSString).deletingPathExtension + "." + self.fileNameExtension, etag: "", size: 0, status: Double(k_metadataStatusNormal), url:url)
                         
-                        self.appDelegate.activeMain.shouldPerformSegue(metadata)
+                        self.appDelegate.activeMain.shouldPerformSegue(metadata, selector: "")
                     })
                 }
             } else if errorCode != 0 {

+ 3 - 3
iOSClient/Main/NCMainCommon.swift

@@ -1309,7 +1309,7 @@ class NCNetworkingMain: NSObject, CCNetworkingDelegate {
             }
             
             // open View File
-            if selector == selectorLoadFileView && UIApplication.shared.applicationState == UIApplication.State.active {
+            if (selector == selectorLoadFileView || selector == selectorLoadFileInternalView) && UIApplication.shared.applicationState == UIApplication.State.active {
             
                 var uti = CCUtility.insertTypeFileIconName(metadata.fileNameView, metadata: metadata)
                 if uti == nil {
@@ -1347,10 +1347,10 @@ class NCNetworkingMain: NSObject, CCNetworkingDelegate {
                 } else {
                     
                     if appDelegate.activeMain.view.window != nil {
-                        appDelegate.activeMain.shouldPerformSegue(metadata)
+                        appDelegate.activeMain.shouldPerformSegue(metadata, selector: selector)
                     }
                     if appDelegate.activeFavorites.view.window != nil {
-                        appDelegate.activeFavorites.shouldPerformSegue(metadata)
+                        appDelegate.activeFavorites.shouldPerformSegue(metadata, selector: selector)
                     }
                 }
             }

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

@@ -421,6 +421,7 @@
 "_copy_files_"                  = "Copy files";
 "_paste_file_"                  = "Paste file";
 "_paste_files_"                 = "Paste files";
+"_open_internal_view_"          = "Open with internal viewer";
 
 "_search_this_folder_"          = "Search in this folder";
 "_search_all_folders_"          = "Search in all folders";