Skip to content

[stable-6.6.0] NMC/2261 - Audio Upload #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: stable-6.6.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@
AFCE353527E4ED5900FEA6C2 /* DateFormatter+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353427E4ED5900FEA6C2 /* DateFormatter+Extension.swift */; };
AFCE353727E4ED7B00FEA6C2 /* NCShareCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */; };
AFCE353927E5DE0500FEA6C2 /* Shareable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* Shareable.swift */; };
AFCE353927E5DE0500FEA6C2 /* NCShare+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */; };
B543154E2DA6913C00981E7E /* AudioUploadTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B543154D2DA6913C00981E7E /* AudioUploadTests.swift */; };
B54315552DA6929700981E7E /* NCCreateFormUploadVoiceNote.swift in Sources */ = {isa = PBXBuildFile; fileRef = B54315522DA6929700981E7E /* NCCreateFormUploadVoiceNote.swift */; };
B543155A2DA6929700981E7E /* NCCreateFormUploadVoiceNote.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B54315512DA6929700981E7E /* NCCreateFormUploadVoiceNote.storyboard */; };
B543155B2DA6929700981E7E /* NCCreateFormUploadVoiceNote.swift in Sources */ = {isa = PBXBuildFile; fileRef = B54315522DA6929700981E7E /* NCCreateFormUploadVoiceNote.swift */; };
B543155C2DA6929700981E7E /* FolderPathCustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B543154F2DA6929700981E7E /* FolderPathCustomCell.swift */; };
B543155D2DA6929700981E7E /* TextTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B54315532DA6929700981E7E /* TextTableViewCell.swift */; };
B543155E2DA6929700981E7E /* TextTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B54315542DA6929700981E7E /* TextTableViewCell.xib */; };
B543155F2DA6929700981E7E /* FolderPathCustomCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B54315502DA6929700981E7E /* FolderPathCustomCell.xib */; };
B54315602DA6929700981E7E /* NCCreateFormUploadVoiceNote.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B54315512DA6929700981E7E /* NCCreateFormUploadVoiceNote.storyboard */; };
C04E2F232A17BB4D001BAD85 /* FilesIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04E2F222A17BB4D001BAD85 /* FilesIntegrationTests.swift */; };
D575039F27146F93008DC9DC /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A0D1342591FBC5008F8A13 /* String+Extension.swift */; };
D5B6AA7827200C7200D49C24 /* NCActivityTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */; };
F310B1EF2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = F310B1EE2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift */; };
Expand Down Expand Up @@ -1330,6 +1341,14 @@
AFCE353427E4ED5900FEA6C2 /* DateFormatter+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateFormatter+Extension.swift"; sourceTree = "<group>"; };
AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareCells.swift; sourceTree = "<group>"; };
AFCE353827E5DE0400FEA6C2 /* Shareable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shareable.swift; sourceTree = "<group>"; };
AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCShare+Helper.swift"; sourceTree = "<group>"; };
B543154D2DA6913C00981E7E /* AudioUploadTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioUploadTests.swift; sourceTree = "<group>"; };
B543154F2DA6929700981E7E /* FolderPathCustomCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderPathCustomCell.swift; sourceTree = "<group>"; };
B54315502DA6929700981E7E /* FolderPathCustomCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FolderPathCustomCell.xib; sourceTree = "<group>"; };
B54315512DA6929700981E7E /* NCCreateFormUploadVoiceNote.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCCreateFormUploadVoiceNote.storyboard; sourceTree = "<group>"; };
B54315522DA6929700981E7E /* NCCreateFormUploadVoiceNote.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCCreateFormUploadVoiceNote.swift; sourceTree = "<group>"; };
B54315532DA6929700981E7E /* TextTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextTableViewCell.swift; sourceTree = "<group>"; };
B54315542DA6929700981E7E /* TextTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TextTableViewCell.xib; sourceTree = "<group>"; };
C0046CDA2A17B98400D87C9D /* NextcloudUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
C04E2F202A17BB4D001BAD85 /* NextcloudIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActivityTableViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2118,6 +2137,8 @@
isa = PBXGroup;
children = (
AA52EB452D42AC5A0089C348 /* Placeholder.swift */,
B543154D2DA6913C00981E7E /* AudioUploadTests.swift */,
AF8ED1FB2757821000B8DBC4 /* NextcloudUnitTests.swift */,
);
path = NextcloudUnitTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -3195,6 +3216,12 @@
F7DFB7E9219C5A0500680748 /* Create cloud */ = {
isa = PBXGroup;
children = (
B543154F2DA6929700981E7E /* FolderPathCustomCell.swift */,
B54315502DA6929700981E7E /* FolderPathCustomCell.xib */,
B54315512DA6929700981E7E /* NCCreateFormUploadVoiceNote.storyboard */,
B54315522DA6929700981E7E /* NCCreateFormUploadVoiceNote.swift */,
B54315532DA6929700981E7E /* TextTableViewCell.swift */,
B54315542DA6929700981E7E /* TextTableViewCell.xib */,
F7FA7FFD2C0F4F3B0072FC60 /* Upload Assets */,
F7A509242C26BD5D00326106 /* NCCreateDocument.swift */,
F704B5E22430AA6F00632F5F /* NCCreateFormUploadConflict.storyboard */,
Expand Down Expand Up @@ -3914,6 +3941,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B543155A2DA6929700981E7E /* NCCreateFormUploadVoiceNote.storyboard in Resources */,
F714803B262EBE3900693E51 /* MainInterface.storyboard in Resources */,
F7148054262ED51000693E51 /* NCListCell.xib in Resources */,
F7D57C8626317BDA00DE301D /* NCAccountRequest.storyboard in Resources */,
Expand Down Expand Up @@ -4007,6 +4035,9 @@
F70753F72542A9C000972D44 /* NCViewerMediaPage.storyboard in Resources */,
F7F4F10627ECDBDB008676F9 /* Inconsolata-Medium.ttf in Resources */,
F7AC934A296193050002BC0F /* Reasons to use Nextcloud.pdf in Resources */,
B543155E2DA6929700981E7E /* TextTableViewCell.xib in Resources */,
B543155F2DA6929700981E7E /* FolderPathCustomCell.xib in Resources */,
B54315602DA6929700981E7E /* NCCreateFormUploadVoiceNote.storyboard in Resources */,
F7A60F87292D215000FCE1F2 /* NCShareAccounts.storyboard in Resources */,
F761856A29E98543006EB3B0 /* NCIntro.storyboard in Resources */,
F719D9E0288D37A300762E33 /* NCColorPicker.storyboard in Resources */,
Expand Down Expand Up @@ -4143,6 +4174,7 @@
files = (
AA52EB472D42AC9E0089C348 /* Placeholder.swift in Sources */,
F372087D2BAB4C0F006B5430 /* TestConstants.swift in Sources */,
B543154E2DA6913C00981E7E /* AudioUploadTests.swift in Sources */,
F78E2D6C29AF02DB0024D4F3 /* Database.swift in Sources */,
F7817CFE29801A3500FFBC65 /* Data+Extension.swift in Sources */,
);
Expand Down Expand Up @@ -4352,6 +4384,7 @@
F77DD6AB2C5CC093009448FB /* NCSession.swift in Sources */,
F76D364728A4F8BF00214537 /* NCActivityIndicator.swift in Sources */,
F73EF7CA2B0225610087E6E9 /* NCManageDatabase+PhotoLibrary.swift in Sources */,
B54315552DA6929700981E7E /* NCCreateFormUploadVoiceNote.swift in Sources */,
F7BFFD2A2C8854200029A201 /* NCHud.swift in Sources */,
F749B654297B0F2400087535 /* NCManageDatabase+Avatar.swift in Sources */,
AF22B208277B4E4C00DAB0CC /* NCCreateFormUploadConflictCell.swift in Sources */,
Expand Down Expand Up @@ -4699,6 +4732,9 @@
F3C587AE2D47E4FE004532DB /* PHAssetCollectionThumbnailLoader.swift in Sources */,
F78F74362163781100C2ADAD /* NCTrash.swift in Sources */,
F39298972A3B12CB00509762 /* BaseNCMoreCell.swift in Sources */,
B543155B2DA6929700981E7E /* NCCreateFormUploadVoiceNote.swift in Sources */,
B543155C2DA6929700981E7E /* FolderPathCustomCell.swift in Sources */,
B543155D2DA6929700981E7E /* TextTableViewCell.swift in Sources */,
AF2D7C7C2742556F00ADF566 /* NCShareLinkCell.swift in Sources */,
F73EF7C72B0225610087E6E9 /* NCManageDatabase+PhotoLibrary.swift in Sources */,
F7E41316294A19B300839300 /* UIView+Extension.swift in Sources */,
Expand Down
52 changes: 52 additions & 0 deletions Tests/NextcloudUnitTests/AudioUploadTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// AudioUploadTests.swift
// NextcloudTests
//
// Created by A200020526 on 13/06/23.
// Copyright © 2023 Marino Faggiana. All rights reserved.
//

import XCTest
@testable import Nextcloud

final class AudioUploadTests: XCTestCase {
var viewController:NCAudioRecorderViewController?

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
// Step 1. Create an instance of UIStoryboard
let viewController = UIStoryboard(name: "NCAudioRecorderViewController", bundle: nil).instantiateInitialViewController() as? NCAudioRecorderViewController
// Step 3. Make the viewDidLoad() execute.
viewController?.loadViewIfNeeded()
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
viewController = nil
}

func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
// Any test you write for XCTest can be annotated as throws and async.
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
}

func testPerformanceExample() throws {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}

func testAudioMeterUpdateAfterDb(){
viewController?.audioMeterDidUpdate(0.5)
XCTAssertNotNil(!(viewController?.durationLabel.text?.isEmpty ?? false))
}

func testStartRecorder(){
viewController?.startStop()
XCTAssertEqual(viewController?.recording.state, nil, "Test start audio recorder")
}
}
37 changes: 21 additions & 16 deletions iOSClient/AudioRecorder/NCAudioRecorderViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import QuartzCore
import NextcloudKit

class NCAudioRecorderViewController: UIViewController, NCAudioRecorderDelegate {

@IBOutlet weak var contentContainerView: UIView!
@IBOutlet weak var durationLabel: UILabel!
@IBOutlet weak var startStopLabel: UILabel!
Expand All @@ -42,6 +43,7 @@ class NCAudioRecorderViewController: UIViewController, NCAudioRecorderDelegate {
var session: NCSession.Session {
NCSession.shared.getSession(controller: controller)
}
let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!

// MARK: - View Life Cycle

Expand All @@ -54,18 +56,16 @@ class NCAudioRecorderViewController: UIViewController, NCAudioRecorderDelegate {

view.backgroundColor = .clear
contentContainerView.backgroundColor = UIColor.lightGray
voiceRecordHUD.fillColor = UIColor.green
voiceRecordHUD.fillColor = NCBrandColor.shared.progressColorGreen60

Task {
self.fileName = await NCNetworking.shared.createFileName(fileNameBase: NSLocalizedString("_untitled_", comment: "") + ".m4a", account: self.session.account, serverUrl: controller.currentServerUrl())
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 @@ -83,8 +83,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: controller.currentServerUrl(), fileNamePath: NSTemporaryDirectory() + self.fileName, fileName: self.fileName)
UIApplication.shared.firstWindow?.rootViewController?.present(navigationController, animated: true)
}
} else {
do {
Expand All @@ -106,7 +110,7 @@ class NCAudioRecorderViewController: UIViewController, NCAudioRecorderDelegate {
url: "",
contentType: "",
session: self.session,
sceneIdentifier: self.controller?.sceneIdentifier)
sceneIdentifier: self.appDelegate.sceneIdentifier)

metadata.session = NCNetworking.shared.sessionUploadBackground
metadata.sessionSelector = NCGlobal.shared.selectorUploadFile
Expand Down Expand Up @@ -134,7 +138,7 @@ class NCAudioRecorderViewController: UIViewController, NCAudioRecorderDelegate {
}

voiceRecordHUD.update(CGFloat(rate))
voiceRecordHUD.fillColor = UIColor.green
voiceRecordHUD.fillColor = NCBrandColor.shared.progressColorGreen60

let formatter = DateComponentsFormatter()
formatter.allowedUnits = [.second]
Expand All @@ -148,7 +152,8 @@ class NCAudioRecorderViewController: UIViewController, NCAudioRecorderDelegate {
}

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

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

Expand Down
33 changes: 33 additions & 0 deletions iOSClient/Main/Create cloud/FolderPathCustomCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// FolderPathCustomCell.swift
// Nextcloud
//
// Created by Sumit on 28/04/21.
// Copyright © 2021 Marino Faggiana. All rights reserved.
//

import Foundation

class FolderPathCustomCell: XLFormButtonCell{

@IBOutlet weak var photoLabel: UILabel!
@IBOutlet weak var folderImage: UIImageView!
@IBOutlet weak var bottomLineView: UIView!

override func awakeFromNib() {
super.awakeFromNib()
}

override func configure() {
super.configure()
}

override func update() {
super.update()
if (rowDescriptor.tag == "PhotoButtonDestinationFolder"){
bottomLineView.isHidden = true
}else{
bottomLineView.isHidden = false
}
}
}
Loading