Skip to content
Closed
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
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")
}
}
22 changes: 14 additions & 8 deletions iOSClient/Login/NCLoginWeb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,20 @@ extension NCLoginWeb: WKNavigationDelegate {

self.appDelegate.changeAccount(account, userProfile: userProfile)

if self.presentingViewController == nil {
if let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController() {
viewController.modalPresentationStyle = .fullScreen
viewController.view.alpha = 0
self.appDelegate.window?.rootViewController = viewController
self.appDelegate.window?.makeKeyAndVisible()
UIView.animate(withDuration: 0.5) {
viewController.view.alpha = 1
if NCKeychain().intro {
self.dismiss(animated: true)
} else {
NCKeychain().intro = true
if self.presentingViewController == nil {
if let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController() {
viewController.modalPresentationStyle = .fullScreen
viewController.view.alpha = 0
NCKeychain().setOriginalFileName(key: NCGlobal.shared.keyFileNameOriginalAutoUpload, value: true)
self.appDelegate.window?.rootViewController = viewController
self.appDelegate.window?.makeKeyAndVisible()
UIView.animate(withDuration: 0.5) {
viewController.view.alpha = 1
}
}
}
} else {
Expand Down
9 changes: 9 additions & 0 deletions iOSClient/Networking/NCAutoUpload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ class NCAutoUpload: NSObject {
// MARK: -

@objc func initAutoUpload(viewController: UIViewController?, completion: @escaping (_ items: Int) -> Void) {
if(NCManageDatabase.shared.getAccountAutoUploadFileName() == "Kamera-Medien" || NCManageDatabase.shared.getAccountAutoUploadFileName() == "Camera-Media"){
//set autoupload folder as per locale
if(NCManageDatabase.shared.getAccountAutoUploadFileName() != NCBrandOptions.shared.folderDefaultAutoUpload){
//set auto upload as per locale
print("auto upload folder set here....")
NCManageDatabase.shared.setAccountAutoUploadFileName(NCBrandOptions.shared.folderDefaultAutoUpload)
}
}

guard let account = NCManageDatabase.shared.getActiveAccount(), account.autoUpload else {
completion(0)
return
Expand Down
44 changes: 39 additions & 5 deletions iOSClient/Settings/CCManageAutoUpload.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ - (void)initializeForm
else row.value = @0;
[row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
[row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
row.cellConfig[@"switchControl.onTintColor"] = NCBrandColor.shared.brand;
[section addFormRow:row];

// Auto Upload Directory
Expand All @@ -64,7 +65,7 @@ - (void)initializeForm
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadDirectory" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_autoupload_select_folder_", nil)];
row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
[row.cellConfig setObject:[[UIImage imageNamed:@"foldersOnTop"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
[row.cellConfig setObject:[[UIImage imageNamed:@"foldersOnTop"] imageWithColor:NCBrandColor.shared.iconColor size:25] forKey:@"imageView.image"];
[row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
[row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
[row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
Expand All @@ -84,6 +85,7 @@ - (void)initializeForm
else row.value = @0;
[row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
[row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
row.cellConfig[@"switchControl.onTintColor"] = NCBrandColor.shared.brand;
[section addFormRow:row];

row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadWWAnPhoto" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_wifi_only_", nil)];
Expand All @@ -93,6 +95,7 @@ - (void)initializeForm
else row.value = @0;
[row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
[row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
row.cellConfig[@"switchControl.onTintColor"] = NCBrandColor.shared.brand;
[section addFormRow:row];

// Auto Upload Video
Expand All @@ -107,6 +110,7 @@ - (void)initializeForm
else row.value = @0;
[row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
[row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
row.cellConfig[@"switchControl.onTintColor"] = NCBrandColor.shared.brand;
[section addFormRow:row];

row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadWWAnVideo" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_wifi_only_", nil)];
Expand All @@ -116,6 +120,21 @@ - (void)initializeForm
else row.value = @0;
[row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
[row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
row.cellConfig[@"switchControl.onTintColor"] = NCBrandColor.shared.brand;
[section addFormRow:row];

// Delete asset remove photo camera roll
section = [XLFormSectionDescriptor formSection];
[form addFormSection:section];

row = [XLFormRowDescriptor formRowDescriptorWithTag:@"removePhotoCameraRoll" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_remove_photo_CameraRoll_", nil)];
row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
if ([[[NCKeychain alloc] init] removePhotoCameraRoll]) row.value = @"1";
else row.value = @0;
[row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
[row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
row.cellConfig[@"switchControl.onTintColor"] = NCBrandColor.shared.brand;
[section addFormRow:row];

// Auto Upload Full
Expand All @@ -131,6 +150,7 @@ - (void)initializeForm
else row.value = @0;
[row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
[row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
row.cellConfig[@"switchControl.onTintColor"] = NCBrandColor.shared.brand;
[section addFormRow:row];

// Auto Upload create subfolder
Expand All @@ -145,11 +165,13 @@ - (void)initializeForm
else row.value = @0;
[row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
[row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
row.cellConfig[@"switchControl.onTintColor"] = NCBrandColor.shared.brand;
[section addFormRow:row];

row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadSubfolderGranularity" rowType:XLFormRowDescriptorTypeSelectorPush title:NSLocalizedString(@"_autoupload_subfolder_granularity_", nil)];
row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
row.cellConfigForSelector[@"tintColor"] = NCBrandColor.shared.customer;
row.selectorOptions = @[
[XLFormOptionsObject formOptionsObjectWithValue:@(NCGlobal.shared.subfolderGranularityYearly) displayText:NSLocalizedString(@"_yearly_", nil)],
[XLFormOptionsObject formOptionsObjectWithValue:@(NCGlobal.shared.subfolderGranularityMonthly) displayText:NSLocalizedString(@"_monthly_", nil)],
Expand Down Expand Up @@ -255,6 +277,11 @@ -(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor old

[self reloadForm];
}

if ([rowDescriptor.tag isEqualToString:@"removePhotoCameraRoll"]) {

[[NCKeychain alloc] init].removePhotoCameraRoll = [[rowDescriptor.value valueData] boolValue];
}

if ([rowDescriptor.tag isEqualToString:@"autoUploadFull"]) {

Expand Down Expand Up @@ -325,7 +352,7 @@ - (void)reloadForm

XLFormRowDescriptor *rowAutoUploadVideo = [self.form formRowWithTag:@"autoUploadVideo"];
XLFormRowDescriptor *rowAutoUploadWWAnVideo = [self.form formRowWithTag:@"autoUploadWWAnVideo"];

XLFormRowDescriptor *rowRemovePhotoCameraRoll = [self.form formRowWithTag:@"removePhotoCameraRoll"];
XLFormRowDescriptor *rowAutoUploadFull = [self.form formRowWithTag:@"autoUploadFull"];

XLFormRowDescriptor *rowAutoUploadCreateSubfolder = [self.form formRowWithTag:@"autoUploadCreateSubfolder"];
Expand All @@ -346,6 +373,9 @@ - (void)reloadForm
if (activeAccount.autoUploadWWAnPhoto)
[rowAutoUploadWWAnPhoto setValue:@1]; else [rowAutoUploadWWAnPhoto setValue:@0];

if ([[[NCKeychain alloc] init] removePhotoCameraRoll])
[rowRemovePhotoCameraRoll setValue:@1]; else [rowRemovePhotoCameraRoll setValue:@0];

if (activeAccount.autoUploadVideo)
[rowAutoUploadVideo setValue:@1]; else [rowAutoUploadVideo setValue:@0];

Expand All @@ -367,7 +397,7 @@ - (void)reloadForm

rowAutoUploadVideo.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
rowAutoUploadWWAnVideo.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];

rowRemovePhotoCameraRoll.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
rowAutoUploadFull.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];

rowAutoUploadCreateSubfolder.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
Expand Down Expand Up @@ -403,14 +433,18 @@ - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInte
else sectionName = @"";
break;
case 4:
if (activeAccount.autoUpload) sectionName = NSLocalizedString(@"_autoupload_fullphotos_footer_", nil);
if (activeAccount.autoUpload) sectionName = NSLocalizedString(@"_remove_photo_CameraRoll_desc_", nil);
else sectionName = @"";
break;
case 5:
if (activeAccount.autoUpload) sectionName = NSLocalizedString(@"_autoupload_create_subfolder_footer_", nil);
if (activeAccount.autoUpload) sectionName = NSLocalizedString(@"_autoupload_description_background_", nil);
else sectionName = @"";
break;
case 6:
if (activeAccount.autoUpload) sectionName = NSLocalizedString(@"_autoupload_create_subfolder_footer_", nil);
else sectionName = @"";
break;
case 7:
if (activeAccount.autoUpload) sectionName = NSLocalizedString(@"_autoupload_filenamemask_footer_", nil);
else sectionName = @"";
break;
Expand Down
19 changes: 16 additions & 3 deletions iOSClient/Settings/NCManageAutoUploadFileName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class NCManageAutoUploadFileName: XLFormViewController {

row = XLFormRowDescriptor(tag: "maintainOriginalFileName", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_maintain_original_filename_", comment: ""))
row.value = NCKeychain().getOriginalFileName(key: NCGlobal.shared.keyFileNameOriginalAutoUpload)
row.cellConfig["switchControl.onTintColor"] = NCBrandColor.shared.brand;
row.cellConfig["backgroundColor"] = UIColor.secondarySystemGroupedBackground

row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
Expand All @@ -60,6 +61,7 @@ class NCManageAutoUploadFileName: XLFormViewController {
row.value = NCKeychain().getFileNameType(key: NCGlobal.shared.keyFileNameAutoUploadType)
row.hidden = "$\("maintainOriginalFileName") == 1"
row.cellConfig["backgroundColor"] = UIColor.secondarySystemGroupedBackground
row.cellConfig["switchControl.onTintColor"] = NCBrandColor.shared.brand;

row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
row.cellConfig["textLabel.textColor"] = UIColor.label
Expand All @@ -72,17 +74,23 @@ class NCManageAutoUploadFileName: XLFormViewController {
form.addFormSection(section)

row = XLFormRowDescriptor(tag: "maskFileName", rowType: XLFormRowDescriptorTypeText, title: (NSLocalizedString("_filename_", comment: "")))

let fileNameMask: String = NCKeychain().getFileNameMask(key: NCGlobal.shared.keyFileNameAutoUploadMask)
if !fileNameMask.isEmpty {
row.cellConfig["textField.text"] = fileNameMask
row.value = fileNameMask
}else{
let placeholderText = CCUtility.createFileName("IMG_0001.JPG", fileDate: dateExample, fileType: PHAssetMediaType.image, keyFileName: nil, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)
row.cellConfig["textField.text"] = placeholderText
row.value = ""
}
row.hidden = "$\("maintainOriginalFileName") == 1"
row.cellConfig["backgroundColor"] = UIColor.secondarySystemGroupedBackground

row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
row.cellConfig["textLabel.textColor"] = UIColor.label

row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
row.cellConfig["textField.textAlignment"] = NSTextAlignment.left.rawValue
row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 15.0)
row.cellConfig["textField.textColor"] = UIColor.label

Expand Down Expand Up @@ -134,7 +142,13 @@ class NCManageAutoUploadFileName: XLFormViewController {
let maskFileName: XLFormRowDescriptor = self.form.formRow(withTag: "maskFileName")!
let previewFileName: XLFormRowDescriptor = self.form.formRow(withTag: "previewFileName")!
previewFileName.value = self.previewFileName(valueRename: maskFileName.value as? String)

let placeholderText = CCUtility.createFileName("IMG_0001.JPG", fileDate: dateExample, fileType: PHAssetMediaType.image, keyFileName: nil, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)
let fileNameMask : String = NCKeychain().getFileNameMask(key: NCGlobal.shared.keyFileNameAutoUploadMask)
if fileNameMask.count > 0 {
maskFileName.cellConfig["textField.text"] = fileNameMask
}else {
maskFileName.cellConfig["textField.text"] = placeholderText
}
self.tableView.reloadData()
self.form.delegate = self
}
Expand Down Expand Up @@ -208,7 +222,6 @@ class NCManageAutoUploadFileName: XLFormViewController {

returnString = CCUtility.createFileName("IMG_0001.JPG", fileDate: dateExample, fileType: PHAssetMediaType.image, keyFileName: NCGlobal.shared.keyFileNameAutoUploadMask, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)
}

} else {

NCKeychain().setFileNameMask(key: NCGlobal.shared.keyFileNameAutoUploadMask, mask: "")
Expand Down