Skip to content

Commit bd58e2f

Browse files
fix: clarify auto upload progress and PhotoKit settings (#4361)
Display the incremental backup date while uploading and show range controls only while stopped. Hide focused upload and background location controls when PhotoKit is enabled and supported. Assisted-by: Codex:GPT-6 Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
1 parent d7e48d6 commit bd58e2f

3 files changed

Lines changed: 64 additions & 30 deletions

File tree

‎iOSClient/Settings/AutoUpload/NCAutoUploadModel.swift‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ class NCAutoUploadModel: ObservableObject, ViewOnAppearHandling {
4343
/// Whether the experimental PhotoKit background upload extension is enabled.
4444
@Published var backgroundUploadExtensionEnabled: Bool = false
4545

46+
/// Legacy controls remain available when PhotoKit is disabled or unsupported for this account.
47+
var usesPhotoKitAutoUpload: Bool {
48+
guard #available(iOS 27, *),
49+
NCPreferences.canConfigureBackgroundUploadExtension,
50+
backgroundUploadExtensionEnabled,
51+
PHPhotoLibrary.authorizationStatus(for: .readWrite) == .authorized,
52+
let capabilities = NCNetworking.shared.capabilities[session.account] else { return false }
53+
return NCBrandOptions.shared.isServerVersion(capabilities, greaterOrEqualTo: .v35)
54+
}
55+
4656
/// Whether the error alert should be shown in the view.
4757
@Published var showErrorAlert: Bool = false
4858
/// The currently displayed section name.

‎iOSClient/Settings/AutoUpload/NCAutoUploadView.swift‎

Lines changed: 52 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ struct NCAutoUploadView: View {
142142
}
143143
}
144144

145-
if model.autoUploadStart && autoUploadCounter.hasItemsToUpload {
145+
if !model.usesPhotoKitAutoUpload, model.autoUploadStart && autoUploadCounter.hasItemsToUpload {
146146
Section(content: {
147147
Button {
148148
showFocusedAutoUploadIntro = true
@@ -231,7 +231,11 @@ struct NCAutoUploadView: View {
231231
}
232232
}
233233

234-
autoUploadTimespanOptions
234+
if model.autoUploadStart {
235+
autoUploadProgressDate
236+
} else {
237+
autoUploadTimespanOptions
238+
}
235239
}, footer: {
236240
Text(autoUploadTimespanDescription)
237241
.font(.footnote)
@@ -387,37 +391,39 @@ struct NCAutoUploadView: View {
387391
.font(.footnote)
388392
})
389393

390-
Section(content: {
391-
Toggle(
392-
NSLocalizedString(
393-
"_enable_background_location_title_",
394-
comment: ""
395-
),
396-
isOn: $model.locationAutoUploadPermissionGranted
397-
)
398-
.font(.body)
399-
.tint(
400-
Color(
401-
NCBrandColor.shared.getElement(
402-
account: model.session.account
394+
if !model.usesPhotoKitAutoUpload {
395+
Section(content: {
396+
Toggle(
397+
NSLocalizedString(
398+
"_enable_background_location_title_",
399+
comment: ""
400+
),
401+
isOn: $model.locationAutoUploadPermissionGranted
402+
)
403+
.font(.body)
404+
.tint(
405+
Color(
406+
NCBrandColor.shared.getElement(
407+
account: model.session.account
408+
)
403409
)
404410
)
405-
)
406-
.opacity(model.autoUploadStart ? 0.15 : 1)
407-
.onChange(
408-
of: model.locationAutoUploadPermissionGranted
409-
) { _, newValue in
410-
model.handleLocationChange(newValue: newValue)
411-
}
412-
}, footer: {
413-
Text(
414-
NSLocalizedString(
415-
"_enable_background_location_footer_",
416-
comment: ""
411+
.opacity(model.autoUploadStart ? 0.15 : 1)
412+
.onChange(
413+
of: model.locationAutoUploadPermissionGranted
414+
) { _, newValue in
415+
model.handleLocationChange(newValue: newValue)
416+
}
417+
}, footer: {
418+
Text(
419+
NSLocalizedString(
420+
"_enable_background_location_footer_",
421+
comment: ""
422+
)
417423
)
418-
)
419-
.font(.footnote)
420-
})
424+
.font(.footnote)
425+
})
426+
}
421427
}
422428
.disabled(
423429
model.autoUploadStart || model.isChangingAutoUpload || isAutoUploadUnavailable
@@ -495,6 +501,22 @@ struct NCAutoUploadView: View {
495501
}
496502
}
497503

504+
private var autoUploadProgressDate: some View {
505+
LabeledContent {
506+
if let date = model.autoUploadSinceDate {
507+
Text(date.formatted(date: .abbreviated, time: .shortened))
508+
.multilineTextAlignment(.trailing)
509+
} else {
510+
Text("_autoupload_waiting_for_uploads_")
511+
}
512+
} label: {
513+
Text("_autoupload_completed_until_")
514+
}
515+
.font(.body)
516+
.foregroundStyle(.primary)
517+
.accessibilityIdentifier("AutoUploadProgressDate")
518+
}
519+
498520
@ViewBuilder
499521
private var autoUploadTimespanOptions: some View {
500522
ForEach(AutoUploadTimespan.allCases) { timespan in

‎iOSClient/Supporting Files/en.lproj/Localizable.strings‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,5 +934,7 @@ You can stop it at any time, adjust the settings, and enable it again.";
934934
"_autoupload_whole_library_description_" = "Checks the entire selected library. Files already uploaded to %@ are skipped.";
935935
"_autoupload_from_date_" = "From a date";
936936
"_autoupload_start_date_" = "Upload starting from";
937+
"_autoupload_completed_until_" = "Upload completed up to";
938+
"_autoupload_waiting_for_uploads_" = "Waiting for the first uploads";
937939
"_autoupload_set_to_now_" = "Set to now";
938940
"_autoupload_date_range_footer_" = "Files already uploaded to %@ are skipped. The date advances through confirmed uploads and is preserved when auto upload is stopped.";

0 commit comments

Comments
 (0)