diff --git a/Tests/NextcloudUnitTests/AudioUploadTests.swift b/Tests/NextcloudUnitTests/AudioUploadTests.swift new file mode 100644 index 0000000000..2ea01a8085 --- /dev/null +++ b/Tests/NextcloudUnitTests/AudioUploadTests.swift @@ -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") + } +} diff --git a/iOSClient/Login/NCLoginWeb.swift b/iOSClient/Login/NCLoginWeb.swift index 8ced23e0ff..100acae9c2 100644 --- a/iOSClient/Login/NCLoginWeb.swift +++ b/iOSClient/Login/NCLoginWeb.swift @@ -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 { diff --git a/iOSClient/Networking/NCAutoUpload.swift b/iOSClient/Networking/NCAutoUpload.swift index dd04f9581c..7e5aa59c55 100644 --- a/iOSClient/Networking/NCAutoUpload.swift +++ b/iOSClient/Networking/NCAutoUpload.swift @@ -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 diff --git a/iOSClient/Settings/CCManageAutoUpload.m b/iOSClient/Settings/CCManageAutoUpload.m index 269379039f..0e8d106c5f 100644 --- a/iOSClient/Settings/CCManageAutoUpload.m +++ b/iOSClient/Settings/CCManageAutoUpload.m @@ -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 @@ -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"]; @@ -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)]; @@ -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 @@ -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)]; @@ -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 @@ -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 @@ -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)], @@ -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"]) { @@ -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"]; @@ -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]; @@ -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"]; @@ -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; diff --git a/iOSClient/Settings/NCManageAutoUploadFileName.swift b/iOSClient/Settings/NCManageAutoUploadFileName.swift index 13fbd79369..fc9c1997ac 100644 --- a/iOSClient/Settings/NCManageAutoUploadFileName.swift +++ b/iOSClient/Settings/NCManageAutoUploadFileName.swift @@ -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) @@ -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 @@ -72,9 +74,15 @@ 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 @@ -82,7 +90,7 @@ class NCManageAutoUploadFileName: XLFormViewController { 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 @@ -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 } @@ -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: "")