diff --git a/Brand/Database.swift b/Brand/Database.swift index ae439a5ec7..699a9a634e 100644 --- a/Brand/Database.swift +++ b/Brand/Database.swift @@ -26,4 +26,4 @@ import Foundation // Database Realm // let databaseName = "nextcloud.realm" -let databaseSchemaVersion: UInt64 = 365 +let databaseSchemaVersion: UInt64 = 366 diff --git a/iOSClient/Data/NCManageDatabase+Account.swift b/iOSClient/Data/NCManageDatabase+Account.swift index 4d599d6f75..1fed677983 100644 --- a/iOSClient/Data/NCManageDatabase+Account.swift +++ b/iOSClient/Data/NCManageDatabase+Account.swift @@ -39,6 +39,7 @@ class tableAccount: Object { @objc dynamic var autoUploadFull: Bool = false @objc dynamic var autoUploadImage: Bool = false @objc dynamic var autoUploadVideo: Bool = false + @objc dynamic var autoUploadFavoritesOnly: Bool = false @objc dynamic var autoUploadWWAnPhoto: Bool = false @objc dynamic var autoUploadWWAnVideo: Bool = false @objc dynamic var backend = "" diff --git a/iOSClient/Networking/NCAutoUpload.swift b/iOSClient/Networking/NCAutoUpload.swift index bf56c2dcb0..bddd137c11 100644 --- a/iOSClient/Networking/NCAutoUpload.swift +++ b/iOSClient/Networking/NCAutoUpload.swift @@ -246,12 +246,16 @@ class NCAutoUpload: NSObject { } let idAsset = account + asset.localIdentifier + creationDateString if !idAssets.contains(idAsset) { - newAssets.append(asset) + if ((asset.isFavorite && tableAccount.autoUploadFavoritesOnly) || !tableAccount.autoUploadFavoritesOnly) { + newAssets.append(asset) + } } } } else { assets.enumerateObjects { asset, _, _ in - newAssets.append(asset) + if ((asset.isFavorite && tableAccount.autoUploadFavoritesOnly) || !tableAccount.autoUploadFavoritesOnly) { + newAssets.append(asset) + } } } completion(newAssets) diff --git a/iOSClient/Settings/AutoUpload/NCAutoUploadModel.swift b/iOSClient/Settings/AutoUpload/NCAutoUploadModel.swift index dbb5fc4090..f6f334b3b1 100644 --- a/iOSClient/Settings/AutoUpload/NCAutoUploadModel.swift +++ b/iOSClient/Settings/AutoUpload/NCAutoUploadModel.swift @@ -41,6 +41,8 @@ class NCAutoUploadModel: ObservableObject, ViewOnAppearHandling { @Published var autoUploadVideo: Bool = false /// A state variable that indicates whether auto upload for videos is enabled or not @Published var autoUploadWWAnVideo: Bool = false + /// A state variable that indicates whether only assets marked as favorites should be uploaded + @Published var autoUploadFavoritesOnly: Bool = false /// A state variable that indicates whether auto upload for full resolution photos is enabled or not @Published var autoUploadFull: Bool = false /// A state variable that indicates whether auto upload creates subfolders based on date or not @@ -151,6 +153,10 @@ class NCAutoUploadModel: ObservableObject, ViewOnAppearHandling { func handleAutoUploadWWAnVideoChange(newValue: Bool) { updateAccountProperty(\.autoUploadWWAnVideo, value: newValue) } + + func handleAutoUploadFavoritesOnlyChange(newValue: Bool) { + updateAccountProperty(\.autoUploadFavoritesOnly, value: newValue) + } /// Updates the auto-upload full content setting. func handleAutoUploadFullChange(newValue: Bool) { diff --git a/iOSClient/Settings/AutoUpload/NCAutoUploadView.swift b/iOSClient/Settings/AutoUpload/NCAutoUploadView.swift index 58b22a0913..642a515d70 100644 --- a/iOSClient/Settings/AutoUpload/NCAutoUploadView.swift +++ b/iOSClient/Settings/AutoUpload/NCAutoUploadView.swift @@ -113,6 +113,15 @@ struct NCAutoUploadView: View { } .font(.system(size: 16)) }) + /// Only upload favorites if desired + Section(content: { + Toggle(NSLocalizedString("_autoupload_favorites_", comment: ""), isOn: $model.autoUploadFavoritesOnly) + .tint(Color(NCBrandColor.shared.getElement(account: model.session.account))) + .onChange(of: model.autoUploadFavoritesOnly) { newValue in + model.handleAutoUploadFavoritesOnlyChange(newValue: newValue) + } + .font(.system(size: 16)) + }) /// Auto Upload create subfolder Section(content: { Toggle(NSLocalizedString("_autoupload_create_subfolder_", comment: ""), isOn: $model.autoUploadCreateSubfolder) diff --git a/iOSClient/Supporting Files/de.lproj/Localizable.strings b/iOSClient/Supporting Files/de.lproj/Localizable.strings index 489d84a7c1..7230afe9ac 100644 Binary files a/iOSClient/Supporting Files/de.lproj/Localizable.strings and b/iOSClient/Supporting Files/de.lproj/Localizable.strings differ diff --git a/iOSClient/Supporting Files/en.lproj/Localizable.strings b/iOSClient/Supporting Files/en.lproj/Localizable.strings index fe9ee97227..d8d4703bd6 100644 --- a/iOSClient/Supporting Files/en.lproj/Localizable.strings +++ b/iOSClient/Supporting Files/en.lproj/Localizable.strings @@ -392,6 +392,7 @@ "_autoupload_background_" = "Auto upload in the background"; "_autoupload_photos_" = "Auto upload photos"; "_autoupload_videos_" = "Auto upload videos"; +"_autoupload_favorites_" = "Upload favorites only"; "_autoupload_description_" = "New photos/videos will be automatically uploaded to your server."; "_autoupload_description_background_" = "This option requires the use of GPS to trigger the detection of new photos/videos in the camera roll once the location changes significantly"; "_autoupload_background_title_" = "Limitations";