marinofaggiana 6 yıl önce
ebeveyn
işleme
c4f2d3f7ad

+ 17 - 8
iOSClient/AudioRecorder/NCAudioRecorderViewController.storyboard

@@ -25,7 +25,7 @@
                                 <rect key="frame" x="87.5" y="208.5" width="200" height="250"/>
                                 <subviews>
                                     <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vr6-IX-Yee" customClass="VoiceRecordHUD" customModule="Nextcloud" customModuleProvider="target">
-                                        <rect key="frame" x="7" y="32" width="186" height="186"/>
+                                        <rect key="frame" x="2" y="27" width="196" height="196"/>
                                         <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
                                         <constraints>
                                             <constraint firstAttribute="width" secondItem="vr6-IX-Yee" secondAttribute="height" id="c7R-AE-rou"/>
@@ -40,25 +40,32 @@
                                         </userDefinedRuntimeAttributes>
                                     </view>
                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="120″" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yIp-rq-klm">
-                                        <rect key="frame" x="85" y="15" width="30" height="17"/>
+                                        <rect key="frame" x="85" y="10" width="30" height="17"/>
                                         <fontDescription key="fontDescription" type="system" pointSize="14"/>
                                         <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                         <nil key="highlightedColor"/>
                                     </label>
-                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="bottom" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Lnv-LR-qq5">
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="bottom" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Lnv-LR-qq5" userLabel="button">
                                         <rect key="frame" x="0.0" y="0.0" width="200" height="250"/>
                                         <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
-                                        <state key="normal" title="Tap to finish">
+                                        <state key="normal">
                                             <color key="titleColor" red="0.94117647059999998" green="0.91764705879999997" blue="0.85490196080000003" alpha="1" colorSpace="calibratedRGB"/>
                                         </state>
                                         <connections>
-                                            <action selector="stop" destination="9IE-bj-VJb" eventType="touchUpInside" id="fjb-L2-YTP"/>
+                                            <action selector="startStop" destination="9IE-bj-VJb" eventType="touchUpInside" id="B8V-Tg-Hbf"/>
                                         </connections>
                                     </button>
+                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="tap to start" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3Wm-qO-FzJ" userLabel="start stop">
+                                        <rect key="frame" x="64" y="225" width="72" height="17"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                        <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                        <nil key="highlightedColor"/>
+                                    </label>
                                 </subviews>
-                                <color key="backgroundColor" red="0.32549019610000002" green="0.83529411760000005" blue="0.76078431369999999" alpha="1" colorSpace="calibratedRGB"/>
+                                <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <constraints>
-                                    <constraint firstItem="yIp-rq-klm" firstAttribute="top" secondItem="Ztv-M0-yUI" secondAttribute="top" constant="15" id="1S8-2v-d7k"/>
+                                    <constraint firstItem="yIp-rq-klm" firstAttribute="top" secondItem="Ztv-M0-yUI" secondAttribute="top" constant="10" id="1S8-2v-d7k"/>
+                                    <constraint firstItem="3Wm-qO-FzJ" firstAttribute="centerX" secondItem="Lnv-LR-qq5" secondAttribute="centerX" id="2UV-Gt-2oO"/>
                                     <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="vr6-IX-Yee" secondAttribute="trailing" id="6e6-C9-ZWQ"/>
                                     <constraint firstItem="yIp-rq-klm" firstAttribute="bottom" secondItem="vr6-IX-Yee" secondAttribute="top" id="E3m-Yu-zdJ"/>
                                     <constraint firstAttribute="height" constant="250" id="G5W-ie-MCH"/>
@@ -68,6 +75,7 @@
                                     <constraint firstAttribute="width" constant="200" id="Qu2-eD-5VF"/>
                                     <constraint firstItem="vr6-IX-Yee" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Ztv-M0-yUI" secondAttribute="leading" id="Wmx-H6-3OK"/>
                                     <constraint firstAttribute="centerX" secondItem="vr6-IX-Yee" secondAttribute="centerX" id="Zvz-EB-nL6"/>
+                                    <constraint firstItem="3Wm-qO-FzJ" firstAttribute="top" secondItem="Lnv-LR-qq5" secondAttribute="bottom" constant="-25" id="a8Q-Z1-NFp"/>
                                     <constraint firstAttribute="centerX" secondItem="yIp-rq-klm" secondAttribute="centerX" id="hwa-S6-oPz"/>
                                     <constraint firstAttribute="centerY" secondItem="vr6-IX-Yee" secondAttribute="centerY" id="iqe-Ov-fVD"/>
                                     <constraint firstItem="Lnv-LR-qq5" firstAttribute="top" secondItem="Ztv-M0-yUI" secondAttribute="top" id="mrG-va-2Su"/>
@@ -86,8 +94,9 @@
                         </constraints>
                     </view>
                     <connections>
+                        <outlet property="contentContainerView" destination="Ztv-M0-yUI" id="P6f-ew-Dyb"/>
                         <outlet property="durationLabel" destination="yIp-rq-klm" id="a8F-JI-uNe"/>
-                        <outlet property="tapToFinishBtn" destination="Lnv-LR-qq5" id="vsS-bs-9DO"/>
+                        <outlet property="startStopLabel" destination="3Wm-qO-FzJ" id="2oa-5C-G2K"/>
                         <outlet property="voiceRecordHUD" destination="vr6-IX-Yee" id="s4E-Ka-QV9"/>
                     </connections>
                 </viewController>

+ 29 - 22
iOSClient/AudioRecorder/NCAudioRecorderViewController.swift

@@ -29,8 +29,8 @@ import UIKit
 import AVFoundation
 import QuartzCore
 
-protocol NCAudioRecorderViewControllerDelegate : class {
-    func didFinishRecording(_ NCAudioRecorderViewController: NCAudioRecorderViewController)
+@objc protocol NCAudioRecorderViewControllerDelegate : class {
+    func didFinishRecording(_ viewController: NCAudioRecorderViewController)
 }
 
 class NCAudioRecorderViewController: UIViewController , NCAudioRecorderDelegate {
@@ -39,8 +39,9 @@ class NCAudioRecorderViewController: UIViewController , NCAudioRecorderDelegate
     var recording: NCAudioRecorder!
     var recordDuration = 0
     
-    @IBOutlet weak var tapToFinishBtn: UIButton!
+    @IBOutlet weak var contentContainerView: UIView!
     @IBOutlet weak var durationLabel: UILabel!
+    @IBOutlet weak var startStopLabel: UILabel!
     @IBOutlet weak var voiceRecordHUD: VoiceRecordHUD!
     
     // MARK: View Life Cycle
@@ -48,19 +49,20 @@ class NCAudioRecorderViewController: UIViewController , NCAudioRecorderDelegate
     override func viewDidLoad() {
         super.viewDidLoad()
         
-        //createRecorder()
     }
     
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         
+        contentContainerView.backgroundColor = NCBrandColor.sharedInstance.brand
         voiceRecordHUD.update(0.0)
         voiceRecordHUD.fillColor = UIColor.green
         durationLabel.text = ""
+        startStopLabel.text = NSLocalizedString("_voice_memo_start_", comment: "")
     }
     
     func createRecorder(fileName: String) {
-        recording = NCAudioRecorder(to: fileName) //"recording.m4a"
+        recording = NCAudioRecorder(to: fileName)
         recording.delegate = self
         
         // Optionally, you can prepare the recording in the background to
@@ -76,24 +78,29 @@ class NCAudioRecorderViewController: UIViewController , NCAudioRecorderDelegate
         }
     }
     
-    func startRecording() {
-        recordDuration = 0
-        do {
-            try recording.record()
-        } catch {
-            print(error)
-        }
-    }
-    
-    @IBAction func stop() {
-        
-        delegate?.didFinishRecording(self)
-        dismiss(animated: true, completion: nil)
-        
-        recordDuration = 0
-        recording.stop()
-        voiceRecordHUD.update(0.0)
+    @IBAction func startStop() {
         
+        if recording.state == .none {
+            
+            recordDuration = 0
+            do {
+                try recording.record()
+                startStopLabel.text = NSLocalizedString("_voice_memo_stop_", comment: "")
+            } catch {
+                print(error)
+            }
+            
+        } else {
+            
+            delegate?.didFinishRecording(self)
+            dismiss(animated: true, completion: nil)
+            
+            recordDuration = 0
+            recording.stop()
+            voiceRecordHUD.update(0.0)
+            
+            startStopLabel.text = NSLocalizedString("_voice_memo_start_", comment: "")
+        }
     }
     
     func audioMeterDidUpdate(_ db: Float) {

+ 13 - 8
iOSClient/Main/Create cloud/NCCreateMenuAdd.swift

@@ -57,7 +57,9 @@ class NCCreateMenuAdd: NSObject {
         }
 #endif
         
-        items.append(ActionSheetItem(title: NSLocalizedString("_create_folder_", comment: ""), value: 5, image: CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 50, height: 50, color: colorIcon)))
+        items.append(ActionSheetItem(title: NSLocalizedString("_create_voice_memo_", comment: ""), value: 5, image: CCGraphics.changeThemingColorImage(UIImage.init(named: "microphone"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)))
+
+        items.append(ActionSheetItem(title: NSLocalizedString("_create_folder_", comment: ""), value: 6, image: CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 50, height: 50, color: colorIcon)))
         
         // items.append(ActionSheetSectionTitle(title: "Cheap"))
         // items.append(ActionSheetSectionMargin())
@@ -73,9 +75,9 @@ class NCCreateMenuAdd: NSObject {
         
         if let richdocumentsMimetypes = NCManageDatabase.sharedInstance.getRichdocumentsMimetypes(account: appDelegate.activeAccount) {
             if richdocumentsMimetypes.count > 0 {
-                items.append(ActionSheetItem(title: NSLocalizedString("_create_new_document_", comment: ""), value: 6, image: UIImage.init(named: "create_file_document")))
-                items.append(ActionSheetItem(title: NSLocalizedString("_create_new_spreadsheet_", comment: ""), value: 7, image: UIImage(named: "create_file_xls")))
-                items.append(ActionSheetItem(title: NSLocalizedString("_create_new_presentation_", comment: ""), value: 8, image: UIImage(named: "create_file_ppt")))
+                items.append(ActionSheetItem(title: NSLocalizedString("_create_new_document_", comment: ""), value: 7, image: UIImage.init(named: "create_file_document")))
+                items.append(ActionSheetItem(title: NSLocalizedString("_create_new_spreadsheet_", comment: ""), value: 8, image: UIImage(named: "create_file_xls")))
+                items.append(ActionSheetItem(title: NSLocalizedString("_create_new_presentation_", comment: ""), value: 9, image: UIImage(named: "create_file_ppt")))
             }
         }
         
@@ -95,9 +97,12 @@ class NCCreateMenuAdd: NSObject {
                     NCCreateScanDocument.sharedInstance.openScannerDocument(viewController: self.appDelegate.activeMain, openScan: true)
                 }
             }
-            if item.value as? Int == 5 { self.appDelegate.activeMain.createFolder() }
             
-            if item.value as? Int == 6 {
+            if item.value as? Int == 5 { NCMainCommon.sharedInstance.startAudioRecorder() }
+            
+            if item.value as? Int == 6 { self.appDelegate.activeMain.createFolder() }
+            
+            if item.value as? Int == 7 {
                 guard let navigationController = UIStoryboard(name: "NCCreateFormUploadRichdocuments", bundle: nil).instantiateInitialViewController() else {
                     return
                 }
@@ -110,7 +115,7 @@ class NCCreateMenuAdd: NSObject {
                 
                 self.appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
             }
-            if item.value as? Int == 7 {
+            if item.value as? Int == 8 {
                 guard let navigationController = UIStoryboard(name: "NCCreateFormUploadRichdocuments", bundle: nil).instantiateInitialViewController() else {
                     return
                 }
@@ -123,7 +128,7 @@ class NCCreateMenuAdd: NSObject {
                 
                 self.appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
             }
-            if item.value as? Int == 8 {
+            if item.value as? Int == 9 {
                 guard let navigationController = UIStoryboard(name: "NCCreateFormUploadRichdocuments", bundle: nil).instantiateInitialViewController() else {
                     return
                 }

+ 19 - 1
iOSClient/Main/NCMainCommon.swift

@@ -24,7 +24,7 @@
 import Foundation
 import TLPhotoPicker
 
-class NCMainCommon: NSObject, PhotoEditorDelegate {
+class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewControllerDelegate {
     
     @objc static let sharedInstance: NCMainCommon = {
         let instance = NCMainCommon()
@@ -1019,6 +1019,24 @@ class NCMainCommon: NSObject, PhotoEditorDelegate {
     func canceledEditing() {
         print("Canceled")
     }
+    
+    //MARK: - NCAudioRecorder
+    
+    func startAudioRecorder() {
+    
+        let viewController = UIStoryboard(name: "NCAudioRecorderViewController", bundle: nil).instantiateInitialViewController() as! NCAudioRecorderViewController
+    
+        viewController.delegate = self
+        viewController.createRecorder(fileName: "xxx.m4a")
+        viewController.modalTransitionStyle = .crossDissolve
+        viewController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
+    
+        self.appDelegate.window.rootViewController?.present(viewController, animated: true, completion: nil)
+    }
+    
+    func didFinishRecording(_ viewController: NCAudioRecorderViewController) {
+        
+    }
 }
     
 //MARK: -

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

@@ -724,3 +724,9 @@
 
 "_qrcode_not_authorized_"   = "This app is not authorized to use Back Camera";
 "_qrcode_not_supported_"    = "QRCode not supported by the current device";
+
+// Voice Memo
+
+"_create_voice_memo_"       = "Create voice memo";
+"_voice_memo_start_"        = "tap to start";
+"_voice_memo_stop_"         = "tap to stop";