Skip to content

Commit

Permalink
NMC 2261 - Save audio screen update after removed by nextcloud versio…
Browse files Browse the repository at this point in the history
…n 5.0
  • Loading branch information
TSI-amrutwaghmare committed Aug 27, 2024
1 parent 019637a commit bbcc111
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
32 changes: 17 additions & 15 deletions iOSClient/AudioRecorder/NCAudioRecorderViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class NCAudioRecorderViewController: UIViewController, NCAudioRecorderDelegate {
var recording: NCAudioRecorder!
var startDate: Date = Date()
var fileName: String = ""
var serverUrl = ""
let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!

@IBOutlet weak var contentContainerView: UIView!
Expand All @@ -54,16 +53,14 @@ class NCAudioRecorderViewController: UIViewController, NCAudioRecorderDelegate {
contentContainerView.backgroundColor = UIColor.lightGray
voiceRecordHUD.fillColor = NCBrandColor.shared.progressColorGreen60

Task {
self.fileName = await NCNetworking.shared.createFileName(fileNameBase: NSLocalizedString("_untitled_", comment: "") + ".m4a", account: self.appDelegate.account, serverUrl: self.serverUrl)
recording = NCAudioRecorder(to: self.fileName)
recording.delegate = self
do {
try self.recording.prepare()
startStopLabel.text = NSLocalizedString("_voice_memo_start_", comment: "")
} catch {
print(error)
}
self.fileName = NCUtilityFileSystem().createFileNameDate(NSLocalizedString("_voice_memo_filename_", comment: ""), ext: "m4a")
recording = NCAudioRecorder(to: self.fileName)
recording.delegate = self
do {
try self.recording.prepare()
startStopLabel.text = NSLocalizedString("_voice_memo_start_", comment: "")
} catch {
print(error)
}
}

Expand All @@ -81,8 +78,12 @@ class NCAudioRecorderViewController: UIViewController, NCAudioRecorderDelegate {
if recording.state == .record {
recording.stop()
voiceRecordHUD.update(0.0)
dismiss(animated: true) {
self.uploadMetadata()
dismiss(animated: true) { [self] in
guard let navigationController = UIStoryboard(name: "NCCreateFormUploadVoiceNote", bundle: nil).instantiateInitialViewController() as? UINavigationController,
let viewController = navigationController.topViewController as? NCCreateFormUploadVoiceNote else { return }
navigationController.modalPresentationStyle = .formSheet
viewController.setup(serverUrl: self.appDelegate.activeServerUrl, fileNamePath: NSTemporaryDirectory() + self.fileName, fileName: self.fileName)
self.appDelegate.window?.rootViewController?.present(navigationController, animated: true)
}
} else {
do {
Expand All @@ -97,7 +98,7 @@ class NCAudioRecorderViewController: UIViewController, NCAudioRecorderDelegate {

func uploadMetadata() {
let fileNamePath = NSTemporaryDirectory() + self.fileName
let metadata = NCManageDatabase.shared.createMetadata(account: appDelegate.account, user: appDelegate.user, userId: appDelegate.userId, fileName: fileName, fileNameView: fileName, ocId: UUID().uuidString, serverUrl: self.serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: "")
let metadata = NCManageDatabase.shared.createMetadata(account: appDelegate.account, user: appDelegate.user, userId: appDelegate.userId, fileName: fileName, fileNameView: fileName, ocId: UUID().uuidString, serverUrl: appDelegate.activeServerUrl, urlBase: appDelegate.urlBase, url: "", contentType: "")
metadata.session = NCNetworking.shared.sessionUploadBackground
metadata.sessionSelector = NCGlobal.shared.selectorUploadFile
metadata.status = NCGlobal.shared.metadataStatusWaitUpload
Expand Down Expand Up @@ -138,7 +139,8 @@ class NCAudioRecorderViewController: UIViewController, NCAudioRecorderDelegate {
}

open class NCAudioRecorder: NSObject {
public enum State: Int {

@objc public enum State: Int {
case none, record, play
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud

utilityFileSystem.copyFile(atPath: self.fileNamePath, toPath: utilityFileSystem.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))

NCNetworkingProcessUpload.shared.createProcessUploads(metadatas: [metadata], completion: { _ in })
NCNetworkingProcess.shared.createProcessUploads(metadatas: [metadata], completion: { _ in })

self.dismiss(animated: true, completion: nil)
}
Expand Down

0 comments on commit bbcc111

Please sign in to comment.