diff --git a/Tests/NextcloudUnitTests/SettingsTestCases.swift b/Tests/NextcloudUnitTests/SettingsTestCases.swift new file mode 100644 index 0000000000..4b16db93f3 --- /dev/null +++ b/Tests/NextcloudUnitTests/SettingsTestCases.swift @@ -0,0 +1,341 @@ +// +// SettingsTestCases.swift +// NextcloudTests +// +// Created by A200073704 on 12/05/23. +// Copyright © 2023 Marino Faggiana. All rights reserved. +// + +@testable import Nextcloud +import XCTest +import NextcloudKit +import XLForm + + class SettingsTestCases: XCTestCase { + + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + // MARK: - Settings + + func testAutoUploadSectionIsPresent() { + + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + + var section : XLFormSectionDescriptor + var row : XLFormRowDescriptor + + let image = UIImage(named: "autoUpload") + row = XLFormRowDescriptor(tag: "autoUpload", rowType: XLFormRowDescriptorTypeButton, title: NSLocalizedString("_settings_autoupload_", comment: "")); + section = XLFormSectionDescriptor.formSection(withTitle: "") + section.addFormRow(row) + + XCTAssertNotNil(image) + // Verify that section was found + XCTAssertNotNil(row, "Expected 'Auto Upload' section to exist in form.") + + + } + + func testLockSectionIsPresent() { + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + + var section : XLFormSectionDescriptor + var row : XLFormRowDescriptor + + let image = UIImage(named: "lock_open") + row = XLFormRowDescriptor(tag: "bloccopasscode", rowType: XLFormRowDescriptorTypeButton, title: NSLocalizedString("_lock_not_active_", comment: "")); + section = XLFormSectionDescriptor.formSection(withTitle: "") + section.addFormRow(row) + + XCTAssertNotNil(image) + + XCTAssertNotNil(row, "Expected 'Lock Active / Off ' section exists") + + + } + + func testEnableTouchIDSectionIsPresent() { + + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + + var section : XLFormSectionDescriptor + var row : XLFormRowDescriptor + + row = XLFormRowDescriptor(tag: "enableTouchDaceID", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_enable_touch_face_id_", comment: "")); + section = XLFormSectionDescriptor.formSection(withTitle: "") + section.addFormRow(row) + + XCTAssertNotNil(row, "Expected 'Enable/Disable touch ID' is present") + + } + + func testEndToEndEncryptionSectionIsPresent() { + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + + var section : XLFormSectionDescriptor + var row : XLFormRowDescriptor + + row = XLFormRowDescriptor(tag: "e2eEncryption", rowType: XLFormRowDescriptorTypeButton, title: NSLocalizedString("_e2e_settings_", comment: "")); + section = XLFormSectionDescriptor.formSection(withTitle: "") + section.addFormRow(row) + + XCTAssertNotNil(row, "Expected 'End to End encryption' section exists") + + + } + + func testAdvancedSectionIsPresent() { + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + + var section : XLFormSectionDescriptor + var row : XLFormRowDescriptor + + row = XLFormRowDescriptor(tag: "advanced", rowType: XLFormRowDescriptorTypeButton, title: NSLocalizedString("_e2e_settings_", comment: "")); + section = XLFormSectionDescriptor.formSection(withTitle: "") + section.addFormRow(row) + + XCTAssertNotNil(row, " Expected 'Advanced' Section exists") + } + + + + func testNavigatesToOpenSourceViewController() { + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + let section = XLFormSectionDescriptor.formSection() + form.addFormSection(section) + + let row = XLFormRowDescriptor(tag: "buttonLeftAligned", rowType: XLFormRowDescriptorTypeButton, title: NSLocalizedString("_used_opensource_software_", comment: "")) + section.addFormRow(row) + + // Create a view controller with the form and add it to a navigation controller + let viewController = OpenSourceSoftwareViewController() + let window = UIApplication.shared.windows.first { $0.isKeyWindow } + let navigationController = UINavigationController(rootViewController: viewController) + window?.rootViewController = navigationController + + viewController.loadViewIfNeeded() + let indexPath = IndexPath(row: 0, section: 0) + print("Calling didSelectRowAt for row at \(indexPath)") + + // Verify that the OpenSourceSoftwareViewController class is opened + XCTAssertTrue(navigationController.topViewController is OpenSourceSoftwareViewController) + + } + + func testHelpSectionIsPresent() { + + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + let section = XLFormSectionDescriptor.formSection() + form.addFormSection(section) + + let row = XLFormRowDescriptor(tag: "buttonLeftAligned", rowType: XLFormRowDescriptorTypeButton, title: NSLocalizedString("_help_", comment: "")) + section.addFormRow(row) + + // Create a view controller with the form and add it to a navigation controller + let viewController = HelpViewController() + let window = UIApplication.shared.windows.first { $0.isKeyWindow } + let navigationController = UINavigationController(rootViewController: viewController) + window?.rootViewController = navigationController + + viewController.loadViewIfNeeded() + let indexPath = IndexPath(row: 0, section: 0) + print("Calling didSelectRowAt for row at \(indexPath)") + + // Verify that the HelpViewController class is opened + XCTAssertTrue(navigationController.topViewController is HelpViewController) + + XCTAssertNotNil(row, "Expected 'Help' Section is present") + + } + + func testImprintSectionIsPresent() { + + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + let section = XLFormSectionDescriptor.formSection() + form.addFormSection(section) + + let row = XLFormRowDescriptor(tag: "buttonLeftAligned", rowType: XLFormRowDescriptorTypeButton, title: NSLocalizedString("_imprint_", comment: "")) + section.addFormRow(row) + + // Create a view controller with the form and add it to a navigation controller + let viewController = ImprintViewController() + let window = UIApplication.shared.windows.first { $0.isKeyWindow } + let navigationController = UINavigationController(rootViewController: viewController) + window?.rootViewController = navigationController + + viewController.loadViewIfNeeded() + let indexPath = IndexPath(row: 0, section: 0) + print("Calling didSelectRowAt for row at \(indexPath)") + + // Verify that the ImprintViewController class is opened + XCTAssertTrue(navigationController.topViewController is ImprintViewController) + + XCTAssertNotNil(row, "Expected 'Imprint' Section is present") + } + + func testMagentaCloudVersionSectionIsPresent() { + + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + let section = XLFormSectionDescriptor.formSection() + form.addFormSection(section) + + let row = XLFormRowDescriptor(tag: "disablefilesapp", rowType: "kNMCCustomCellType", title: NSLocalizedString("_magentacloud_version_", comment: "")) + section.addFormRow(row) + + XCTAssertNotNil(row, "Expected 'MagentaCloud Version' is present") + + + } + + // MARK: - Advanced + + func testShowHiddenFilesSectionIsPresent() { + + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + let section = XLFormSectionDescriptor.formSection() + form.addFormSection(section) + + let row = XLFormRowDescriptor(tag: "showHiddenFiles", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_show_hidden_files_", comment: "")) + section.addFormRow(row) + + XCTAssertNotNil(row, "Expected 'Show hidden files' section is present") + + } + + func testMostCompatibleSectionIsPresent() { + + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + let section = XLFormSectionDescriptor.formSection() + form.addFormSection(section) + + let row = XLFormRowDescriptor(tag: "formatCompatibility", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_format_compatibility_", comment: "")) + row.value = "1" + section.addFormRow(row) + + XCTAssertNotNil(row, "Expected 'Most Compatible' is present") + } + + func testLivePhotoSectionIsPresent() { + + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + let section = XLFormSectionDescriptor.formSection() + form.addFormSection(section) + + let row = XLFormRowDescriptor(tag: "livePhoto", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_upload_mov_livephoto_", comment: "")) + if CCUtility.getLivePhoto() { + row.value = "1" + } else { + row.value = "0" + } + section.addFormRow(row) + + XCTAssertNotNil(row, "Expected 'Live Photo' section is present") + + } + + func testImageResolutionSectionIsPresent() { + + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + let section = XLFormSectionDescriptor.formSection() + form.addFormSection(section) + + let row = XLFormRowDescriptor(tag: "automaticDownloadImage", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_automatic_Download_Image_", comment: "")) + section.addFormRow(row) + + XCTAssertNotNil(row, "Expected 'Use images in full resolution' section is present") + } + + func testAppIntegrationSectionIsPresent() { + + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + let section = XLFormSectionDescriptor.formSection() + form.addFormSection(section) + + let row = XLFormRowDescriptor(tag: "disablefilesapp", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_disable_files_app_", comment: "")) + section.addFormRow(row) + + XCTAssertNotNil(row, "Expected 'Disable Files App Integration' section is present") + } + + func testDeleteFilesSectionIsPresent() { + + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + let section = XLFormSectionDescriptor.formSection() + form.addFormSection(section) + + let row = XLFormRowDescriptor(tag: "deleteoldfiles", rowType: XLFormRowDescriptorTypeSelectorPush, title: NSLocalizedString("_delete_old_files_", comment: "")) + section.addFormRow(row) + + XCTAssertNotNil(row, "Expected 'Delete all files older than..' section is present") + } + + func testClearCacheSectionIsPresent() { + + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + let section = XLFormSectionDescriptor.formSection() + form.addFormSection(section) + + let image = UIImage(named: "trash") + + let row = XLFormRowDescriptor(tag: "azzeracache", rowType:XLFormRowDescriptorTypeButton, title: NSLocalizedString("_clear_cache_", comment: "")) + section.addFormRow(row) + + XCTAssertNotNil(image) + + XCTAssertNotNil(row, "Expected 'Clear Cache' section is present") + + } + + func testLogoutButtonIsPresent() { + + let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor + form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow + let section = XLFormSectionDescriptor.formSection() + form.addFormSection(section) + + let image = UIImage(named: "xmark") + + let row = XLFormRowDescriptor(tag: "esci", rowType: XLFormRowDescriptorTypeButton, title: NSLocalizedString("_exit_", comment: "")) + section.addFormRow(row) + + XCTAssertNotNil(image) + + XCTAssertNotNil(row, "Expected 'Logout' Button is present") + + + } + + + + + + + + + + + +} diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index d404eb425c..af75881150 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -52,6 +52,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]; // Format Compatibility + Live Photo + Delete asset @@ -66,6 +67,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:@"livePhoto" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_upload_mov_livephoto_", nil)]; @@ -74,14 +76,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"]; - [section addFormRow:row]; - - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"removePhotoCameraRoll" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_remove_photo_CameraRoll_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - 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]; // Section : Files App -------------------------------------------------------------- @@ -99,6 +94,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]; } @@ -120,6 +116,7 @@ - (void)initializeForm [section addFormRow:row]; } +#ifdef DEBUG // Section DIAGNOSTICS ------------------------------------------------- section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_diagnostics_", nil)]; @@ -191,6 +188,7 @@ - (void)initializeForm [self.navigationController pushViewController:vc animated:YES]; }; [section addFormRow:row]; +#endif // Section : Delete files / Clear cache -------------------------------------------------------------- diff --git a/iOSClient/Settings/HelpViewController.swift b/iOSClient/Settings/HelpViewController.swift new file mode 100644 index 0000000000..eb91d7b4cf --- /dev/null +++ b/iOSClient/Settings/HelpViewController.swift @@ -0,0 +1,57 @@ +// +// HelpViewController.swift +// Nextcloud +// +// Created by A200073704 on 11/05/23. +// Copyright © 2023 Marino Faggiana. All rights reserved. +// + +import UIKit +import WebKit + +class HelpViewController: UIViewController, WKNavigationDelegate, WKUIDelegate { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + + self.title = NSLocalizedString("_help_", comment: "") + let myWebView:WKWebView = WKWebView(frame: CGRect(x:0, y:0, width: UIScreen.main.bounds.width, height:UIScreen.main.bounds.height)) + myWebView.uiDelegate = self + myWebView.navigationDelegate = self + myWebView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + self.view.addSubview(myWebView) + + + //1. Load web site into my web view + let myURL = URL(string: "https://cloud.telekom-dienste.de/hilfe") + let myURLRequest:URLRequest = URLRequest(url: myURL!) + NCActivityIndicator.shared.start() + myWebView.load(myURLRequest) + + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { + NCActivityIndicator.shared.stop() + } + + func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { + if navigationAction.navigationType == .linkActivated { + if let url = navigationAction.request.url, + UIApplication.shared.canOpenURL(url) { + UIApplication.shared.open(url) + decisionHandler(.cancel) + } else { + decisionHandler(.allow) + } + } else { + decisionHandler(.allow) + } + } +} + diff --git a/iOSClient/Settings/ImprintViewController.swift b/iOSClient/Settings/ImprintViewController.swift new file mode 100644 index 0000000000..819a86599d --- /dev/null +++ b/iOSClient/Settings/ImprintViewController.swift @@ -0,0 +1,70 @@ +// +// ImprintViewController.swift +// Nextcloud +// +// Created by A200073704 on 11/05/23. +// Copyright © 2023 Marino Faggiana. All rights reserved. +// + +import UIKit +import WebKit + +class ImprintViewController: UIViewController, WKNavigationDelegate, WKUIDelegate { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + self.title = NSLocalizedString("_imprint_", comment: "") + + let myWebView:WKWebView = WKWebView(frame: CGRect(x:0, y:0, width: UIScreen.main.bounds.width, height:UIScreen.main.bounds.height)) + myWebView.uiDelegate = self + myWebView.navigationDelegate = self + myWebView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + self.view.addSubview(myWebView) + + + //1. Load web site into my web view + let myURL = URL(string: "https://www.telekom.de/impressum") + let myURLRequest:URLRequest = URLRequest(url: myURL!) + NCActivityIndicator.shared.start() + myWebView.load(myURLRequest) + + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { + NCActivityIndicator.shared.stop() + } + + override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + super.viewWillTransition(to: size, with: coordinator) + + if UIDevice.current.orientation.isLandscape { + print("Landscape") + } + if UIDevice.current.orientation.isFlat { + print("Flat") + } else { + print("Portrait") + } + } + + func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { + if navigationAction.navigationType == .linkActivated { + if let url = navigationAction.request.url, + UIApplication.shared.canOpenURL(url) { + UIApplication.shared.open(url) + decisionHandler(.cancel) + } else { + decisionHandler(.allow) + } + } else { + decisionHandler(.allow) + } + } +} + diff --git a/iOSClient/Settings/MagentaCloudVersionView.swift b/iOSClient/Settings/MagentaCloudVersionView.swift new file mode 100644 index 0000000000..16de2ec088 --- /dev/null +++ b/iOSClient/Settings/MagentaCloudVersionView.swift @@ -0,0 +1,31 @@ +// +// MagentaCloudVersionView.swift +// Nextcloud +// +// Created by A200073704 on 11/05/23. +// Copyright © 2023 Marino Faggiana. All rights reserved. +// + +import Foundation + + +class MagentaCloudVersionView: XLFormBaseCell{ + + + @IBOutlet weak var cellLabel: UILabel! + @IBOutlet weak var versionLabel: UILabel! + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + self.selectionStyle = .none + } + + override func configure() { + super.configure() + } + + override func update() { + super.update() + } +} diff --git a/iOSClient/Settings/MagentaCloudVersionView.xib b/iOSClient/Settings/MagentaCloudVersionView.xib new file mode 100644 index 0000000000..9c9d06adfe --- /dev/null +++ b/iOSClient/Settings/MagentaCloudVersionView.xib @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOSClient/Settings/NCSettings.m b/iOSClient/Settings/NCSettings.m index 2aad8d9498..54109b8db6 100644 --- a/iOSClient/Settings/NCSettings.m +++ b/iOSClient/Settings/NCSettings.m @@ -64,19 +64,19 @@ - (void)initializeForm row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"autoUpload"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"]; + [row.cellConfig setObject:[[UIImage imageNamed:@"autoUpload"] imageWithColor:NCBrandColor.shared.iconColor size:25] forKey:@"imageView.image"]; row.action.viewControllerClass = [CCManageAutoUpload class]; [section addFormRow:row]; - // Section : PRIVACY -------------------------------------------------------------- + // Section : SECURITY -------------------------------------------------------------- - section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_privacy_", nil)]; + section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_security_", nil)]; [form addFormSection:section]; // Lock active YES/NO row = [XLFormRowDescriptor formRowDescriptorWithTag:@"bloccopasscode" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_lock_not_active_", nil)]; row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[[UIImage imageNamed:@"lock_open"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"]; + [row.cellConfig setObject:[[UIImage imageNamed:@"lock_open"] 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"]; @@ -88,42 +88,13 @@ - (void)initializeForm row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [section addFormRow:row]; - // Lock no screen - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"notPasscodeAtStart" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_lock_protection_no_screen_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [section addFormRow:row]; - // Privacy screen - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"privacyScreen" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_privacy_screen_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [section addFormRow:row]; - // Reset app wrong attemps - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"resetAppAttemps" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_reset_wrong_passcode_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [section addFormRow:row]; - - // Section : CALDAV CARDAV -------------------------------------------------------------- - - if (!NCBrandOptions.shared.disable_mobileconfig) { - - section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_calendar_contacts_", nil)]; - [form addFormSection:section]; - - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"caldavcardav" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_mobile_config_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"caldavcardav"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"]; - row.action.formSelector = @selector(CalDAVCardDAV:); - [section addFormRow:row]; + row.cellConfig[@"switchControl.onTintColor"] = NCBrandColor.shared.brand; + if([[NCKeychain alloc] init].passcode){ + row.disabled = @NO; + }else{ + row.disabled = @YES; } + [section addFormRow:row]; // Section : E2EEncryption -------------------------------------------------------------- @@ -132,9 +103,6 @@ - (void)initializeForm if (isE2EEEnabled == YES && [NCGlobal.shared.e2eeVersions containsObject:versionE2EE]) { - section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_title_", nil)]; - [form addFormSection:section]; - // EndToEnd Encryption NSString *title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"_e2e_settings_", nil)]; row = [XLFormRowDescriptor formRowDescriptorWithTag:@"e2eEncryption" rowType:XLFormRowDescriptorTypeButton title:title]; @@ -142,7 +110,7 @@ - (void)initializeForm [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"]; + [row.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:NCBrandColor.shared.iconColor size:25] forKey:@"imageView.image"]; row.action.formSelector = @selector(manageE2EE:); [section addFormRow:row]; } @@ -157,50 +125,91 @@ - (void)initializeForm row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"gear"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"]; + [row.cellConfig setObject:[[UIImage imageNamed:@"gear"] imageWithColor:NCBrandColor.shared.iconColor size:25] forKey:@"imageView.image"]; row.action.viewControllerClass = [CCAdvanced class]; [section addFormRow:row]; - // Section : INFORMATION ------------------------------------------------ + // Section : DATA PROTECTION ------------------------------------------------ - section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_information_", nil)]; + section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_data_protection_", nil)]; [form addFormSection:section]; - // Acknowledgements - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"buttonLeftAligned" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_acknowledgements_", nil)]; + // Privacy Settings + PrivacySettingsViewController *privacySettingsViewController = [[PrivacySettingsViewController alloc] init]; + privacySettingsViewController.isShowSettingsButton = true; + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"showSettingsButton"]; + [[NSUserDefaults standardUserDefaults] synchronize]; + row = [XLFormRowDescriptor formRowDescriptorWithTag:@"privacySettings" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_privacy_settings_", nil)]; row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"acknowledgements"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"]; - row.action.formBlock = ^(XLFormRowDescriptor * sender){ - [self performSegueWithIdentifier:@"AcknowledgementsSegue" sender:sender]; - [self deselectFormRow:sender]; - }; + row.action.viewControllerClass = [privacySettingsViewController class]; + [section addFormRow:row]; + + // Privacy Policy + row = [XLFormRowDescriptor formRowDescriptorWithTag:@"advanced" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_privacy_policy_", nil)]; + row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; + [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"]; + row.action.viewControllerClass = [PrivacyPolicyViewController class]; + [section addFormRow:row]; + + // Used OpenSource Software + row = [XLFormRowDescriptor formRowDescriptorWithTag:@"buttonLeftAligned" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_used_opensource_software_", nil)]; + row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; + [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; + [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"]; + [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; + row.action.viewControllerClass = [OpenSourceSoftwareViewController class]; [section addFormRow:row]; - if (!NCBrandOptions.shared.disable_crash_service) { - - // Privacy and Legal Policy - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"privacy" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_privacy_legal_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"shield.checkerboard"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"]; - row.action.formSelector = @selector(privacy:); - [section addFormRow:row]; - - // Source code - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"sourcecode" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_source_code_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"gitHub"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"]; - row.action.formSelector = @selector(sourceCode:); - [section addFormRow:row]; - } + + // Section : SERVICE ------------------------------------------------ + + section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_service_", nil)]; + [form addFormSection:section]; + + // HELP + row = [XLFormRowDescriptor formRowDescriptorWithTag:@"buttonLeftAligned" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_help_", nil)]; + row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; + [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; + [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"]; + [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; + row.action.viewControllerClass = [HelpViewController class]; + [section addFormRow:row]; + + // Imprint + row = [XLFormRowDescriptor formRowDescriptorWithTag:@"buttonLeftAligned" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_imprint_", nil)]; + row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; + [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; + [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"]; + [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; + row.action.viewControllerClass = [ImprintViewController class]; + [section addFormRow:row]; + + // Section : INFO ------------------------------------------------ + + section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_info_", nil)]; + [form addFormSection:section]; + + //MagentaCloud Version + + //custom cell + + [[XLFormViewController cellClassesForRowDescriptorTypes] setObject:[MagentaCloudVersionView class] forKey:@"kNMCCustomCellType"]; + + row = [XLFormRowDescriptor formRowDescriptorWithTag:@"disablefilesapp" rowType:@"kNMCCustomCellType" title:NSLocalizedString(@"_magentacloud_version_", nil)]; + NSString *appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleInfoDictionaryVersion"]; + row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; + row.cellConfigAtConfigure[@"cellLabel.text"] = NSLocalizedString(@"_magentacloud_version_", nil); + [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"cellLabel.font"]; + [row.cellConfig setObject:UIColor.labelColor forKey:@"cellLabel.textColor"]; + row.cellConfigAtConfigure[@"versionLabel.text"] = appVersion; + [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"versionLabel.font"]; + [row.cellConfig setObject:UIColor.systemGrayColor forKey:@"versionLabel.textColor"]; + [section addFormRow:row]; self.tableView.showsVerticalScrollIndicator = NO; self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 35, 0); @@ -219,7 +228,7 @@ - (void)viewDidLoad appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:NCGlobal.shared.notificationCenterApplicationDidEnterBackground object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeUser) name:NCGlobal.shared.notificationCenterChangeUser object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeUser) name:NCGlobal.shared.notificationCenterInitialize object:nil]; [self initializeForm]; [self reloadForm]; @@ -267,23 +276,23 @@ - (void)reloadForm XLFormRowDescriptor *rowBloccoPasscode = [self.form formRowWithTag:@"bloccopasscode"]; XLFormRowDescriptor *rowNotPasscodeAtStart = [self.form formRowWithTag:@"notPasscodeAtStart"]; XLFormRowDescriptor *rowEnableTouchDaceID = [self.form formRowWithTag:@"enableTouchDaceID"]; - XLFormRowDescriptor *rowResetAppAttemps = [self.form formRowWithTag:@"resetAppAttemps"]; - XLFormRowDescriptor *rowPrivacyScreen = [self.form formRowWithTag:@"privacyScreen"]; // ------------------------------------------------------------------ if ([[NCKeychain alloc] init].passcode) { rowBloccoPasscode.title = NSLocalizedString(@"_lock_active_", nil); - [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"]; + [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:NCBrandColor.shared.iconColor size:25] forKey:@"imageView.image"]; + rowEnableTouchDaceID.disabled = @NO; + rowNotPasscodeAtStart.disabled = @NO; } else { rowBloccoPasscode.title = NSLocalizedString(@"_lock_not_active_", nil); - [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock_open"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"]; + [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock_open"] imageWithColor:NCBrandColor.shared.iconColor size:25] forKey:@"imageView.image"]; + rowEnableTouchDaceID.disabled = @YES; + rowNotPasscodeAtStart.disabled = @YES; } - - if ([[NCKeychain alloc] init].resetAppCounterFail) [rowResetAppAttemps setValue:@1]; else [rowResetAppAttemps setValue:@0]; + if ([[NCKeychain alloc] init].touchFaceID) [rowEnableTouchDaceID setValue:@1]; else [rowEnableTouchDaceID setValue:@0]; if ([[NCKeychain alloc] init].requestPasscodeAtStart) [rowNotPasscodeAtStart setValue:@0]; else [rowNotPasscodeAtStart setValue:@1]; - if ([[NCKeychain alloc] init].privacyScreenEnabled) [rowPrivacyScreen setValue:@1]; else [rowPrivacyScreen setValue:@0]; // ----------------------------------------------------------------- @@ -314,21 +323,6 @@ - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor ol [[NCKeychain alloc] init].touchFaceID = false; } } - - if ([rowDescriptor.tag isEqualToString:@"privacyScreen"]) { - - if ([[rowDescriptor.value valueData] boolValue] == YES) { - [[NCKeychain alloc] init].privacyScreenEnabled = true; - } else { - [[NCKeychain alloc] init].privacyScreenEnabled = false; - } - } - - if ([rowDescriptor.tag isEqualToString:@"resetAppAttemps"]) { - - NSInteger value = [[rowDescriptor.value valueData] intValue]; - [[NCKeychain alloc] init].resetAppCounterFail = value; - } } #pragma mark - @@ -341,42 +335,6 @@ - (void)manageE2EE:(XLFormRowDescriptor *)sender [self.navigationController pushViewController:vc animated:YES]; } -- (void)privacy:(XLFormRowDescriptor *)sender -{ - [self deselectFormRow:sender]; - - NCBrowserWeb* browserWebVC = [[UIStoryboard storyboardWithName:@"NCBrowserWeb" bundle:nil] instantiateInitialViewController]; - - browserWebVC.urlBase = NCBrandOptions.shared.privacy; - browserWebVC.isHiddenButtonExit = false; - browserWebVC.titleBrowser = NSLocalizedString(@"_privacy_", nil); - - [self presentViewController:browserWebVC animated:YES completion:nil]; -} - -- (void)sourceCode:(XLFormRowDescriptor *)sender -{ - [self deselectFormRow:sender]; - - NCBrowserWeb* browserWebVC = [[UIStoryboard storyboardWithName:@"NCBrowserWeb" bundle:nil] instantiateInitialViewController]; - - browserWebVC.urlBase = NCBrandOptions.shared.sourceCode; - browserWebVC.isHiddenButtonExit = false; - browserWebVC.titleBrowser = NSLocalizedString(@"_source_code_", nil); - - [self presentViewController:browserWebVC animated:YES completion:nil]; -} - -- (void)CalDAVCardDAV:(XLFormRowDescriptor *)sender -{ - [self deselectFormRow:sender]; - - NSString *url = [appDelegate.urlBase stringByAppendingString:NCBrandOptions.shared.mobileconfig]; - NCConfigServer *configServer = [NCConfigServer new]; - [configServer startServiceWithUrl:[NSURL URLWithString: url]]; -} - - #pragma mark - Passcode - (void)didPerformBiometricValidationRequestInPasscodeViewController:(TOPasscodeViewController *)passcodeViewController @@ -471,18 +429,6 @@ - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInte NSString *sectionName; NSInteger numSections = [tableView numberOfSections] - 1; - if (section == 1) { - NSString *lock = NSLocalizedString(@"_lock_protection_no_screen_footer_", nil); - NSString *reset = [NSString stringWithFormat:NSLocalizedString(@"_reset_wrong_passcode_desc_", nil), NCBrandOptions.shared.resetAppPasscodeAttempts]; - sectionName = [NSString stringWithFormat:@"%@\n%@", lock, reset]; - } else if (section == 2 && !NCBrandOptions.shared.disable_mobileconfig) { - sectionName = NSLocalizedString(@"_calendar_contacts_footer_", nil); - } else if (section == numSections) { - NSString *versionNextcloud = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudServer, versionServer]; - NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, [[[NCUtility alloc] init] getVersionAppWithBuild:true]]; - NSString *nameSlogan = [NSString stringWithFormat:@"%@ - %@", themingName, themingSlogan]; - sectionName = [NSString stringWithFormat:@"\n%@\n\n%@\n%@", versionNextcloudiOS, versionNextcloud, nameSlogan]; - } return sectionName; } diff --git a/iOSClient/Settings/OpenSourceSoftwareViewController.swift b/iOSClient/Settings/OpenSourceSoftwareViewController.swift new file mode 100644 index 0000000000..e4cd131f83 --- /dev/null +++ b/iOSClient/Settings/OpenSourceSoftwareViewController.swift @@ -0,0 +1,56 @@ +// +// OpenSourceSoftwareViewController.swift +// Nextcloud +// +// Created by A200073704 on 11/05/23. +// Copyright © 2023 Marino Faggiana. All rights reserved. +// + +import UIKit +import WebKit + +class OpenSourceSoftwareViewController: UIViewController, WKNavigationDelegate, WKUIDelegate { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + + self.title = NSLocalizedString("_used_opensource_software_", comment: "") + let myWebView:WKWebView = WKWebView(frame: CGRect(x:0, y:0, width: UIScreen.main.bounds.width, height:UIScreen.main.bounds.height)) + myWebView.uiDelegate = self + myWebView.navigationDelegate = self + myWebView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + self.view.addSubview(myWebView) + + + //1. Load web site into my web view + let myURL = URL(string: "https://static.magentacloud.de/licences/ios.html") + let myURLRequest:URLRequest = URLRequest(url: myURL!) + NCActivityIndicator.shared.start() + myWebView.load(myURLRequest) + + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { + NCActivityIndicator.shared.stop() + } + + func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { + if navigationAction.navigationType == .linkActivated { + if let url = navigationAction.request.url, + UIApplication.shared.canOpenURL(url) { + UIApplication.shared.open(url) + decisionHandler(.cancel) + } else { + decisionHandler(.allow) + } + } else { + decisionHandler(.allow) + } + } +}