Fix background uploads and redesign cloud UI
Android / test-and-build (push) Canceled after 18m0s

This commit is contained in:
Курнат Андрей
2026-07-16 18:29:05 +03:00
parent dd21285700
commit fceac09264
80 changed files with 4652 additions and 606 deletions
@@ -29,5 +29,10 @@ interface FolderBackupRepository {
fun saveFolderBackupConfiguration(folderBackUpConfiguration: FolderBackUpConfiguration)
fun updateLastSyncTimestamp(
expectedConfiguration: FolderBackUpConfiguration,
lastSyncTimestamp: Long,
): Boolean
fun resetFolderBackupConfigurationByName(name: String)
}
@@ -22,10 +22,10 @@ data class AutomaticUploadsConfiguration(
val pictureUploadsConfiguration: FolderBackUpConfiguration?,
val videoUploadsConfiguration: FolderBackUpConfiguration?
) {
fun areAutomaticUploadsDisabled() = pictureUploadsConfiguration == null && videoUploadsConfiguration == null
val sourcePaths: List<String>
get() = listOfNotNull(pictureUploadsConfiguration, videoUploadsConfiguration)
.flatMap { it.sourcePaths }
.distinct()
fun areAutomaticUploadsDisabled() = pictureUploadsConfiguration == null && videoUploadsConfiguration == null
}
@@ -33,18 +33,21 @@ data class FolderBackUpConfiguration(
val isPictureUploads get() = name == pictureUploadsName
val isVideoUploads get() = name == videoUploadsName
val isAutomaticUploads get() = isPictureUploads || isVideoUploads
val sourcePaths get() = parseSourcePaths(sourcePath)
/**
* Picture uploads are an ingest operation: the source is removed only after
* the upload worker has completed successfully. Video uploads keep their
* explicitly configured behavior.
* Automatic uploads are an ingest operation: the source is removed only after
* the upload worker has completed successfully. Legacy COPY and charging-only
* settings are ignored even before the user opens the redesigned settings screen.
*/
val effectiveBehavior get() = if (isPictureUploads) UploadBehavior.MOVE else behavior
val effectiveBehavior get() = if (isAutomaticUploads) UploadBehavior.MOVE else behavior
val effectiveChargingOnly get() = if (isAutomaticUploads) false else chargingOnly
companion object {
const val pictureUploadsName = "Picture uploads"
const val videoUploadsName = "Video uploads"
private const val SOURCE_PATH_SEPARATOR = "\n"
fun parseSourcePaths(sourcePath: String): List<String> =
sourcePath
@@ -60,7 +63,6 @@ data class FolderBackUpConfiguration(
.distinct()
.joinToString(SOURCE_PATH_SEPARATOR)
private const val SOURCE_PATH_SEPARATOR = "\n"
}
}
@@ -71,25 +71,43 @@ class FolderBackUpConfigurationTest {
}
@Test
fun `video uploads preserve configured behavior`() {
fun `video uploads always remove source after successful upload`() {
val configuration = folderBackUpConfiguration(
name = FolderBackUpConfiguration.videoUploadsName,
behavior = UploadBehavior.COPY,
)
assertEquals(UploadBehavior.COPY, configuration.effectiveBehavior)
assertEquals(UploadBehavior.MOVE, configuration.effectiveBehavior)
}
@Test
fun `automatic uploads ignore legacy charging only setting`() {
val pictureConfiguration = folderBackUpConfiguration(
name = FolderBackUpConfiguration.pictureUploadsName,
behavior = UploadBehavior.COPY,
chargingOnly = true,
)
val videoConfiguration = folderBackUpConfiguration(
name = FolderBackUpConfiguration.videoUploadsName,
behavior = UploadBehavior.COPY,
chargingOnly = true,
)
assertEquals(false, pictureConfiguration.effectiveChargingOnly)
assertEquals(false, videoConfiguration.effectiveChargingOnly)
}
private fun folderBackUpConfiguration(
name: String,
behavior: UploadBehavior,
chargingOnly: Boolean = false,
) = FolderBackUpConfiguration(
accountName = "account",
behavior = behavior,
sourcePath = "content://source",
uploadPath = "/CameraUpload",
wifiOnly = false,
chargingOnly = false,
chargingOnly = chargingOnly,
lastSyncTimestamp = 0,
name = name,
spaceId = null,