diff --git a/Brand/Database.swift b/Brand/Database.swift index 04492bd278..3a2f4ed488 100644 --- a/Brand/Database.swift +++ b/Brand/Database.swift @@ -26,4 +26,4 @@ import Foundation // Database Realm // let databaseName = "nextcloud.realm" -let databaseSchemaVersion: UInt64 = 347 +let databaseSchemaVersion: UInt64 = 348 diff --git a/Brand/NCBrand.swift b/Brand/NCBrand.swift index f7b0704c5f..30ff68e0fb 100755 --- a/Brand/NCBrand.swift +++ b/Brand/NCBrand.swift @@ -35,63 +35,63 @@ let userAgent: String = { return instance }() - @objc public var brand: String = "Nextcloud" - @objc public var textCopyrightNextcloudiOS: String = "Nextcloud Hydrogen for iOS %@ © 2024" - @objc public var textCopyrightNextcloudServer: String = "Nextcloud Server %@" - @objc public var loginBaseUrl: String = "https://cloud.nextcloud.com" - @objc public var pushNotificationServerProxy: String = "https://push-notifications.nextcloud.com" - @objc public var linkLoginHost: String = "https://nextcloud.com/install" - @objc public var linkloginPreferredProviders: String = "https://nextcloud.com/signup-ios" - @objc public var webLoginAutenticationProtocol: String = "nc://" // example "abc://" - @objc public var privacy: String = "https://nextcloud.com/privacy" - @objc public var sourceCode: String = "https://github.com/nextcloud/ios" - @objc public var mobileconfig: String = "/remote.php/dav/provisioning/apple-provisioning.mobileconfig" + var brand: String = "Nextcloud" + var textCopyrightNextcloudiOS: String = "Nextcloud Hydrogen for iOS %@ © 2024" + var textCopyrightNextcloudServer: String = "Nextcloud Server %@" + var loginBaseUrl: String = "https://cloud.nextcloud.com" + @objc var pushNotificationServerProxy: String = "https://push-notifications.nextcloud.com" + var linkLoginHost: String = "https://nextcloud.com/install" + var linkloginPreferredProviders: String = "https://nextcloud.com/signup-ios" + var webLoginAutenticationProtocol: String = "nc://" // example "abc://" + var privacy: String = "https://nextcloud.com/privacy" + var sourceCode: String = "https://github.com/nextcloud/ios" + var mobileconfig: String = "/remote.php/dav/provisioning/apple-provisioning.mobileconfig" // Personalized - @objc public var webCloseViewProtocolPersonalized: String = "" // example "abc://change/plan" Don't touch me !! - @objc public var folderBrandAutoUpload: String = "" // example "_auto_upload_folder_" Don't touch me !! + var webCloseViewProtocolPersonalized: String = "" // example "abc://change/plan" Don't touch me !! + var folderBrandAutoUpload: String = "" // example "_auto_upload_folder_" Don't touch me !! // Auto Upload default folder - @objc public var folderDefaultAutoUpload: String = "Photos" + var folderDefaultAutoUpload: String = "Photos" // Capabilities Group - @objc public var capabilitiesGroups: String = "group.it.twsweb.Crypto-Cloud" - @objc public var capabilitiesGroupApps: String = "group.com.nextcloud.apps" + var capabilitiesGroups: String = "group.it.twsweb.Crypto-Cloud" + var capabilitiesGroupApps: String = "group.com.nextcloud.apps" // BRAND ONLY - @objc public var use_login_web_personalized: Bool = false // Don't touch me !! - @objc public var use_AppConfig: Bool = false // Don't touch me !! - @objc public var use_GroupApps: Bool = true // Don't touch me !! + var use_login_web_personalized: Bool = false // Don't touch me !! + var use_AppConfig: Bool = false // Don't touch me !! + var use_GroupApps: Bool = true // Don't touch me !! // Options - @objc public var use_default_auto_upload: Bool = false - @objc public var use_themingColor: Bool = true - @objc public var use_themingLogo: Bool = false - @objc public var use_storeLocalAutoUploadAll: Bool = false - @objc public var use_loginflowv2: Bool = false // Don't touch me !! - - @objc public var disable_intro: Bool = false - @objc public var disable_request_login_url: Bool = false - @objc public var disable_multiaccount: Bool = false - @objc public var disable_manage_account: Bool = false - @objc public var disable_more_external_site: Bool = false - @objc public var disable_openin_file: Bool = false // Don't touch me !! - @objc public var disable_crash_service: Bool = false - @objc public var disable_log: Bool = false - @objc public var disable_mobileconfig: Bool = false - @objc public var disable_show_more_nextcloud_apps_in_settings: Bool = false - @objc public var doNotAskPasscodeAtStartup: Bool = false + var use_default_auto_upload: Bool = false + var use_themingColor: Bool = true + var use_themingLogo: Bool = false + var use_storeLocalAutoUploadAll: Bool = false + var use_loginflowv2: Bool = false // Don't touch me !! + + var disable_intro: Bool = false + var disable_request_login_url: Bool = false + var disable_multiaccount: Bool = false + var disable_manage_account: Bool = false + var disable_more_external_site: Bool = false + var disable_openin_file: Bool = false // Don't touch me !! + var disable_crash_service: Bool = false + var disable_log: Bool = false + var disable_mobileconfig: Bool = false + var disable_show_more_nextcloud_apps_in_settings: Bool = false + var doNotAskPasscodeAtStartup: Bool = false // Internal option behaviour - @objc public var cleanUpDay: Int = 0 // Set default "Delete, in the cache, all files older than" possible days value are: 0, 1, 7, 30, 90, 180, 365 + var cleanUpDay: Int = 0 // Set default "Delete, in the cache, all files older than" possible days value are: 0, 1, 7, 30, 90, 180, 365 // Max download/upload concurrent - public let maxConcurrentOperationDownload: Int = 5 - public let maxConcurrentOperationUpload: Int = 5 + let maxConcurrentOperationDownload: Int = 5 + let maxConcurrentOperationUpload: Int = 5 // Number of failed attempts after reset app - @objc public let resetAppPasscodeAttempts: Int = 10 - public let passcodeSecondsFail: Int = 60 + let resetAppPasscodeAttempts: Int = 10 + let passcodeSecondsFail: Int = 60 // Info Paging enum NCInfoPagingTab: Int, CaseIterable { @@ -140,53 +140,53 @@ let userAgent: String = { } class NCBrandColor: NSObject { - @objc static let shared: NCBrandColor = { + static let shared: NCBrandColor = { let instance = NCBrandColor() return instance }() // Color - @objc public let customer: UIColor = UIColor(red: 0.0 / 255.0, green: 130.0 / 255.0, blue: 201.0 / 255.0, alpha: 1.0) // BLU NC : #0082c9 - @objc public var customerText: UIColor = .white + let customer: UIColor = UIColor(red: 0.0 / 255.0, green: 130.0 / 255.0, blue: 201.0 / 255.0, alpha: 1.0) // BLU NC : #0082c9 + var customerText: UIColor = .white - @objc private var brand: UIColor // don't touch me - @objc public var brandElement: UIColor // don't touch me - @objc public var brandText: UIColor // don't touch me + var brand: UIColor // don't touch me + var brandElement: UIColor // don't touch me + var brandText: UIColor // don't touch me - @objc public let nextcloud: UIColor = UIColor(red: 0.0 / 255.0, green: 130.0 / 255.0, blue: 201.0 / 255.0, alpha: 1.0) - @objc public let yellowFavorite: UIColor = UIColor(red: 248.0 / 255.0, green: 205.0 / 255.0, blue: 70.0 / 255.0, alpha: 1.0) + let nextcloud: UIColor = UIColor(red: 0.0 / 255.0, green: 130.0 / 255.0, blue: 201.0 / 255.0, alpha: 1.0) + let yellowFavorite: UIColor = UIColor(red: 248.0 / 255.0, green: 205.0 / 255.0, blue: 70.0 / 255.0, alpha: 1.0) - public var userColors: [CGColor] = [] - public var themingColor: String = "" - public var themingColorElement: String = "" - public var themingColorText: String = "" + var userColors: [CGColor] = [] + var themingColor: String = "" + var themingColorElement: String = "" + var themingColorText: String = "" - @objc public let iconImageColor: UIColor = .label - @objc public let iconImageColor2: UIColor = .secondaryLabel - @objc public let iconImageMultiColors: [UIColor] = [.secondaryLabel, .label] + let iconImageColor: UIColor = .label + let iconImageColor2: UIColor = .secondaryLabel + let iconImageMultiColors: [UIColor] = [.secondaryLabel, .label] - @objc public let textColor: UIColor = .label - @objc public let textColor2: UIColor = .secondaryLabel + let textColor: UIColor = .label + let textColor2: UIColor = .secondaryLabel - @objc public var systemMint: UIColor { + var systemMint: UIColor { get { return UIColor(red: 0.0 / 255.0, green: 199.0 / 255.0, blue: 190.0 / 255.0, alpha: 1.0) } } - @objc public var documentIconColor: UIColor { + var documentIconColor: UIColor { get { return UIColor(hex: "#49abe9")! } } - @objc public var spreadsheetIconColor: UIColor { + var spreadsheetIconColor: UIColor { get { return UIColor(hex: "#9abd4e")! } } - @objc public var presentationIconColor: UIColor { + var presentationIconColor: UIColor { get { return UIColor(hex: "#f0965f")! } @@ -203,12 +203,10 @@ class NCBrandColor: NSObject { } func settingThemingColor(account: String) { - let darker: CGFloat = 30 // % let lighter: CGFloat = 30 // % if NCBrandOptions.shared.use_themingColor { - self.themingColor = NCGlobal.shared.capabilityThemingColor self.themingColorElement = NCGlobal.shared.capabilityThemingColorElement self.themingColorText = NCGlobal.shared.capabilityThemingColorText diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index 0335f2c98c..0b5893c632 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -81,7 +81,6 @@ F3391B102B4C52E6001C0C4B /* SVGKit in Frameworks */ = {isa = PBXBuildFile; productRef = F3391B0F2B4C52E6001C0C4B /* SVGKit */; }; F3391B142B4C52EF001C0C4B /* JGProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = F3391B132B4C52EF001C0C4B /* JGProgressHUD */; }; F3391B162B4C52F6001C0C4B /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = F3391B152B4C52F6001C0C4B /* FirebaseDatabase */; }; - F33AAF9A2A60394C006ECCBD /* NCMoreUserCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F33AAF992A60394C006ECCBD /* NCMoreUserCell.xib */; }; F343A4B32A1E01FF00DDA874 /* PHAsset+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F343A4B22A1E01FF00DDA874 /* PHAsset+Extension.swift */; }; F343A4B42A1E084100DDA874 /* PHAsset+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F343A4B22A1E01FF00DDA874 /* PHAsset+Extension.swift */; }; F343A4B52A1E084200DDA874 /* PHAsset+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F343A4B22A1E01FF00DDA874 /* PHAsset+Extension.swift */; }; @@ -145,7 +144,6 @@ F3A0479E2BD268B500658E7B /* PopupView in Frameworks */ = {isa = PBXBuildFile; productRef = F3A0479D2BD268B500658E7B /* PopupView */; }; F3A7AFC62A41AA82001FC89C /* BaseUIXCTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3A7AFC52A41AA82001FC89C /* BaseUIXCTestCase.swift */; }; F3BB464D2A39ADCC00461F6E /* NCMoreAppSuggestionsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F3BB464C2A39ADCC00461F6E /* NCMoreAppSuggestionsCell.xib */; }; - F3BB464F2A39EBE500461F6E /* NCMoreUserCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3BB464E2A39EBE500461F6E /* NCMoreUserCell.swift */; }; F3BB46522A39EC4900461F6E /* NCMoreAppSuggestionsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3BB46512A39EC4900461F6E /* NCMoreAppSuggestionsCell.swift */; }; F3BB46542A3A1E9D00461F6E /* CCCellMore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3BB46532A3A1E9D00461F6E /* CCCellMore.swift */; }; F3F0419B2B9F7E6700D5155F /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = F3F0419A2B9F7E6700D5155F /* RealmSwift */; }; @@ -554,7 +552,6 @@ F768823C2C0DD231001CF441 /* NCKeychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76882132C0DD1E7001CF441 /* NCKeychain.swift */; }; F768823E2C0DD305001CF441 /* LazyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F768823D2C0DD304001CF441 /* LazyView.swift */; }; F76882402C0DD30B001CF441 /* ViewOnAppear.swift in Sources */ = {isa = PBXBuildFile; fileRef = F768823F2C0DD30B001CF441 /* ViewOnAppear.swift */; }; - F76882432C0DD3B4001CF441 /* CCManageAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = F76882422C0DD3B4001CF441 /* CCManageAccount.m */; }; F769453C22E9CFFF000A798A /* NCShareUserCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F769453B22E9CFFF000A798A /* NCShareUserCell.xib */; }; F769454022E9F077000A798A /* NCSharePaging.swift in Sources */ = {isa = PBXBuildFile; fileRef = F769453F22E9F077000A798A /* NCSharePaging.swift */; }; F769454622E9F1B0000A798A /* NCShareCommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = F769454522E9F1B0000A798A /* NCShareCommon.swift */; }; @@ -746,6 +743,8 @@ F7AE00F5230D5F9E007ACF8A /* NCLoginWeb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7AE00F4230D5F9E007ACF8A /* NCLoginWeb.swift */; }; F7AE00F8230E81CB007ACF8A /* NCBrowserWeb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7AE00F7230E81CB007ACF8A /* NCBrowserWeb.swift */; }; F7AE00FA230E81EB007ACF8A /* NCBrowserWeb.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7AE00F9230E81EB007ACF8A /* NCBrowserWeb.storyboard */; }; + F7AEEAA62C11DBAF00011412 /* NCAccountSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7AEEAA52C11DBAF00011412 /* NCAccountSettingsView.swift */; }; + F7AEEAA82C11DBFD00011412 /* NCAccountSettingsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7AEEAA72C11DBFD00011412 /* NCAccountSettingsModel.swift */; }; F7B398422A6A91D5007538D6 /* NCSectionHeaderMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7B398412A6A91D5007538D6 /* NCSectionHeaderMenu.xib */; }; F7B398432A6A91D5007538D6 /* NCSectionHeaderMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7B398412A6A91D5007538D6 /* NCSectionHeaderMenu.xib */; }; F7B6B70427C4E7FA00A7F6EB /* NCScan+CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B6B70327C4E7FA00A7F6EB /* NCScan+CollectionView.swift */; }; @@ -1114,7 +1113,6 @@ F3131ED82B038DB20018DB28 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/iOSSupport/System/Library/Frameworks/SwiftUI.framework; sourceTree = DEVELOPER_DIR; }; F3131EDA2B038DB90018DB28 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/iOSSupport/System/Library/Frameworks/WidgetKit.framework; sourceTree = DEVELOPER_DIR; }; F321DA892B71205A00DDA0E6 /* NCTrashSelectTabBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCTrashSelectTabBar.swift; sourceTree = ""; }; - F33AAF992A60394C006ECCBD /* NCMoreUserCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NCMoreUserCell.xib; sourceTree = ""; }; F343A4B22A1E01FF00DDA874 /* PHAsset+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PHAsset+Extension.swift"; sourceTree = ""; }; F343A4BA2A1E734600DDA874 /* Optional+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Optional+Extension.swift"; sourceTree = ""; }; F359D8662A7D03420023F405 /* NCUtility+Exif.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCUtility+Exif.swift"; sourceTree = ""; }; @@ -1134,7 +1132,6 @@ F3A047962BD2668800658E7B /* NCAssistant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCAssistant.swift; sourceTree = ""; }; F3A7AFC52A41AA82001FC89C /* BaseUIXCTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseUIXCTestCase.swift; sourceTree = ""; }; F3BB464C2A39ADCC00461F6E /* NCMoreAppSuggestionsCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCMoreAppSuggestionsCell.xib; sourceTree = ""; }; - F3BB464E2A39EBE500461F6E /* NCMoreUserCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMoreUserCell.swift; sourceTree = ""; }; F3BB46512A39EC4900461F6E /* NCMoreAppSuggestionsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMoreAppSuggestionsCell.swift; sourceTree = ""; }; F3BB46532A3A1E9D00461F6E /* CCCellMore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCCellMore.swift; sourceTree = ""; }; F700222B1EC479840080073F /* Custom.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Custom.xcassets; sourceTree = ""; }; @@ -1380,8 +1377,6 @@ F76882212C0DD1E7001CF441 /* NCAcknowledgementsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCAcknowledgementsView.swift; sourceTree = ""; }; F768823D2C0DD304001CF441 /* LazyView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LazyView.swift; sourceTree = ""; }; F768823F2C0DD30B001CF441 /* ViewOnAppear.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewOnAppear.swift; sourceTree = ""; }; - F76882412C0DD3B4001CF441 /* CCManageAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCManageAccount.h; sourceTree = ""; }; - F76882422C0DD3B4001CF441 /* CCManageAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCManageAccount.m; sourceTree = ""; }; F769453B22E9CFFF000A798A /* NCShareUserCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NCShareUserCell.xib; sourceTree = ""; }; F769453F22E9F077000A798A /* NCSharePaging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCSharePaging.swift; sourceTree = ""; }; F769454522E9F1B0000A798A /* NCShareCommon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareCommon.swift; sourceTree = ""; }; @@ -1538,6 +1533,8 @@ F7AE00F4230D5F9E007ACF8A /* NCLoginWeb.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCLoginWeb.swift; sourceTree = ""; }; F7AE00F7230E81CB007ACF8A /* NCBrowserWeb.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCBrowserWeb.swift; sourceTree = ""; }; F7AE00F9230E81EB007ACF8A /* NCBrowserWeb.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCBrowserWeb.storyboard; sourceTree = ""; }; + F7AEEAA52C11DBAF00011412 /* NCAccountSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCAccountSettingsView.swift; sourceTree = ""; }; + F7AEEAA72C11DBFD00011412 /* NCAccountSettingsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCAccountSettingsModel.swift; sourceTree = ""; }; F7AF7632246BEDFE00B86E3C /* TOPasscodeViewController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TOPasscodeViewController.framework; path = Carthage/Build/iOS/TOPasscodeViewController.framework; sourceTree = ""; }; F7B1076C25D3CF2800E72DE2 /* BackgroundTasks.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BackgroundTasks.framework; path = System/Library/Frameworks/BackgroundTasks.framework; sourceTree = SDKROOT; }; F7B1A7761EBB3C8000BFB6D1 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = ""; }; @@ -2003,8 +2000,6 @@ children = ( F3BB464C2A39ADCC00461F6E /* NCMoreAppSuggestionsCell.xib */, F3BB46512A39EC4900461F6E /* NCMoreAppSuggestionsCell.swift */, - F33AAF992A60394C006ECCBD /* NCMoreUserCell.xib */, - F3BB464E2A39EBE500461F6E /* NCMoreUserCell.swift */, F3BB46532A3A1E9D00461F6E /* CCCellMore.swift */, F39298962A3B12CB00509762 /* BaseNCMoreCell.swift */, ); @@ -2625,6 +2620,15 @@ path = BrowserWeb; sourceTree = ""; }; + F7AEEAA92C11DC0600011412 /* Account Settings */ = { + isa = PBXGroup; + children = ( + F7AEEAA52C11DBAF00011412 /* NCAccountSettingsView.swift */, + F7AEEAA72C11DBFD00011412 /* NCAccountSettingsModel.swift */, + ); + path = "Account Settings"; + sourceTree = ""; + }; F7BAAD951ED5A63D00B7EAD4 /* Data */ = { isa = PBXGroup; children = ( @@ -2786,8 +2790,6 @@ F3BB46502A39EC2D00461F6E /* Cells */, F7CB68992541676B0050EC94 /* NCMore.storyboard */, F73F537E1E929C8500F8678D /* NCMore.swift */, - F76882412C0DD3B4001CF441 /* CCManageAccount.h */, - F76882422C0DD3B4001CF441 /* CCManageAccount.m */, ); path = More; sourceTree = ""; @@ -2908,6 +2910,7 @@ F769CA1B2966EF4F00039397 /* GUI */, F70211F31BAC56E9003FC03E /* Main */, F7CA213725F1372B00826ABB /* Account Request */, + F7AEEAA92C11DC0600011412 /* Account Settings */, F7A321621E9E37960069AD1B /* Activity */, F76687042B7D067400779E3F /* AudioRecorder */, F3A0478E2BD2668800658E7B /* Assistant */, @@ -3667,7 +3670,6 @@ F723985C253C95CE00257F49 /* NCViewerRichdocument.storyboard in Resources */, F758B45A212C564000515F55 /* NCScan.storyboard in Resources */, F70D87CF25EE6E58008CBBBD /* NCRenameFile.storyboard in Resources */, - F33AAF9A2A60394C006ECCBD /* NCMoreUserCell.xib in Resources */, F765F73225237E3F00391DBE /* NCRecent.storyboard in Resources */, F78F74342163757000C2ADAD /* NCTrash.storyboard in Resources */, F702F30225EE5D2C008F8E80 /* english.txt in Resources */, @@ -4303,7 +4305,6 @@ F70BFC7420E0FA7D00C67599 /* NCUtility.swift in Sources */, F79EDAA526B004980007D134 /* NCPlayer.swift in Sources */, F7C1EEA525053A9C00866ACC /* NCDataSource.swift in Sources */, - F76882432C0DD3B4001CF441 /* CCManageAccount.m in Sources */, F713FF002472764100214AF6 /* UIImage+animatedGIF.m in Sources */, AFCE353527E4ED5900FEA6C2 /* DateFormatter+Extension.swift in Sources */, F718C24E254D507B00C5C256 /* NCViewerMediaDetailView.swift in Sources */, @@ -4325,6 +4326,7 @@ F769CA192966EA3C00039397 /* ComponentView.swift in Sources */, F7C9B91D2B582F550064EA91 /* NCManageDatabase+SecurityGuard.swift in Sources */, AF93474C27E34120002537EE /* NCUtility+Image.swift in Sources */, + F7AEEAA62C11DBAF00011412 /* NCAccountSettingsView.swift in Sources */, F702F30125EE5D2C008F8E80 /* NYMnemonic.m in Sources */, AF93474E27E3F212002537EE /* NCShareNewUserAddComment.swift in Sources */, F7C30DFD291BD0B80017149B /* NCNetworkingE2EEDelete.swift in Sources */, @@ -4346,7 +4348,6 @@ F7134186259747BA00768D21 /* NCPushNotification.m in Sources */, F76882322C0DD1E7001CF441 /* NCAutoUploadView.swift in Sources */, F36E64F72B9245210085ABB5 /* NCCollectionViewCommon+SelectTabBarDelegate.swift in Sources */, - F3BB464F2A39EBE500461F6E /* NCMoreUserCell.swift in Sources */, F79A65C62191D95E00FF6DCC /* NCSelect.swift in Sources */, F75D19E325EFE09000D74598 /* NCTrash+Menu.swift in Sources */, F70CAE3A1F8CF31A008125FD /* NCEndToEndEncryption.m in Sources */, @@ -4375,6 +4376,7 @@ D5B6AA7827200C7200D49C24 /* NCActivityTableViewCell.swift in Sources */, F745B253222D88AE00346520 /* NCLoginQRCode.swift in Sources */, F769454822E9F20D000A798A /* NCShareNetworking.swift in Sources */, + F7AEEAA82C11DBFD00011412 /* NCAccountSettingsModel.swift in Sources */, F749B64A297B0CBB00087535 /* NCManageDatabase+Share.swift in Sources */, F7C9555521F0C5470024296E /* NCActivity.swift in Sources */, F7725A60251F33BB00D125E0 /* NCFiles.swift in Sources */, @@ -5696,8 +5698,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/nextcloud/NextcloudKit"; requirement = { - kind = exactVersion; - version = 3.0.1; + branch = develop; + kind = branch; }; }; F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = { diff --git a/Widget/Files/FilesData.swift b/Widget/Files/FilesData.swift index 0d49dd3272..19180076ff 100644 --- a/Widget/Files/FilesData.swift +++ b/Widget/Files/FilesData.swift @@ -219,11 +219,11 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi if let result = utility.createFilePreviewImage(ocId: file.ocId, etag: file.etag, fileNameView: file.fileName, classFile: file.classFile, status: 0, createPreviewMedia: false) { image = result } else if file.hasPreview { - let fileNamePathOrFileId = utilityFileSystem.getFileNamePath(file.fileName, serverUrl: file.serverUrl, urlBase: file.urlBase, userId: file.userId) + let fileNamePreviewLocalPath = utilityFileSystem.getDirectoryProviderStoragePreviewOcId(file.ocId, etag: file.etag) let fileNameIconLocalPath = utilityFileSystem.getDirectoryProviderStorageIconOcId(file.ocId, etag: file.etag) let sizePreview = NCUtility().getSizePreview(width: Int(file.width), height: Int(file.height)) - let (_, _, imageIcon, _, _, _) = await NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePathOrFileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, widthPreview: Int(sizePreview.width), heightPreview: Int(sizePreview.height), fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon, options: options) + let (_, _, imageIcon, _, _, _) = await NextcloudKit.shared.downloadPreview(fileId: file.fileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, fileNameIconLocalPath: fileNameIconLocalPath, widthPreview: Int(sizePreview.width), heightPreview: Int(sizePreview.height), sizeIcon: NCGlobal.shared.sizeIcon, options: options) if let result = imageIcon { image = result } diff --git a/iOSClient/Account Settings/NCAccountSettingsModel.swift b/iOSClient/Account Settings/NCAccountSettingsModel.swift new file mode 100644 index 0000000000..f384745b32 --- /dev/null +++ b/iOSClient/Account Settings/NCAccountSettingsModel.swift @@ -0,0 +1,182 @@ +// +// NCAccountSettingsModel.swift +// Nextcloud +// +// Created by Marino Faggiana on 06/06/24. +// Copyright © 2024 Marino Faggiana. All rights reserved. +// +// Author Marino Faggiana +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +import Foundation +import UIKit +import RealmSwift + +/// Protocol for know when the Account Settings has dimissed +protocol NCAccountSettingsModelDelegate: AnyObject { + func accountSettingsDidDismiss(tableAccount: tableAccount?) +} + +/// A model that allows the user to configure the account +class NCAccountSettingsModel: ObservableObject, ViewOnAppearHandling { + /// AppDelegate + let appDelegate = (UIApplication.shared.delegate as? AppDelegate)! + /// Root View Controller + var controller: NCMainTabBarController? + /// All account + var accounts: [tableAccount] = [] + /// Delegate + weak var delegate: NCAccountSettingsModelDelegate? + /// Timer change user + var timerChangeAccount: Timer? + /// Account now active + @Published var activeAccount: tableAccount? + /// Index + @Published var indexActiveAccount: Int = 0 + /// Current alias + @Published var alias: String = "" + /// State to control + @Published var accountRequest: Bool = false + /// Set true for dismiss the view + @Published var dismissView = false + /// Token observe tableAccount + private var notificationToken: NotificationToken? + + /// Initialization code to set up the ViewModel with the active account + init(controller: NCMainTabBarController?, delegate: NCAccountSettingsModelDelegate?) { + self.controller = controller + self.delegate = delegate + if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" { + NCManageDatabase.shared.previewCreateDB() + } + onViewAppear() + observeTableAccount() + } + + deinit { + timerChangeAccount?.invalidate() + timerChangeAccount = nil + notificationToken?.invalidate() + notificationToken = nil + } + + /// Reload the view when change the tableAccount + func observeTableAccount() { + do { + let realm = try Realm() + let results = realm.objects(tableAccount.self) + notificationToken = results.observe { [weak self] (changes: RealmCollectionChange) in + switch changes { + case .initial: + break + case .update: + DispatchQueue.main.async { + self?.objectWillChange.send() + } + case .error: + break + } + } + } catch let error as NSError { + NSLog("Could not access database: ", error) + } + } + + /// Triggered when the view appears. + func onViewAppear() { + accounts = NCManageDatabase.shared.getAllAccount() + accountRequest = NCKeychain().accountRequest + getIndexActiveAccount() + } + + /// Internal use + func getIndexActiveAccount() { + self.indexActiveAccount = 0 + for (index, account) in accounts.enumerated() { + if account.active { + self.activeAccount = account + self.indexActiveAccount = index + self.alias = account.alias + } + } + } + + /// Func to get the user display name + alias + func getUserName() -> String { + guard let activeAccount else { return "" } + NCManageDatabase.shared.setAccountAlias(activeAccount.account, alias: alias) + if alias.isEmpty { + return activeAccount.displayName + } else { + return activeAccount.displayName + " (\(alias))" + } + } + + /// Function to update the user data + func getUserStatus() -> (statusImage: UIImage, statusMessage: String, descriptionMessage: String) { + guard let activeAccount else { return (UIImage(), "", "") } + if NCGlobal.shared.capabilityUserStatusEnabled, + let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", activeAccount.account)) { + return NCUtility().getUserStatus(userIcon: tableAccount.userStatusIcon, userStatus: tableAccount.userStatusStatus, userMessage: tableAccount.userStatusMessage) + } + return (UIImage(), "", "") + } + + /// Function to know the height of "account" data + func getTableViewHeight() -> CGFloat { + guard let activeAccount else { return 0 } + var height: CGFloat = 190 + if NCGlobal.shared.capabilityUserStatusEnabled, + let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", activeAccount.account)) { + if !tableAccount.email.isEmpty { height += 30 } + if !tableAccount.phone.isEmpty { height += 30 } + if !tableAccount.address.isEmpty { height += 30 } + } + if height == 190 { return 170 } + return height + } + + /// Function to change account + func setAccount(account: String) { + if let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)), self.activeAccount?.account != tableAccount.account { + self.activeAccount = tableAccount + self.alias = tableAccount.alias + /// Change active account + timerChangeAccount?.invalidate() + timerChangeAccount = Timer.scheduledTimer(timeInterval: 1.5, target: self, selector: #selector(changeAccount), userInfo: nil, repeats: false) + + } + } + + @objc func changeAccount() { + if let activeAccount { + self.appDelegate.changeAccount(activeAccount.account, userProfile: nil) + } + } + + /// Function to delete the current account + func deleteAccount() { + if let activeAccount { + appDelegate.deleteAccount(activeAccount.account, wipe: false) + if let account = NCManageDatabase.shared.getAllAccount().first?.account { + appDelegate.changeAccount(account, userProfile: nil) + } else { + dismissView = true + } + onViewAppear() + } + } +} diff --git a/iOSClient/Account Settings/NCAccountSettingsView.swift b/iOSClient/Account Settings/NCAccountSettingsView.swift new file mode 100644 index 0000000000..ff3ed39d73 --- /dev/null +++ b/iOSClient/Account Settings/NCAccountSettingsView.swift @@ -0,0 +1,277 @@ +// +// NCAccountSettingsView.swift +// Nextcloud +// +// Created by Marino Faggiana on 06/06/24. +// Copyright © 2024 Marino Faggiana. All rights reserved. +// +// Author Marino Faggiana +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +import SwiftUI + +struct NCAccountSettingsView: View { + @ObservedObject var model: NCAccountSettingsModel + + @State private var isExpanded: Bool = false + @State private var showUserStatus = false + @State private var showServerCertificate = false + @State private var showPushCertificate = false + @State private var showDeleteAccountAlert: Bool = false + @State private var showAddAccount: Bool = false + + @Environment(\.presentationMode) var presentationMode + + var body: some View { + Form { + Section(content: { + TabView(selection: $model.indexActiveAccount) { + ForEach(0.. Void)? @@ -340,7 +340,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD // MARK: - Login - @objc func openLogin(selector: Int, openLoginWeb: Bool, windowForRootViewController: UIWindow? = nil) { + func openLogin(selector: Int, openLoginWeb: Bool, windowForRootViewController: UIWindow? = nil) { func showLoginViewController(_ viewController: UIViewController?) { guard let viewController else { return } let navigationController = NCLoginNavigationController(rootViewController: viewController) @@ -408,7 +408,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD // MARK: - Error Networking - @objc func startTimerErrorNetworking(scene: UIScene) { + func startTimerErrorNetworking(scene: UIScene) { timerErrorNetworkingDisabled = false timerErrorNetworking = Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(checkErrorNetworking(_:)), userInfo: nil, repeats: true) } @@ -457,7 +457,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD // MARK: - Account - @objc func changeAccount(_ account: String, userProfile: NKUserProfile?) { + func changeAccount(_ account: String, userProfile: NKUserProfile?) { NCNetworking.shared.cancelAllQueue() NCNetworking.shared.cancelDataTask() @@ -500,7 +500,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeUser) } - @objc func deleteAccount(_ account: String, wipe: Bool) { + func deleteAccount(_ account: String, wipe: Bool) { UIApplication.shared.allSceneSessionDestructionExceptFirst() @@ -566,7 +566,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD // MARK: - Reset Application - @objc func resetApplication() { + func resetApplication() { let utilityFileSystem = NCUtilityFileSystem() diff --git a/iOSClient/AudioRecorder/NCAudioRecorderViewController.swift b/iOSClient/AudioRecorder/NCAudioRecorderViewController.swift index fb9803f8c0..6ae7328808 100644 --- a/iOSClient/AudioRecorder/NCAudioRecorderViewController.swift +++ b/iOSClient/AudioRecorder/NCAudioRecorderViewController.swift @@ -138,8 +138,7 @@ class NCAudioRecorderViewController: UIViewController, NCAudioRecorderDelegate { } open class NCAudioRecorder: NSObject { - - @objc public enum State: Int { + public enum State: Int { case none, record, play } diff --git a/iOSClient/BrowserWeb/NCBrowserWeb.swift b/iOSClient/BrowserWeb/NCBrowserWeb.swift index bc351f602e..fc45fdee5b 100644 --- a/iOSClient/BrowserWeb/NCBrowserWeb.swift +++ b/iOSClient/BrowserWeb/NCBrowserWeb.swift @@ -30,10 +30,10 @@ import WebKit class NCBrowserWeb: UIViewController { - @objc var urlBase = "" - @objc var isHiddenButtonExit = false - @objc var titleBrowser: String? - @objc weak var delegate: NCBrowserWebDelegate? + var urlBase = "" + var isHiddenButtonExit = false + var titleBrowser: String? + weak var delegate: NCBrowserWebDelegate? @IBOutlet weak var buttonExit: UIButton! diff --git a/iOSClient/Data/NCManageDatabase+Account.swift b/iOSClient/Data/NCManageDatabase+Account.swift index f365de359a..1cd4b0c36d 100644 --- a/iOSClient/Data/NCManageDatabase+Account.swift +++ b/iOSClient/Data/NCManageDatabase+Account.swift @@ -26,7 +26,6 @@ import RealmSwift import NextcloudKit class tableAccount: Object, NCUserBaseUrl { - @objc dynamic var account = "" @objc dynamic var active: Bool = false @objc dynamic var address = "" @@ -44,10 +43,6 @@ class tableAccount: Object, NCUserBaseUrl { @objc dynamic var backend = "" @objc dynamic var backendCapabilitiesSetDisplayName: Bool = false @objc dynamic var backendCapabilitiesSetPassword: Bool = false - @objc dynamic var businessSize: String = "" - @objc dynamic var businessType = "" - @objc dynamic var city = "" - @objc dynamic var country = "" @objc dynamic var displayName = "" @objc dynamic var email = "" @objc dynamic var enabled: Bool = false @@ -64,7 +59,6 @@ class tableAccount: Object, NCUserBaseUrl { @objc dynamic var quotaRelative: Double = 0 @objc dynamic var quotaTotal: Int64 = 0 @objc dynamic var quotaUsed: Int64 = 0 - @objc dynamic var role = "" @objc dynamic var storageLocation = "" @objc dynamic var subadmin = "" @objc dynamic var twitter = "" @@ -79,7 +73,6 @@ class tableAccount: Object, NCUserBaseUrl { @objc dynamic var userStatusStatus: String? @objc dynamic var userStatusStatusIsUserDefined: Bool = false @objc dynamic var website = "" - @objc dynamic var zip = "" override static func primaryKey() -> String { return "account" @@ -453,19 +446,14 @@ extension NCManageDatabase { } } - @objc func setAccountAlias(_ alias: String?) { - - let alias = alias?.trimmingCharacters(in: .whitespacesAndNewlines) + @objc func setAccountAlias(_ account: String, alias: String) { + let alias = alias.trimmingCharacters(in: .whitespacesAndNewlines) do { let realm = try Realm() try realm.write { - if let result = realm.objects(tableAccount.self).filter("active == true").first { - if let alias = alias { - result.alias = alias - } else { - result.alias = "" - } + if let result = realm.objects(tableAccount.self).filter("account == %@", account).first { + result.alias = alias } } } catch let error { diff --git a/iOSClient/Data/NCManageDatabase.swift b/iOSClient/Data/NCManageDatabase.swift index 1d7873053a..cd01e706f3 100644 --- a/iOSClient/Data/NCManageDatabase.swift +++ b/iOSClient/Data/NCManageDatabase.swift @@ -186,8 +186,7 @@ class NCManageDatabase: NSObject { // MARK: - // MARK: Utility Database - @objc func clearTable(_ table: Object.Type, account: String? = nil) { - + func clearTable(_ table: Object.Type, account: String? = nil) { do { let realm = try Realm() try realm.write { @@ -206,8 +205,7 @@ class NCManageDatabase: NSObject { } } - @objc func clearDatabase(account: String?, removeAccount: Bool) { - + func clearDatabase(account: String?, removeAccount: Bool) { if removeAccount { self.clearTable(tableAccount.self, account: account) } @@ -287,4 +285,25 @@ class NCManageDatabase: NSObject { return nil } + + // MARK: - + // MARK: SWIFTUI PREVIEW + + func previewCreateDB() { + /// Account + let account = "marinofaggiana https://cloudtest.nextcloud.com" + let account2 = "mariorossi https://cloudtest.nextcloud.com" + NCManageDatabase.shared.addAccount(account, urlBase: "https://cloudtest.nextcloud.com", user: "marinofaggiana", userId: "marinofaggiana", password: "password") + NCManageDatabase.shared.addAccount(account2, urlBase: "https://cloudtest.nextcloud.com", user: "mariorossi", userId: "mariorossi", password: "password") + let userProfile = NKUserProfile() + userProfile.displayName = "Marino Faggiana" + userProfile.address = "Hirschstrasse 26, 70192 Stuttgart, Germany" + userProfile.phone = "+49 (711) 252 428 - 90" + userProfile.email = "cloudtest@nextcloud.com" + NCManageDatabase.shared.setAccountUserProfile(account: account, userProfile: userProfile) + let userProfile2 = NKUserProfile() + userProfile2.displayName = "Mario Rossi" + userProfile2.email = "cloudtest@nextcloud.com" + NCManageDatabase.shared.setAccountUserProfile(account: account2, userProfile: userProfile2) + } } diff --git a/iOSClient/Files/NCFiles.swift b/iOSClient/Files/NCFiles.swift index 70ff01d645..191beb7f64 100644 --- a/iOSClient/Files/NCFiles.swift +++ b/iOSClient/Files/NCFiles.swift @@ -290,4 +290,17 @@ class NCFiles: NCCollectionViewCommon { } } } + + // MARK: - NCAccountSettingsModelDelegate + + override func accountSettingsDidDismiss(tableAccount: tableAccount?) { + if NCManageDatabase.shared.getAllAccount().isEmpty { + appDelegate.openLogin(selector: NCGlobal.shared.introLogin, openLoginWeb: false) + } else if let account = tableAccount?.account, account != appDelegate.account { + appDelegate.changeAccount(account, userProfile: nil) + } else if isRoot { + titleCurrentFolder = getNavigationTitle() + navigationItem.title = titleCurrentFolder + } + } } diff --git a/iOSClient/Images.xcassets/circle_fill.imageset/Contents.json b/iOSClient/Images.xcassets/circle_fill.imageset/Contents.json index b73baca819..09a262759f 100644 --- a/iOSClient/Images.xcassets/circle_fill.imageset/Contents.json +++ b/iOSClient/Images.xcassets/circle_fill.imageset/Contents.json @@ -1,15 +1,15 @@ { "images" : [ { - "idiom" : "universal", - "filename" : "circle.pdf" + "filename" : "circle_fill.pdf", + "idiom" : "universal" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 }, "properties" : { "preserves-vector-representation" : true } -} \ No newline at end of file +} diff --git a/iOSClient/Images.xcassets/circle_fill.imageset/circle.pdf b/iOSClient/Images.xcassets/circle_fill.imageset/circle.pdf deleted file mode 100644 index 4be68b831d..0000000000 Binary files a/iOSClient/Images.xcassets/circle_fill.imageset/circle.pdf and /dev/null differ diff --git a/iOSClient/Images.xcassets/circle_fill.imageset/circle_fill.pdf b/iOSClient/Images.xcassets/circle_fill.imageset/circle_fill.pdf new file mode 100644 index 0000000000..df94f96d6b Binary files /dev/null and b/iOSClient/Images.xcassets/circle_fill.imageset/circle_fill.pdf differ diff --git a/iOSClient/Login/NCViewCertificateDetails.swift b/iOSClient/Login/NCViewCertificateDetails.swift index d08a7a2a0e..25b673a92b 100644 --- a/iOSClient/Login/NCViewCertificateDetails.swift +++ b/iOSClient/Login/NCViewCertificateDetails.swift @@ -41,9 +41,10 @@ class NCViewCertificateDetails: UIViewController { var delegate: NCViewCertificateDetailsDelegate? let utilityFileSystem = NCUtilityFileSystem() - @objc public var host: String = "" + + public var host: String = "" public var fileNamePath: String = "" - @objc public var certificateTitle = NSLocalizedString("_certificate_view_", comment: "") + public var certificateTitle = NSLocalizedString("_certificate_view_", comment: "") // MARK: - View Life Cycle @@ -105,11 +106,11 @@ class NCViewCertificateDetails: UIViewController { // MARK: - UIViewControllerRepresentable -struct NCViewCertificateDetailsRepresentable: UIViewControllerRepresentable { +struct certificateDetailsView: UIViewControllerRepresentable { typealias UIViewControllerType = UINavigationController - var fileNamePath: String - var title: String + var host: String = "" + var title: String = "" func makeUIViewController(context: Context) -> UINavigationController { @@ -117,7 +118,7 @@ struct NCViewCertificateDetailsRepresentable: UIViewControllerRepresentable { let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController let viewController = navigationController?.topViewController as? NCViewCertificateDetails - viewController?.fileNamePath = fileNamePath + viewController?.host = host viewController?.certificateTitle = title return navigationController! diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 7dbb415db7..56c3a9677e 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -22,12 +22,13 @@ // import UIKit +import SwiftUI import Realm import NextcloudKit import EasyTipView import JGProgressHUD -class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, NCSectionFooterDelegate, NCSectionHeaderEmptyDataDelegate, UIAdaptivePresentationControllerDelegate, UIContextMenuInteractionDelegate { +class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, NCSectionFooterDelegate, NCSectionHeaderEmptyDataDelegate, NCAccountSettingsModelDelegate, UIAdaptivePresentationControllerDelegate, UIContextMenuInteractionDelegate { @IBOutlet weak var collectionView: UICollectionView! @@ -629,7 +630,14 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS self.appDelegate.openLogin(selector: NCGlobal.shared.introLogin, openLoginWeb: false) } - let addAccountSubmenu = UIMenu(title: "", options: .displayInline, children: [addAccountAction]) + let settingsAccountAction = UIAction(title: NSLocalizedString("_account_settings_", comment: ""), image: utility.loadImage(named: "gear", colors: [NCBrandColor.shared.iconImageColor])) { _ in + let accountSettingsModel = NCAccountSettingsModel(controller: self.tabBarController as? NCMainTabBarController, delegate: self) + let accountSettingsView = NCAccountSettingsView(model: accountSettingsModel) + let accountSettingsController = UIHostingController(rootView: accountSettingsView) + self.present(accountSettingsController, animated: true, completion: nil) + } + + let addAccountSubmenu = UIMenu(title: "", options: .displayInline, children: [addAccountAction, settingsAccountAction]) let menu = UIMenu(children: accountActions + [addAccountSubmenu]) @@ -771,7 +779,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS } func getNavigationTitle() -> String { - let activeAccount = NCManageDatabase.shared.getActiveAccount() guard let userAlias = activeAccount?.alias, !userAlias.isEmpty else { return NCBrandOptions.shared.brand @@ -779,6 +786,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS return userAlias } + func accountSettingsDidDismiss(tableAccount: tableAccount?) { } + // MARK: - SEARCH func searchController(enabled: Bool) { diff --git a/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift b/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift index 7f10df306d..7b455cb415 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift @@ -32,7 +32,6 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation { var metadata: tableMetadata var cell: NCCellProtocol? var collectionView: UICollectionView? - var fileNamePath: String var fileNamePreviewLocalPath: String var fileNameIconLocalPath: String let utilityFileSystem = NCUtilityFileSystem() @@ -41,7 +40,6 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation { self.metadata = tableMetadata.init(value: metadata) self.cell = cell self.collectionView = collectionView - self.fileNamePath = utilityFileSystem.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId) self.fileNamePreviewLocalPath = utilityFileSystem.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) self.fileNameIconLocalPath = utilityFileSystem.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag) } @@ -56,11 +54,11 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation { etagResource = metadata.etagResource } - NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePath, + NextcloudKit.shared.downloadPreview(fileId: metadata.fileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, + fileNameIconLocalPath: fileNameIconLocalPath, widthPreview: Int(sizePreview.width), heightPreview: Int(sizePreview.height), - fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon, etag: etagResource, options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { _, _, imageIcon, _, etag, error in diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift index 07a1c608fc..31cca24a9e 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift @@ -27,7 +27,7 @@ import XLForm // MARK: - -@objc class NCCreateFormUploadDocuments: XLFormViewController, NCSelectDelegate, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, NCCreateFormUploadConflictDelegate { +class NCCreateFormUploadDocuments: XLFormViewController, NCSelectDelegate, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, NCCreateFormUploadConflictDelegate { @IBOutlet weak var indicator: UIActivityIndicatorView! @IBOutlet weak var collectionView: UICollectionView! diff --git a/iOSClient/Media/NCMediaDownloadThumbnaill.swift b/iOSClient/Media/NCMediaDownloadThumbnaill.swift index 6ec3c154b4..bfc1304625 100644 --- a/iOSClient/Media/NCMediaDownloadThumbnaill.swift +++ b/iOSClient/Media/NCMediaDownloadThumbnaill.swift @@ -29,7 +29,6 @@ class NCMediaDownloadThumbnaill: ConcurrentOperation { var metadata: tableMetadata var media: NCMedia - var fileNamePath: String var fileNamePreviewLocalPath: String var fileNameIconLocalPath: String let utilityFileSystem = NCUtilityFileSystem() @@ -37,7 +36,6 @@ class NCMediaDownloadThumbnaill: ConcurrentOperation { init(metadata: tableMetadata, media: NCMedia) { self.metadata = tableMetadata.init(value: metadata) self.media = media - self.fileNamePath = utilityFileSystem.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId) self.fileNamePreviewLocalPath = utilityFileSystem.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) self.fileNameIconLocalPath = utilityFileSystem.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag) } @@ -52,11 +50,11 @@ class NCMediaDownloadThumbnaill: ConcurrentOperation { etagResource = metadata.etagResource } - NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePath, + NextcloudKit.shared.downloadPreview(fileId: metadata.fileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, + fileNameIconLocalPath: fileNameIconLocalPath, widthPreview: Int(sizePreview.width), heightPreview: Int(sizePreview.height), - fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon, etag: etagResource, options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { _, imagePreview, _, _, etag, error in diff --git a/iOSClient/More/CCManageAccount.h b/iOSClient/More/CCManageAccount.h deleted file mode 100644 index 48a072c44f..0000000000 --- a/iOSClient/More/CCManageAccount.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// CCManageAccount.h -// Nextcloud -// -// Created by Marino Faggiana on 12/03/15. -// Copyright (c) 2015 Marino Faggiana. All rights reserved. -// -// Author Marino Faggiana -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#import - -@interface CCManageAccount : XLFormViewController - -@end diff --git a/iOSClient/More/CCManageAccount.m b/iOSClient/More/CCManageAccount.m deleted file mode 100644 index ac89ff723d..0000000000 --- a/iOSClient/More/CCManageAccount.m +++ /dev/null @@ -1,434 +0,0 @@ -// -// CCManageAccount.m -// Nextcloud -// -// Created by Marino Faggiana on 12/03/15. -// Copyright (c) 2015 Marino Faggiana. All rights reserved. -// -// Author Marino Faggiana -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#import "CCManageAccount.h" -#import "NCBridgeSwift.h" - -#define actionSheetCancellaAccount 1 - -@interface CCManageAccount () -{ - AppDelegate *appDelegate; -} -@end - -@implementation CCManageAccount - -- (void)initializeForm -{ - XLFormDescriptor *form = [XLFormDescriptor formDescriptor]; - XLFormSectionDescriptor *section; - XLFormRowDescriptor *row; - - NSArray *accounts = [[NCManageDatabase shared] getAllAccount]; - tableAccount *activeAccount = [[NCManageDatabase shared] getActiveAccount]; - - // Section : ACCOUNTS ------------------------------------------- - - section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_accounts_", nil) sectionOptions:XLFormSectionOptionCanDelete]; - [form addFormSection:section]; - - for (tableAccount *account in accounts) { - - NSString *title = [NSString stringWithFormat:@"%@ %@", account.user, [NSURL URLWithString:account.urlBase].host]; - row = [XLFormRowDescriptor formRowDescriptorWithTag:account.account rowType:XLFormRowDescriptorTypeBooleanCheck title:title]; - - // Avatar - UIImage *avatar = [[[NCUtility alloc] init] loadUserImageFor:account.user displayName:account.displayName userBaseUrl:account]; - - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:13.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:avatar forKey:@"imageView.image"]; - if (account.active) { - row.value = @"YES"; - } - [section addFormRow:row]; - } - - // Section : ALIAS -------------------------------------------------- - - section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_alias_", nil)]; - section.footerTitle = NSLocalizedString(@"_alias_footer_", nil); - [form addFormSection:section]; - - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"alias" rowType:XLFormRowDescriptorTypeText]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[[UIImage imageNamed:@"form-textbox"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textField.font"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textField.textColor"]; - row.value = activeAccount.alias; - [section addFormRow:row]; - - // Section : MANAGE ACCOUNT ------------------------------------------- - - if ([NCBrandOptions shared].disable_manage_account == NO) { - - section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_manage_account_", nil)]; - [form addFormSection:section]; - - if ([NCBrandOptions shared].disable_multiaccount == NO) { - - // New Account nextcloud - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"addAccount" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_add_account_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:[[UIImage systemImageNamed:@"plus"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - row.action.formSelector = @selector(addAccount:); - [section addFormRow:row]; - } - - // Set user status - - BOOL userStatus = [[NCGlobal shared] capabilityUserStatusEnabled]; - if (userStatus) { - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"setUserStatus" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_set_user_status_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"userStatusAway"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"]; - row.action.formSelector = @selector(setUserStatus:); - if (accounts.count == 0) row.disabled = @YES; - [section addFormRow:row]; - } - - if ([NCBrandOptions shared].disable_multiaccount == NO) { - - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"accountRequest" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_settings_account_request_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[[UIImage imageNamed:@"users"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - if ([[NCKeychain alloc] init].accountRequest) row.value = @1; - else row.value = @0; - [section addFormRow:row]; - } - } - - // Section : CERIFICATES ------------------------------------------- - - section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_certificates_", nil)]; - [form addFormSection:section]; - - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"certificateDetails" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_certificate_details_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - row.action.formSelector = @selector(certificateDetails:); - [section addFormRow:row]; - - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"certificatePNDetails" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_certificate_pn_details_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - row.action.formSelector = @selector(certificatePNDetails:); - [section addFormRow:row]; - - // Section : USER INFORMATION ------------------------------------------- - - section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_personal_information_", nil)]; - [form addFormSection:section]; - - // Full Name - if ([activeAccount.displayName length] > 0) { - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"userfullname" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_full_name_", 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:[UIFont systemFontOfSize:15.0] forKey:@"detailTextLabel.font"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"user"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - row.value = activeAccount.displayName; - [section addFormRow:row]; - } - - // Address - if ([activeAccount.address length] > 0) { - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"useraddress" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_address_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"detailTextLabel.font"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"address"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - row.value = activeAccount.address; - [section addFormRow:row]; - } - - // City + zip - if ([activeAccount.city length] > 0) { - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"usercity" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_city_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"detailTextLabel.font"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"city"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - row.value = activeAccount.city; - if ([activeAccount.zip length] > 0) { - row.value = [NSString stringWithFormat:@"%@ %@", row.value, activeAccount.zip]; - } - [section addFormRow:row]; - } - - // Country - if ([activeAccount.country length] > 0) { - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"usercountry" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_country_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"detailTextLabel.font"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"country"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - row.value = [[NSLocale systemLocale] displayNameForKey:NSLocaleCountryCode value:activeAccount.country]; - [section addFormRow:row]; - } - - // Phone - if ([activeAccount.phone length] > 0) { - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"userphone" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_phone_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"detailTextLabel.font"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"phone"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - row.value = activeAccount.phone; - [section addFormRow:row]; - } - - // Email - if ([activeAccount.email length] > 0) { - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"useremail" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_email_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"detailTextLabel.font"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"email"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - row.value = activeAccount.email; - [section addFormRow:row]; - } - - // Web - if ([activeAccount.website length] > 0) { - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"userweb" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_web_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"detailTextLabel.font"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"network"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - row.value = activeAccount.website; - [section addFormRow:row]; - } - - // Twitter - if ([activeAccount.twitter length] > 0) { - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"usertwitter" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_twitter_", nil)]; - row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"detailTextLabel.font"]; - [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; - [row.cellConfig setObject:[[UIImage imageNamed:@"twitter"] imageWithColor:[NCBrandColor shared].iconImageColor size:25] forKey:@"imageView.image"]; - row.value = activeAccount.twitter; - [section addFormRow:row]; - } - - self.tableView.showsVerticalScrollIndicator = NO; - self.form = form; - - // Open Login - if (accounts.count == 0) { - [appDelegate openLoginWithSelector:NCGlobal.shared.introLogin openLoginWeb:false windowForRootViewController: nil]; - } -} - -// MARK: - View Life Cycle - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - self.title = NSLocalizedString(@"_credentials_", nil); - appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; - self.view.backgroundColor = UIColor.systemGroupedBackgroundColor; - - self.tableView.backgroundColor = UIColor.systemGroupedBackgroundColor; - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeUser) name:NCGlobal.shared.notificationCenterChangeUser object:nil]; - - [self initializeForm]; -} - -#pragma mark - NotificationCenter - -- (void)changeUser -{ - [self initializeForm]; -} - -#pragma mark - - --(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue -{ - [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue]; - - if ([rowDescriptor.tag isEqualToString:@"accountRequest"]) { - - if ([[rowDescriptor.value valueData] boolValue] == YES) { - [[NCKeychain alloc] init].accountRequest = true; - } else { - [[NCKeychain alloc] init].accountRequest = false; - } - } - - else if ([rowDescriptor.tag isEqualToString:@"alias"]) { - - if ([newValue isEqual:[NSNull null]]) { - [[NCManageDatabase shared] setAccountAlias:@""]; - } else { - [[NCManageDatabase shared] setAccountAlias:newValue]; - } - } - - else { - - NSArray *accounts = [[NCManageDatabase shared] getAllAccount]; - tableAccount *activeAccount = [[NCManageDatabase shared] getActiveAccount]; - - for (tableAccount *account in accounts) { - if ([rowDescriptor.tag isEqualToString:account.account]) { - if (![account.account isEqualToString:activeAccount.account]) { - [appDelegate changeAccount:account.account userProfile:nil]; - } - } - } - - [self initializeForm]; - } -} - --(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath -{ - return NSLocalizedString(@"_remove_local_account_", nil); -} - --(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { - [super tableView:tableView commitEditingStyle:editingStyle forRowAtIndexPath:indexPath]; - - if (editingStyle == UITableViewCellEditingStyleDelete) { - - [self initializeForm]; - - NSArray *accounts = [[NCManageDatabase shared] getAllAccount]; - tableAccount *tableAccountForDelete = accounts[indexPath.row]; - tableAccount *tableActiveAccount = [[NCManageDatabase shared] getActiveAccount]; - - NSString *accountForDelete = tableAccountForDelete.account; - NSString *activeAccount = tableActiveAccount.account; - - NSString *title = [NSString stringWithFormat:NSLocalizedString(@"_want_delete_account_",nil), accountForDelete]; - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet]; - - [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_remove_local_account_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { - - if (accountForDelete) { - [appDelegate deleteAccount:accountForDelete wipe:false]; - } - - NSArray *listAccount = [[NCManageDatabase shared] getAccounts]; - if ([listAccount count] > 0) { - if ([accountForDelete isEqualToString:activeAccount]) { - [appDelegate changeAccount:listAccount[0] userProfile:nil]; - } - } - - [self initializeForm]; - }]]; - - [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { }]]; - - alertController.popoverPresentationController.sourceView = self.view; - alertController.popoverPresentationController.sourceRect = [self.tableView rectForRowAtIndexPath:indexPath]; - - [self presentViewController:alertController animated:YES completion:nil]; - } -} - -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - if (indexPath.section == 0) { - return 60; - } else { - return 50; - } -} - -#pragma mark - - -- (void)addAccount:(XLFormRowDescriptor *)sender -{ - [self deselectFormRow:sender]; - - [appDelegate openLoginWithSelector:NCGlobal.shared.introLogin openLoginWeb:false windowForRootViewController:nil]; -} - -#pragma mark - - -- (void)setUserStatus:(XLFormRowDescriptor *)sender -{ - [self deselectFormRow:sender]; - - UINavigationController *navigationController = [[UIStoryboard storyboardWithName:@"NCUserStatus" bundle:nil] instantiateInitialViewController]; - [self presentViewController:navigationController animated:YES completion:nil]; -} - -#pragma mark - - -- (void)certificateDetails:(XLFormRowDescriptor *)sender -{ - [self deselectFormRow:sender]; - - UINavigationController *navigationController = [[UIStoryboard storyboardWithName:@"NCViewCertificateDetails" bundle:nil] instantiateInitialViewController]; - NCViewCertificateDetails *viewController = (NCViewCertificateDetails *)navigationController.topViewController; - - NSURL *url = [NSURL URLWithString:appDelegate.urlBase]; - viewController.host = [url host]; - - [self presentViewController:navigationController animated:YES completion:nil]; -} - -- (void)certificatePNDetails:(XLFormRowDescriptor *)sender -{ - [self deselectFormRow:sender]; - - UINavigationController *navigationController = [[UIStoryboard storyboardWithName:@"NCViewCertificateDetails" bundle:nil] instantiateInitialViewController]; - NCViewCertificateDetails *viewController = (NCViewCertificateDetails *)navigationController.topViewController; - - NSURL *url = [NSURL URLWithString: NCBrandOptions.shared.pushNotificationServerProxy]; - viewController.host = [url host]; - viewController.certificateTitle = NSLocalizedString(@"_certificate_pn_view_", nil); - - [self presentViewController:navigationController animated:YES completion:nil]; -} - -@end diff --git a/iOSClient/More/Cells/NCMoreUserCell.swift b/iOSClient/More/Cells/NCMoreUserCell.swift deleted file mode 100644 index 1d6e30cece..0000000000 --- a/iOSClient/More/Cells/NCMoreUserCell.swift +++ /dev/null @@ -1,44 +0,0 @@ -// -// NCMoreUserCell.swift -// Nextcloud -// -// Created by Milen on 14.06.23. -// Copyright © 2023 Marino Faggiana. All rights reserved. -// -// Author Marino Faggiana -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -import Foundation -import MarqueeLabel - -class NCMoreUserCell: BaseNCMoreCell { - @IBOutlet weak var displayName: UILabel! - @IBOutlet weak var avatar: UIImageView! - @IBOutlet weak var icon: UIImageView! - @IBOutlet weak var status: MarqueeLabel! - - static let reuseIdentifier = "NCMoreUserCell" - - static func fromNib() -> UINib { - return UINib(nibName: "NCMoreUserCell", bundle: nil) - } - - override func awakeFromNib() { - super.awakeFromNib() - - icon.makeCircularBackground(withColor: .systemBackground) - } -} diff --git a/iOSClient/More/Cells/NCMoreUserCell.xib b/iOSClient/More/Cells/NCMoreUserCell.xib deleted file mode 100755 index 5cd96162bd..0000000000 --- a/iOSClient/More/Cells/NCMoreUserCell.xib +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iOSClient/More/NCMore.swift b/iOSClient/More/NCMore.swift index 78309280b3..f7501a0abf 100644 --- a/iOSClient/More/NCMore.swift +++ b/iOSClient/More/NCMore.swift @@ -50,7 +50,6 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { var type: SectionType enum SectionType { - case account case moreApps case regular } @@ -70,7 +69,6 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { tableView.delegate = self tableView.dataSource = self tableView.backgroundColor = .systemGroupedBackground - tableView.register(NCMoreUserCell.fromNib(), forCellReuseIdentifier: NCMoreUserCell.reuseIdentifier) tableView.register(NCMoreAppSuggestionsCell.fromNib(), forCellReuseIdentifier: NCMoreAppSuggestionsCell.reuseIdentifier) // create tap gesture recognizer @@ -251,9 +249,11 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { } private func loadSections() { + /* if tabAccount != nil { sections.append(Section(items: [NKExternalSite()], type: .account)) } + */ if !NCBrandOptions.shared.disable_show_more_nextcloud_apps_in_settings { sections.append(Section(items: [NKExternalSite()], type: .moreApps)) @@ -275,7 +275,6 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { // MARK: - Action @objc func tapLabelQuotaExternalSite() { - if !quotaMenu.isEmpty { let item = quotaMenu[0] if let browserWebVC = UIStoryboard(name: "NCBrowserWeb", bundle: nil).instantiateInitialViewController() as? NCBrowserWeb { @@ -288,19 +287,10 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { } } - @objc func tapImageLogoManageAccount() { - let controller = CCManageAccount() - self.navigationController?.pushViewController(controller, animated: true) - } - // MARK: - func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - if sections[indexPath.section].type == .account { - return 75 - } else { - return 50 - } + return 50 } func numberOfSections(in tableView: UITableView) -> Int { @@ -310,9 +300,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, heightForHeaderInSection index: Int) -> CGFloat { let section = sections[index] - if section.type == .account { - return 10 - } else if section.type == .moreApps || sections[index - 1].type == .moreApps { + if section.type == .moreApps || sections[index - 1].type == .moreApps { return 1 } else { return 20 @@ -326,45 +314,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let section = sections[indexPath.section] - if section.type == .account { - - guard let cell = tableView.dequeueReusableCell(withIdentifier: NCMoreUserCell.reuseIdentifier, for: indexPath) as? NCMoreUserCell else { return UITableViewCell() } - - cell.avatar.image = nil - cell.icon.image = nil - cell.status.text = "" - cell.displayName.text = "" - - if let account = tabAccount { - cell.avatar.image = utility.loadUserImage(for: account.user, displayName: account.displayName, userBaseUrl: appDelegate) - - if account.alias.isEmpty { - cell.displayName?.text = account.displayName - } else { - cell.displayName?.text = account.displayName + " (" + account.alias + ")" - } - cell.displayName.textColor = NCBrandColor.shared.textColor - } - cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator - - if NCGlobal.shared.capabilityUserStatusEnabled, let account = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", appDelegate.account)) { - let status = utility.getUserStatus(userIcon: account.userStatusIcon, userStatus: account.userStatusStatus, userMessage: account.userStatusMessage) - cell.icon.image = status.onlineStatus - cell.status.text = status.statusMessage - cell.status.textColor = NCBrandColor.shared.textColor - cell.status.trailingBuffer = cell.status.frame.width - if cell.status.labelShouldScroll() { - cell.status.tapToScroll = true - } else { - cell.status.tapToScroll = false - } - } - - cell.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner, .layerMaxXMaxYCorner, .layerMinXMaxYCorner] - - return cell - - } else if section.type == .moreApps { + if section.type == .moreApps { guard let cell = tableView.dequeueReusableCell(withIdentifier: NCMoreAppSuggestionsCell.reuseIdentifier, for: indexPath) as? NCMoreAppSuggestionsCell else { return UITableViewCell() } return cell } else { @@ -406,11 +356,6 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let item = sections[indexPath.section].items[indexPath.row] - // Menu Function - if sections[indexPath.section].type == .account { - tapImageLogoManageAccount() - return - } // Action if item.url.contains("segue") && !item.url.contains("//") { self.navigationController?.performSegue(withIdentifier: item.url, sender: self) @@ -431,11 +376,9 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { } } else if item.url == "logout" { let alertController = UIAlertController(title: "", message: NSLocalizedString("_want_delete_", comment: ""), preferredStyle: .alert) - let actionYes = UIAlertAction(title: NSLocalizedString("_yes_delete_", comment: ""), style: .default) { (_: UIAlertAction) in - let manageAccount = CCManageAccount() - manageAccount.delete(self.appDelegate.account) - + // let manageAccount = CCManageAccount() + // manageAccount.delete(self.appDelegate.account) self.appDelegate.openLogin(selector: NCGlobal.shared.introLogin, openLoginWeb: false) } diff --git a/iOSClient/NCGlobal.swift b/iOSClient/NCGlobal.swift index 8cdfc582a7..df47055a1f 100644 --- a/iOSClient/NCGlobal.swift +++ b/iOSClient/NCGlobal.swift @@ -24,7 +24,7 @@ import UIKit class NCGlobal: NSObject { - @objc static let shared: NCGlobal = { + static let shared: NCGlobal = { let instance = NCGlobal() return instance }() @@ -90,12 +90,12 @@ class NCGlobal: NSObject { // Directory on Group // - @objc let directoryProviderStorage = "File Provider Storage" - @objc let appApplicationSupport = "Library/Application Support" - @objc let appCertificates = "Library/Application Support/Certificates" - @objc let appDatabaseNextcloud = "Library/Application Support/Nextcloud" - @objc let appScan = "Library/Application Support/Scan" - @objc let appUserData = "Library/Application Support/UserData" + let directoryProviderStorage = "File Provider Storage" + let appApplicationSupport = "Library/Application Support" + let appCertificates = "Library/Application Support/Certificates" + let appDatabaseNextcloud = "Library/Application Support/Nextcloud" + let appScan = "Library/Application Support/Scan" + let appUserData = "Library/Application Support/UserData" // Service // @@ -131,7 +131,7 @@ class NCGlobal: NSObject { // Intro selector // - @objc let introLogin: Int = 0 + let introLogin: Int = 0 let introSignup: Int = 1 // Avatar & Preview size @@ -216,82 +216,82 @@ class NCGlobal: NSObject { // ContentPresenter // - @objc let dismissAfterSecond: TimeInterval = 4 - @objc let dismissAfterSecondLong: TimeInterval = 10 + let dismissAfterSecond: TimeInterval = 4 + let dismissAfterSecondLong: TimeInterval = 10 // Error // - @objc let errorRequestExplicityCancelled: Int = 15 - @objc let errorNotModified: Int = 304 - @objc let errorBadRequest: Int = 400 - @objc let errorUnauthorized401: Int = 401 - @objc let errorForbidden: Int = 403 - @objc let errorResourceNotFound: Int = 404 - @objc let errorMethodNotSupported: Int = 405 - @objc let errorConflict: Int = 409 - @objc let errorPreconditionFailed: Int = 412 - @objc let errorUnsupportedMediaType: Int = 415 - @objc let errorInternalServerError: Int = 500 - @objc let errorQuota: Int = 507 - @objc let errorUnauthorized997: Int = 997 - @objc let errorExplicitlyCancelled: Int = -999 - @objc let errorConnectionLost: Int = -1005 - @objc let errorNetworkNotAvailable: Int = -1009 - @objc let errorBadServerResponse: Int = -1011 - @objc let errorInternalError: Int = -99999 - @objc let errorFileNotSaved: Int = -99998 - @objc let errorOffline: Int = -99997 - @objc let errorCharactersForbidden: Int = -99996 - @objc let errorCreationFile: Int = -99995 - @objc let errorReadFile: Int = -99994 - @objc let errorUnauthorizedFilesPasscode: Int = -99993 - @objc let errorDisableFilesApp: Int = -99992 - @objc let errorUnexpectedResponseFromDB: Int = -99991 + let errorRequestExplicityCancelled: Int = 15 + let errorNotModified: Int = 304 + let errorBadRequest: Int = 400 + let errorUnauthorized401: Int = 401 + let errorForbidden: Int = 403 + let errorResourceNotFound: Int = 404 + let errorMethodNotSupported: Int = 405 + let errorConflict: Int = 409 + let errorPreconditionFailed: Int = 412 + let errorUnsupportedMediaType: Int = 415 + let errorInternalServerError: Int = 500 + let errorQuota: Int = 507 + let errorUnauthorized997: Int = 997 + let errorExplicitlyCancelled: Int = -999 + let errorConnectionLost: Int = -1005 + let errorNetworkNotAvailable: Int = -1009 + let errorBadServerResponse: Int = -1011 + let errorInternalError: Int = -99999 + let errorFileNotSaved: Int = -99998 + let errorOffline: Int = -99997 + let errorCharactersForbidden: Int = -99996 + let errorCreationFile: Int = -99995 + let errorReadFile: Int = -99994 + let errorUnauthorizedFilesPasscode: Int = -99993 + let errorDisableFilesApp: Int = -99992 + let errorUnexpectedResponseFromDB: Int = -99991 // E2EE - @objc let errorE2EENotEnabled: Int = -98000 - @objc let errorE2EEVersion: Int = -98001 - @objc let errorE2EEKeyChecksums: Int = -98002 - @objc let errorE2EEKeyEncodeMetadata: Int = -98003 - @objc let errorE2EEKeyDecodeMetadata: Int = -98004 - @objc let errorE2EEKeyVerifySignature: Int = -98005 - @objc let errorE2EEKeyCiphertext: Int = -98006 - @objc let errorE2EEKeyFiledropCiphertext: Int = -98007 - @objc let errorE2EEJSon: Int = -98008 - @objc let errorE2EELock: Int = -98009 - @objc let errorE2EEEncryptFile: Int = -98010 - @objc let errorE2EEEncryptPayloadFile: Int = -98011 - @objc let errorE2EECounter: Int = -98012 - @objc let errorE2EEGenerateKey: Int = -98013 - @objc let errorE2EEEncodedKey: Int = -98014 - @objc let errorE2EENoUserFound: Int = -98015 - @objc let errorE2EEUploadInProgress: Int = -98016 + let errorE2EENotEnabled: Int = -98000 + let errorE2EEVersion: Int = -98001 + let errorE2EEKeyChecksums: Int = -98002 + let errorE2EEKeyEncodeMetadata: Int = -98003 + let errorE2EEKeyDecodeMetadata: Int = -98004 + let errorE2EEKeyVerifySignature: Int = -98005 + let errorE2EEKeyCiphertext: Int = -98006 + let errorE2EEKeyFiledropCiphertext: Int = -98007 + let errorE2EEJSon: Int = -98008 + let errorE2EELock: Int = -98009 + let errorE2EEEncryptFile: Int = -98010 + let errorE2EEEncryptPayloadFile: Int = -98011 + let errorE2EECounter: Int = -98012 + let errorE2EEGenerateKey: Int = -98013 + let errorE2EEEncodedKey: Int = -98014 + let errorE2EENoUserFound: Int = -98015 + let errorE2EEUploadInProgress: Int = -98016 // Filename Mask and Type // - let keyFileNameMask = "fileNameMask" - let keyFileNameType = "fileNameType" - let keyFileNameAutoUploadMask = "fileNameAutoUploadMask" - let keyFileNameAutoUploadType = "fileNameAutoUploadType" - let keyFileNameOriginal = "fileNameOriginal" - let keyFileNameOriginalAutoUpload = "fileNameOriginalAutoUpload" + let keyFileNameMask = "fileNameMask" + let keyFileNameType = "fileNameType" + let keyFileNameAutoUploadMask = "fileNameAutoUploadMask" + let keyFileNameAutoUploadType = "fileNameAutoUploadType" + let keyFileNameOriginal = "fileNameOriginal" + let keyFileNameOriginalAutoUpload = "fileNameOriginalAutoUpload" // Selector // - let selectorDownloadFile = "downloadFile" - let selectorReadFile = "readFile" - let selectorListingFavorite = "listingFavorite" - let selectorLoadFileView = "loadFileView" - let selectorLoadFileQuickLook = "loadFileQuickLook" - let selectorOpenIn = "openIn" - let selectorUploadAutoUpload = "uploadAutoUpload" - let selectorUploadAutoUploadAll = "uploadAutoUploadAll" - let selectorUploadFile = "uploadFile" - let selectorUploadFileNODelete = "UploadFileNODelete" - let selectorUploadFileShareExtension = "uploadFileShareExtension" - let selectorSaveAlbum = "saveAlbum" - let selectorSaveAsScan = "saveAsScan" - let selectorOpenDetail = "openDetail" - let selectorSynchronizationOffline = "synchronizationOffline" + let selectorDownloadFile = "downloadFile" + let selectorReadFile = "readFile" + let selectorListingFavorite = "listingFavorite" + let selectorLoadFileView = "loadFileView" + let selectorLoadFileQuickLook = "loadFileQuickLook" + let selectorOpenIn = "openIn" + let selectorUploadAutoUpload = "uploadAutoUpload" + let selectorUploadAutoUploadAll = "uploadAutoUploadAll" + let selectorUploadFile = "uploadFile" + let selectorUploadFileNODelete = "UploadFileNODelete" + let selectorUploadFileShareExtension = "uploadFileShareExtension" + let selectorSaveAlbum = "saveAlbum" + let selectorSaveAsScan = "saveAsScan" + let selectorOpenDetail = "openDetail" + let selectorSynchronizationOffline = "synchronizationOffline" // Metadata : Status // @@ -300,15 +300,15 @@ class NCGlobal: NSObject { // ± 2 downloading/uploading // ± 3 error // - let metadataStatusNormal: Int = 0 + let metadataStatusNormal: Int = 0 - let metadataStatusWaitDownload: Int = -1 - let metadataStatusDownloading: Int = -2 - let metadataStatusDownloadError: Int = -3 + let metadataStatusWaitDownload: Int = -1 + let metadataStatusDownloading: Int = -2 + let metadataStatusDownloadError: Int = -3 - let metadataStatusWaitUpload: Int = 1 - let metadataStatusUploading: Int = 2 - let metadataStatusUploadError: Int = 3 + let metadataStatusWaitUpload: Int = 1 + let metadataStatusUploading: Int = 2 + let metadataStatusUploadError: Int = 3 // Hidden files included in the read // @@ -316,13 +316,13 @@ class NCGlobal: NSObject { // Auto upload subfolder granularity // - let subfolderGranularityDaily = 2 - let subfolderGranularityMonthly = 1 - let subfolderGranularityYearly = 0 + let subfolderGranularityDaily = 2 + let subfolderGranularityMonthly = 1 + let subfolderGranularityYearly = 0 // Notification Center // - @objc let notificationCenterChangeUser = "changeUser" + let notificationCenterChangeUser = "changeUser" let notificationCenterChangeTheming = "changeTheming" let notificationCenterRichdocumentGrabFocus = "richdocumentGrabFocus" let notificationCenterReloadDataNCShare = "reloadDataNCShare" @@ -412,7 +412,7 @@ class NCGlobal: NSObject { // CAPABILITIES // var capabilityServerVersionMajor: Int = 0 - @objc var capabilityServerVersion: String = "" + var capabilityServerVersion: String = "" var capabilityFileSharingApiEnabled: Bool = false var capabilityFileSharingPubPasswdEnforced: Bool = false @@ -427,11 +427,11 @@ class NCGlobal: NSObject { var capabilityThemingColor: String = "" var capabilityThemingColorElement: String = "" var capabilityThemingColorText: String = "" - @objc var capabilityThemingName: String = "" - @objc var capabilityThemingSlogan: String = "" + var capabilityThemingName: String = "" + var capabilityThemingSlogan: String = "" - @objc var capabilityE2EEEnabled: Bool = false - @objc var capabilityE2EEApiVersion: String = "" + var capabilityE2EEEnabled: Bool = false + var capabilityE2EEApiVersion: String = "" var capabilityRichDocumentsEnabled: Bool = false var capabilityRichDocumentsMimetypes = ThreadSafeArray() @@ -443,7 +443,7 @@ class NCGlobal: NSObject { var capabilityFilesComments: Bool = false // NC 20 var capabilityFilesBigfilechunking: Bool = false - @objc var capabilityUserStatusEnabled: Bool = false + var capabilityUserStatusEnabled: Bool = false var capabilityExternalSites: Bool = false var capabilityGroupfoldersEnabled: Bool = false // NC27 var capabilityAssistantEnabled: Bool = false // NC28 diff --git a/iOSClient/Networking/NCNetworking+WebDAV.swift b/iOSClient/Networking/NCNetworking+WebDAV.swift index 56733b41c8..29afb1d7f2 100644 --- a/iOSClient/Networking/NCNetworking+WebDAV.swift +++ b/iOSClient/Networking/NCNetworking+WebDAV.swift @@ -693,26 +693,6 @@ extension NCNetworking { }) } - // MARK: - Download Preview - - func downloadPreview(fileNamePathOrFileId: String, - fileNamePreviewLocalPath: String, - widthPreview: Int, - heightPreview: Int, - fileNameIconLocalPath: String? = nil, - sizeIcon: Int = 0, - etag: String? = nil, - endpointTrashbin: Bool = false, - useInternalEndpoint: Bool = true, - options: NKRequestOptions = NKRequestOptions()) async -> (account: String, imagePreview: UIImage?, imageIcon: UIImage?, imageOriginal: UIImage?, etag: String?, error: NKError) { - - await withUnsafeContinuation({ continuation in - NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePathOrFileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, widthPreview: widthPreview, heightPreview: heightPreview, fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: sizeIcon, etag: etag, options: options) { account, imagePreview, imageIcon, imageOriginal, etag, error in - continuation.resume(returning: (account: account, imagePreview: imagePreview, imageIcon: imageIcon, imageOriginal: imageOriginal, etag: etag, error: error)) - } - }) - } - // MARK: - Search /// WebDAV search diff --git a/iOSClient/Nextcloud-Bridging-Header.h b/iOSClient/Nextcloud-Bridging-Header.h index 42cc076c22..bcb5fe0d84 100644 --- a/iOSClient/Nextcloud-Bridging-Header.h +++ b/iOSClient/Nextcloud-Bridging-Header.h @@ -2,7 +2,6 @@ // Use this file to import your target's public headers that you would like to expose to Swift. // -#import "CCManageAccount.h" #import "NCEndToEndEncryption.h" #import "NYMnemonic.h" #import "UIImage+animatedGIF.h" diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index 2eab5ad472..f5dd414d22 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -647,13 +647,9 @@ struct NCSelectViewControllerRepresentable: UIViewControllerRepresentable { } struct SelectView: UIViewControllerRepresentable { - - typealias UIViewControllerType = UINavigationController - @Binding var serverUrl: String class Coordinator: NSObject, NCSelectDelegate { - var parent: SelectView init(_ parent: SelectView) { @@ -668,7 +664,6 @@ struct SelectView: UIViewControllerRepresentable { } func makeUIViewController(context: Context) -> UINavigationController { - let storyboard = UIStoryboard(name: "NCSelect", bundle: nil) let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController let viewController = navigationController?.topViewController as? NCSelect diff --git a/iOSClient/Settings/AutoUpload/NCAutoUploadView.swift b/iOSClient/Settings/AutoUpload/NCAutoUploadView.swift index c34b4a6eca..5da2cdd669 100644 --- a/iOSClient/Settings/AutoUpload/NCAutoUploadView.swift +++ b/iOSClient/Settings/AutoUpload/NCAutoUploadView.swift @@ -113,17 +113,6 @@ struct NCAutoUploadView: View { } .font(.system(size: 16)) }) - /// Auto Upload Full - Section(content: { - Toggle(NSLocalizedString("_autoupload_fullphotos_", comment: ""), isOn: $model.autoUploadFull) - .tint(Color(NCBrandColor.shared.brandElement)) - .onChange(of: model.autoUploadFull) { newValue in - model.handleAutoUploadFullChange(newValue: newValue) - } - .font(.system(size: 16)) - }, footer: { - Text(NSLocalizedString("_autoupload_fullphotos_footer_", comment: "")) - }) /// Auto Upload create subfolder Section(content: { Toggle(NSLocalizedString("_autoupload_create_subfolder_", comment: ""), isOn: $model.autoUploadCreateSubfolder) @@ -152,12 +141,20 @@ struct NCAutoUploadView: View { Text(NSLocalizedString("_autoupload_filenamemask_", comment: "")) .font(.system(size: 16)) } + }, footer: { + Text(NSLocalizedString("_autoupload_filenamemask_footer_", comment: "")) + }) + /// Auto Upload Full + Section(content: { + Toggle(NSLocalizedString("_autoupload_fullphotos_", comment: ""), isOn: $model.autoUploadFull) + .tint(Color(NCBrandColor.shared.brandElement)) + .onChange(of: model.autoUploadFull) { newValue in + model.handleAutoUploadFullChange(newValue: newValue) + } + .font(.system(size: 16)) }, footer: { Text( - NSLocalizedString("_autoupload_filenamemask_footer_", comment: "") - + - "\n \n" - ) + NSLocalizedString("_autoupload_fullphotos_footer_", comment: "") + "\n \n") }) } } diff --git a/iOSClient/Settings/Settings/E2EE/NCManageE2EEView.swift b/iOSClient/Settings/Settings/E2EE/NCManageE2EEView.swift index 3ee5bfa6e4..b588ac22be 100644 --- a/iOSClient/Settings/Settings/E2EE/NCManageE2EEView.swift +++ b/iOSClient/Settings/Settings/E2EE/NCManageE2EEView.swift @@ -74,7 +74,7 @@ struct NCManageE2EEView: View { .scaledToFit() .font(Font.system(.body).weight(.light)) .frame(width: 25, height: 15) - .foregroundColor(.red) + .foregroundColor(Color(NCBrandColor.shared.iconImageColor)) } Spacer() } diff --git a/iOSClient/Settings/Settings/NCSettingsModel.swift b/iOSClient/Settings/Settings/NCSettingsModel.swift index 451fbb7da6..dcf51ec18f 100644 --- a/iOSClient/Settings/Settings/NCSettingsModel.swift +++ b/iOSClient/Settings/Settings/NCSettingsModel.swift @@ -43,6 +43,8 @@ class NCSettingsModel: ObservableObject, ViewOnAppearHandling { @Published var privacyScreen: Bool = false /// State to control @Published var resetWrongAttempts: Bool = false + /// Request account on start + @Published var accountRequest: Bool = false /// Root View Controller @Published var controller: NCMainTabBarController? /// Footer @@ -63,6 +65,7 @@ class NCSettingsModel: ObservableObject, ViewOnAppearHandling { lockScreen = !keychain.requestPasscodeAtStart privacyScreen = keychain.privacyScreenEnabled resetWrongAttempts = keychain.resetAppCounterFail + accountRequest = keychain.accountRequest footerApp = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility().getVersionApp(withBuild: true)) + "\n\n" footerServer = String(format: NCBrandOptions.shared.textCopyrightNextcloudServer, NCGlobal.shared.capabilityServerVersion) + "\n" footerSlogan = NCGlobal.shared.capabilityThemingName + " - " + NCGlobal.shared.capabilityThemingSlogan + "\n\n" @@ -99,6 +102,11 @@ class NCSettingsModel: ObservableObject, ViewOnAppearHandling { configServer.startService(url: url) } } + + /// Function to update Account request on start + func updateAccountRequest() { + keychain.accountRequest = accountRequest + } } struct PasscodeView: UIViewControllerRepresentable { diff --git a/iOSClient/Settings/Settings/NCSettingsView.swift b/iOSClient/Settings/Settings/NCSettingsView.swift index 93cafd8b7a..1fc7030c00 100644 --- a/iOSClient/Settings/Settings/NCSettingsView.swift +++ b/iOSClient/Settings/Settings/NCSettingsView.swift @@ -158,7 +158,22 @@ struct NCSettingsView: View { .lineSpacing(1) }) } - /// `E2EEncryption` Section + /// Users + Section(content: { + Toggle(NSLocalizedString("_settings_account_request_", comment: ""), isOn: $model.accountRequest) + .font(.system(size: 16)) + .tint(Color(NCBrandColor.shared.brandElement)) + .onChange(of: model.accountRequest, perform: { _ in + model.updateAccountRequest() + }) + }, header: { + Text(NSLocalizedString("_users_", comment: "")) + }, footer: { + Text(NSLocalizedString("_users_footer_", comment: "")) + .font(.system(size: 12)) + .lineSpacing(1) + }) + /// E2EEncryption` Section if NCGlobal.shared.capabilityE2EEEnabled && NCGlobal.shared.e2eeVersions.contains(NCGlobal.shared.capabilityE2EEApiVersion) { E2EESection(model: model) } diff --git a/iOSClient/Share/NCShareUserCell.swift b/iOSClient/Share/NCShareUserCell.swift index 842707301f..afa5eba26a 100644 --- a/iOSClient/Share/NCShareUserCell.swift +++ b/iOSClient/Share/NCShareUserCell.swift @@ -72,7 +72,7 @@ class NCShareUserCell: UITableViewCell, NCCellProtocol { imageItem.image = NCShareCommon().getImageShareType(shareType: tableShare.shareType) let status = utility.getUserStatus(userIcon: tableShare.userIcon, userStatus: tableShare.userStatus, userMessage: tableShare.userMessage) - imageStatus.image = status.onlineStatus + imageStatus.image = status.statusImage self.status.text = status.statusMessage // If the initiator or the recipient is not the current user, show the list of sharees without any options to edit it. @@ -157,7 +157,7 @@ class NCSearchUserDropDownCell: DropDownCell, NCCellProtocol { imageItem.image = NCShareCommon().getImageShareType(shareType: sharee.shareType) imageShareeType.image = NCShareCommon().getImageShareType(shareType: sharee.shareType) let status = utility.getUserStatus(userIcon: sharee.userIcon, userStatus: sharee.userStatus, userMessage: sharee.userMessage) - imageStatus.image = status.onlineStatus + imageStatus.image = status.statusImage self.status.text = status.statusMessage if self.status.text?.count ?? 0 > 0 { centerTitle.constant = -5 diff --git a/iOSClient/Supporting Files/en.lproj/Localizable.strings b/iOSClient/Supporting Files/en.lproj/Localizable.strings index ee09a0971e..3bedb557df 100644 --- a/iOSClient/Supporting Files/en.lproj/Localizable.strings +++ b/iOSClient/Supporting Files/en.lproj/Localizable.strings @@ -197,6 +197,7 @@ "_settings_account_request_" = "Request account at startup"; "_print_" = "Print"; "_alias_" = "Alias"; +"_alias_placeholder_" = "Write the alias"; "_alias_footer_" = "Give your account names a descriptive name such as Home, Office, School …"; "_chunk_size_mb_" = "Chunk size in MB"; "_chunk_footer_title_" = "Chunked file upload (0 is disabled)\nImportant: the chunked upload works only when the app is \"active\"."; @@ -209,7 +210,7 @@ "_copy_failed_" = "Copy failed"; "_certificate_installed_" = "Certificate installed"; "_remove_local_account_" = "Remove local account"; -"_want_delete_account_" = "Do you want to remove local account %@"; +"_want_delete_account_" = "Do you want to remove local account"; "_prevent_http_redirection_"= "The redirection in HTTP is not permitted"; "_pdf_vertical_" = "PDF vertical display"; "_pdf_horizontal_" = "PDF horizontal display"; @@ -987,6 +988,9 @@ "_light_" = "Light"; "_dark_" = "Dark"; "_use_system_style_" = "Use system style"; +"_account_settings_" = "Account settings"; +"_users_" = "Users"; +"_users_footer_" = "Every time the app is reactivated, the account will be requested"; // Video "_select_trace_" = "Select the trace"; diff --git a/iOSClient/Trash/NCTrash+Networking.swift b/iOSClient/Trash/NCTrash+Networking.swift index af08ebcf31..b52a673e8a 100644 --- a/iOSClient/Trash/NCTrash+Networking.swift +++ b/iOSClient/Trash/NCTrash+Networking.swift @@ -104,15 +104,13 @@ class NCOperationDownloadThumbnailTrash: ConcurrentOperation { let fileNamePreviewLocalPath = NCUtilityFileSystem().getDirectoryProviderStoragePreviewOcId(tableTrash.fileId, etag: tableTrash.fileName) let fileNameIconLocalPath = NCUtilityFileSystem().getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName) - NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: tableTrash.fileId, - fileNamePreviewLocalPath: fileNamePreviewLocalPath, - widthPreview: NCGlobal.shared.sizePreview, - heightPreview: NCGlobal.shared.sizePreview, - fileNameIconLocalPath: fileNameIconLocalPath, - sizeIcon: NCGlobal.shared.sizeIcon, - etag: nil, - endpointTrashbin: true, - options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { _, imagePreview, _, _, _, error in + NextcloudKit.shared.downloadTrashPreview(fileId: tableTrash.fileId, + fileNamePreviewLocalPath: fileNamePreviewLocalPath, + fileNameIconLocalPath: fileNameIconLocalPath, + widthPreview: NCGlobal.shared.sizePreview, + heightPreview: NCGlobal.shared.sizePreview, + sizeIcon: NCGlobal.shared.sizeIcon, + options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { _, imagePreview, _, _, _, error in if error == .success, let imagePreview = imagePreview { DispatchQueue.main.async { diff --git a/iOSClient/UserStatus/NCUserStatus.swift b/iOSClient/UserStatus/NCUserStatus.swift index c2005ee9ac..886e549fb8 100644 --- a/iOSClient/UserStatus/NCUserStatus.swift +++ b/iOSClient/UserStatus/NCUserStatus.swift @@ -22,8 +22,9 @@ // along with this program. If not, see . // -import UIKit import Foundation +import UIKit +import SwiftUI import NextcloudKit import DropDown @@ -86,7 +87,7 @@ class NCUserStatus: UIViewController { onlineButton.layer.masksToBounds = true onlineButton.backgroundColor = .systemGray5 let onLine = utility.getUserStatus(userIcon: nil, userStatus: "online", userMessage: nil) - onlineImage.image = onLine.onlineStatus + onlineImage.image = onLine.statusImage onlineLabel.text = onLine.statusMessage onlineLabel.textColor = NCBrandColor.shared.textColor @@ -94,7 +95,7 @@ class NCUserStatus: UIViewController { awayButton.layer.masksToBounds = true awayButton.backgroundColor = .systemGray5 let away = utility.getUserStatus(userIcon: nil, userStatus: "away", userMessage: nil) - awayImage.image = away.onlineStatus + awayImage.image = away.statusImage awayLabel.text = away.statusMessage awayLabel.textColor = NCBrandColor.shared.textColor @@ -102,7 +103,7 @@ class NCUserStatus: UIViewController { dndButton.layer.masksToBounds = true dndButton.backgroundColor = .systemGray5 let dnd = utility.getUserStatus(userIcon: nil, userStatus: "dnd", userMessage: nil) - dndImage.image = dnd.onlineStatus + dndImage.image = dnd.statusImage dndLabel.text = dnd.statusMessage dndLabel.textColor = NCBrandColor.shared.textColor dndDescrLabel.text = dnd.descriptionMessage @@ -112,7 +113,7 @@ class NCUserStatus: UIViewController { invisibleButton.layer.masksToBounds = true invisibleButton.backgroundColor = .systemGray5 let invisible = utility.getUserStatus(userIcon: nil, userStatus: "invisible", userMessage: nil) - invisibleImage.image = invisible.onlineStatus + invisibleImage.image = invisible.statusImage invisibleLabel.text = invisible.statusMessage invisibleLabel.textColor = NCBrandColor.shared.textColor invisibleDescrLabel.text = invisible.descriptionMessage @@ -172,9 +173,7 @@ class NCUserStatus: UIViewController { super.viewWillDisappear(animated) NextcloudKit.shared.getUserStatus { account, clearAt, icon, message, messageId, messageIsPredefined, status, statusIsUserDefined, _, _, error in - if error == .success { - NCManageDatabase.shared.setAccountUserStatus(userStatusClearAt: clearAt, userStatusIcon: icon, userStatusMessage: message, userStatusMessageId: messageId, userStatusMessageIsPredefined: messageIsPredefined, userStatusStatus: status, userStatusStatusIsUserDefined: statusIsUserDefined, account: account) } } @@ -605,3 +604,29 @@ extension NCUserStatus: UITableViewDataSource { return cell } } + +struct UserStatusView: UIViewControllerRepresentable { + @Binding var showUserStatus: Bool + + class Coordinator: NSObject { + var parent: UserStatusView + + init(_ parent: UserStatusView) { + self.parent = parent + } + } + + func makeUIViewController(context: Context) -> UINavigationController { + let storyboard = UIStoryboard(name: "NCUserStatus", bundle: nil) + let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController + let viewController = navigationController?.topViewController as? NCUserStatus + + return navigationController! + } + + func updateUIViewController(_ uiViewController: UINavigationController, context: Context) { } + + func makeCoordinator() -> Coordinator { + Coordinator(self) + } +} diff --git a/iOSClient/Utility/NCUtility+Image.swift b/iOSClient/Utility/NCUtility+Image.swift index 9ab5099e98..23c5bccb99 100644 --- a/iOSClient/Utility/NCUtility+Image.swift +++ b/iOSClient/Utility/NCUtility+Image.swift @@ -30,7 +30,6 @@ import Photos import SVGKit extension NCUtility { - func loadImage(named imageName: String, colors: [UIColor]? = nil, size: CGFloat? = nil, useTypeIconFile: Bool = false ) -> UIImage { var image: UIImage? @@ -405,4 +404,47 @@ extension NCUtility { } return CGSize(width: widthPreview, height: heightPreview) } + + func getUserStatus(userIcon: String?, userStatus: String?, userMessage: String?) -> (statusImage: UIImage, statusMessage: String, descriptionMessage: String) { + var statusImage: UIImage? + var statusMessage: String = "" + var descriptionMessage: String = "" + var messageUserDefined: String = "" + + if userStatus?.lowercased() == "online" { + statusImage = loadImage(named: "circle_fill", colors: [UIColor(red: 103.0 / 255.0, green: 176.0 / 255.0, blue: 134.0 / 255.0, alpha: 1.0)]) + messageUserDefined = NSLocalizedString("_online_", comment: "") + } + if userStatus?.lowercased() == "away" { + statusImage = loadImage(named: "userStatusAway", colors: [UIColor(red: 233.0 / 255.0, green: 166.0 / 255.0, blue: 75.0 / 255.0, alpha: 1.0)]) + messageUserDefined = NSLocalizedString("_away_", comment: "") + } + if userStatus?.lowercased() == "dnd" { + statusImage = loadImage(named: "userStatusDnd") + messageUserDefined = NSLocalizedString("_dnd_", comment: "") + descriptionMessage = NSLocalizedString("_dnd_description_", comment: "") + } + if userStatus?.lowercased() == "offline" || userStatus?.lowercased() == "invisible" { + statusImage = UIImage(named: "userStatusOffline")!.withTintColor(.init(named: "SystemBackgroundInverted")!) + messageUserDefined = NSLocalizedString("_invisible_", comment: "") + descriptionMessage = NSLocalizedString("_invisible_description_", comment: "") + } + + if let userIcon = userIcon { + statusMessage = userIcon + " " + } + if let userMessage = userMessage { + statusMessage += userMessage + } + statusMessage = statusMessage.trimmingCharacters(in: .whitespaces) + if statusMessage.isEmpty { + statusMessage = messageUserDefined + } + + if let statusImage { + return(statusImage, statusMessage, descriptionMessage) + } else { + return(UIImage(), statusMessage, descriptionMessage) + } + } } diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index 43260ca6bb..c3d588b3a9 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -136,45 +136,6 @@ class NCUtility: NSObject { return String(intFileId) } - func getUserStatus(userIcon: String?, userStatus: String?, userMessage: String?) -> (onlineStatus: UIImage?, statusMessage: String, descriptionMessage: String) { - var onlineStatus: UIImage? - var statusMessage: String = "" - var descriptionMessage: String = "" - var messageUserDefined: String = "" - - if userStatus?.lowercased() == "online" { - onlineStatus = UIImage(named: "circle_fill")!.image(color: UIColor(red: 103.0 / 255.0, green: 176.0 / 255.0, blue: 134.0 / 255.0, alpha: 1.0), size: 50) - messageUserDefined = NSLocalizedString("_online_", comment: "") - } - if userStatus?.lowercased() == "away" { - onlineStatus = UIImage(named: "userStatusAway")!.image(color: UIColor(red: 233.0 / 255.0, green: 166.0 / 255.0, blue: 75.0 / 255.0, alpha: 1.0), size: 50) - messageUserDefined = NSLocalizedString("_away_", comment: "") - } - if userStatus?.lowercased() == "dnd" { - onlineStatus = UIImage(named: "userStatusDnd")?.resizeImage(size: CGSize(width: 100, height: 100), isAspectRation: false) - messageUserDefined = NSLocalizedString("_dnd_", comment: "") - descriptionMessage = NSLocalizedString("_dnd_description_", comment: "") - } - if userStatus?.lowercased() == "offline" || userStatus?.lowercased() == "invisible" { - onlineStatus = UIImage(named: "userStatusOffline")!.withTintColor(.init(named: "SystemBackgroundInverted")!) - messageUserDefined = NSLocalizedString("_invisible_", comment: "") - descriptionMessage = NSLocalizedString("_invisible_description_", comment: "") - } - - if let userIcon = userIcon { - statusMessage = userIcon + " " - } - if let userMessage = userMessage { - statusMessage += userMessage - } - statusMessage = statusMessage.trimmingCharacters(in: .whitespaces) - if statusMessage.isEmpty { - statusMessage = messageUserDefined - } - - return(onlineStatus, statusMessage, descriptionMessage) - } - @objc func getVersionApp(withBuild: Bool = true) -> String { if let dictionary = Bundle.main.infoDictionary { if let version = dictionary["CFBundleShortVersionString"], let build = dictionary["CFBundleVersion"] { diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift index 13308923a1..721fa02d9b 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift @@ -300,16 +300,15 @@ class NCViewerMedia: UIViewController { if utilityFileSystem.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) { return completion(UIImage(contentsOfFile: utilityFileSystem.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag))) } else { - let fileNamePath = utilityFileSystem.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId) let fileNamePreviewLocalPath = utilityFileSystem.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) let fileNameIconLocalPath = utilityFileSystem.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag) let sizePreview = NCUtility().getSizePreview(width: metadata.width, height: metadata.height) - NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePath, + NextcloudKit.shared.downloadPreview(fileId: metadata.fileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, + fileNameIconLocalPath: fileNameIconLocalPath, widthPreview: Int(sizePreview.width), heightPreview: Int(sizePreview.height), - fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon, options: NKRequestOptions(queue: .main)) { _, imagePreview, _, _, etag, error in