marinofaggiana 4 жил өмнө
parent
commit
c9861ddb35

+ 3 - 3
iOSClient/Main/Menu/NCCollectionViewCommon+Menu.swift

@@ -224,11 +224,11 @@ extension NCCollectionViewCommon {
                     icon: UIImage(named: "rename")!.image(color: NCBrandColor.shared.icon, size: 50),
                     action: { menuAction in
                         
-                        if let viewController = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() as? NCRenameFile {
+                        if let vcRename = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() as? NCRenameFile {
                             
-                            viewController.metadata = metadata
+                            vcRename.metadata = metadata
 
-                            let popup = NCPopupViewController(contentController: viewController, popupWidth: 300, popupHeight: 360)
+                            let popup = NCPopupViewController(contentController: vcRename, popupWidth: 300, popupHeight: 360)
                                                         
                             self.present(popup, animated: true)
                         }

+ 8 - 15
iOSClient/Main/Menu/NCViewer+Menu.swift

@@ -168,22 +168,15 @@ extension NCViewer {
                     title: NSLocalizedString("_rename_", comment: ""),
                     icon: UIImage(named: "rename")!.image(color: NCBrandColor.shared.icon, size: 50),
                     action: { menuAction in
-                        let alertController = UIAlertController(title: NSLocalizedString("_rename_", comment: ""), message: nil, preferredStyle: .alert)
-
-                        alertController.addTextField { (textField) in textField.text = metadata.fileNameView }
-                        let cancelAction = UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel, handler: nil)
-                        let okAction = UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in
-                            let fileNameNew = alertController.textFields![0].text
-                            NCNetworking.shared.renameMetadata(metadata, fileNameNew: fileNameNew!, urlBase: self.appDelegate.urlBase, viewController: viewController) { (errorCode, errorDescription) in
-                                if errorCode != 0 {
-                                    NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
-                                }
-                            }
-                        })
-                        alertController.addAction(cancelAction)
-                        alertController.addAction(okAction)
+                        
+                        if let vcRename = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() as? NCRenameFile {
+                            
+                            vcRename.metadata = metadata
 
-                        viewController.present(alertController, animated: true, completion: nil)
+                            let popup = NCPopupViewController(contentController: vcRename, popupWidth: 300, popupHeight: 360)
+                                                        
+                            viewController.present(popup, animated: true)
+                        }
                     }
                 )
             )

+ 1 - 0
iOSClient/Utility/CCUtility.m

@@ -1384,6 +1384,7 @@
                     NSString *fileNameJPEG = [[metadata.fileName lastPathComponent] stringByDeletingPathExtension];
                     fileName = [fileNameJPEG stringByAppendingString:@".jpg"];
                     metadata.contentType = @"image/jpeg";
+                    metadata.ext = @"jpg";
                 }
                 
                 NSString *fileNamePath = [NSTemporaryDirectory() stringByAppendingString:fileName];