marinofaggiana 4 年之前
父节点
当前提交
38086f3431
共有 2 个文件被更改,包括 25 次插入36 次删除
  1. 24 2
      iOSClient/Main/Menu/AppDelegate+Menu.swift
  2. 1 34
      iOSClient/Main/NCMainCommon.swift

+ 24 - 2
iOSClient/Main/Menu/AppDelegate+Menu.swift

@@ -26,7 +26,7 @@
 import FloatingPanel
 import NCCommunication
 
-extension AppDelegate {
+extension AppDelegate: NCAudioRecorderViewControllerDelegate {
     
     @objc public func showMenuIn(viewController: UIViewController) {
         
@@ -123,7 +123,16 @@ extension AppDelegate {
                 title: NSLocalizedString("_create_voice_memo_", comment: ""),
                 icon: CCGraphics.changeThemingColorImage(UIImage(named: "microphone"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
                 action: { menuAction in
-                    NCMainCommon.shared.startAudioRecorder()
+                    
+                    let fileName = CCUtility.createFileNameDate(NSLocalizedString("_voice_memo_filename_", comment: ""), extension: "m4a")!
+                    let viewController = UIStoryboard(name: "NCAudioRecorderViewController", bundle: nil).instantiateInitialViewController() as! NCAudioRecorderViewController
+                
+                    viewController.delegate = self
+                    viewController.createRecorder(fileName: fileName)
+                    viewController.modalTransitionStyle = .crossDissolve
+                    viewController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
+                
+                    appDelegate.window.rootViewController?.present(viewController, animated: true, completion: nil)
                 }
             )
         )
@@ -323,4 +332,17 @@ extension AppDelegate {
 
         return actions
     }
+    
+    func didFinishRecording(_ viewController: NCAudioRecorderViewController, fileName: String) {
+        
+        guard let navigationController = UIStoryboard(name: "NCCreateFormUploadVoiceNote", bundle: nil).instantiateInitialViewController() else { return }
+        navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
+        let appDelegate = UIApplication.shared.delegate as! AppDelegate
+        
+        let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadVoiceNote
+        viewController.setup(serverUrl: appDelegate.activeServerUrl, fileNamePath: NSTemporaryDirectory() + fileName, fileName: fileName)
+        appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
+    }
+    
+    func didFinishWithoutRecording(_ viewController: NCAudioRecorderViewController, fileName: String) { }
 }

+ 1 - 34
iOSClient/Main/NCMainCommon.swift

@@ -28,7 +28,7 @@ import NCCommunication
 
 //MARK: - Main Common
 
-class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate {
+class NCMainCommon: NSObject {
     @objc static let shared: NCMainCommon = {
         let instance = NCMainCommon()
         instance.createImagesThemingColor()
@@ -450,40 +450,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate {
         
         return true
     }
-    
-    
-
    
-    
-    //MARK: - NCAudioRecorder
-    
-    func startAudioRecorder() {
-    
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
-        let fileName = CCUtility.createFileNameDate(NSLocalizedString("_voice_memo_filename_", comment: ""), extension: "m4a")!
-        let viewController = UIStoryboard(name: "NCAudioRecorderViewController", bundle: nil).instantiateInitialViewController() as! NCAudioRecorderViewController
-    
-        viewController.delegate = self
-        viewController.createRecorder(fileName: fileName)
-        viewController.modalTransitionStyle = .crossDissolve
-        viewController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
-    
-        appDelegate.window.rootViewController?.present(viewController, animated: true, completion: nil)
-    }
-    
-    func didFinishRecording(_ viewController: NCAudioRecorderViewController, fileName: String) {
-        
-        guard let navigationController = UIStoryboard(name: "NCCreateFormUploadVoiceNote", bundle: nil).instantiateInitialViewController() else { return }
-        navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
-        
-        let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadVoiceNote
-        viewController.setup(serverUrl: appDelegate.activeServerUrl, fileNamePath: NSTemporaryDirectory() + fileName, fileName: fileName)
-        appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
-    }
-    
-    func didFinishWithoutRecording(_ viewController: NCAudioRecorderViewController, fileName: String) {
-    }
 }
     
 //MARK: - Main TabBarController