diff --git a/Core2/src/main/java/com/infomaniak/core2/FormatterFileSize.kt b/Core2/src/main/java/com/infomaniak/core2/FormatterFileSize.kt index 65dabb604..cc800d96d 100644 --- a/Core2/src/main/java/com/infomaniak/core2/FormatterFileSize.kt +++ b/Core2/src/main/java/com/infomaniak/core2/FormatterFileSize.kt @@ -96,6 +96,7 @@ object FormatterFileSize { isGroupingUsed = false // We do this only for DecimalFormat, since in the general NumberFormat case, // calling setRoundingMode may throw an exception. + @Suppress("DEPRECATION") if (this is DecimalFormat) setRoundingMode(BigDecimal.ROUND_HALF_UP) } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/TransferInfo.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/TransferInfo.kt index 44a80b6d7..34f11bb7c 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/TransferInfo.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/TransferInfo.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.screen.main.transferdetails.components -import android.text.format.Formatter import androidx.compose.foundation.layout.* import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon @@ -45,6 +44,7 @@ import com.infomaniak.swisstransfer.ui.previewparameter.TransferUiListPreviewPar import com.infomaniak.swisstransfer.ui.theme.Dimens import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.HumanReadableSizeUtils import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable @@ -65,7 +65,7 @@ fun TransferInfo(getTransfer: () -> TransferUi) { Spacer(Modifier.width(Margin.Mini)) TextDotText( firstText = { pluralStringResource(R.plurals.filesCount, filesCount, filesCount) }, - secondText = { Formatter.formatShortFileSize(LocalContext.current, sizeUploaded) }, + secondText = { HumanReadableSizeUtils.getHumanReadableSize(LocalContext.current, sizeUploaded) }, color = SwissTransferTheme.colors.primaryTextColor, ) } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportFilesViewModel.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportFilesViewModel.kt index ca2a72d18..64d566790 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportFilesViewModel.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportFilesViewModel.kt @@ -157,7 +157,7 @@ class ImportFilesViewModel @Inject constructor( message = _transferMessage, numberOfDownload = selectedDownloadLimitOption.value.apiValue, language = selectedLanguageOption.value.apiValue, - recipientsEmails = emptyList(), + recipientsEmails = emptySet(), files = importationFilesManager.importedFiles.value.mapToList { fileUi -> object : UploadFileSession { override val path: String? = null diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/ImportedFilesCard.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/ImportedFilesCard.kt index 342e53c9f..689b1a1e7 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/ImportedFilesCard.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/ImportedFilesCard.kt @@ -35,6 +35,7 @@ import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi +import com.infomaniak.multiplatform_swisstransfer.utils.FileUtils import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.SmallFileItem import com.infomaniak.swisstransfer.ui.components.SmallFileTileSize @@ -52,8 +53,6 @@ import com.infomaniak.swisstransfer.ui.utils.HumanReadableSizeUtils.getHumanRead import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark import kotlinx.parcelize.Parcelize -private const val TOTAL_FILE_SIZE: Long = 50_000_000_000L - @Composable fun ImportedFilesCard( modifier: Modifier = Modifier, @@ -67,7 +66,7 @@ fun ImportedFilesCard( val humanReadableSize by remember { derivedStateOf { val usedSpace = files().sumOf { it.fileSize } - val spaceLeft = (TOTAL_FILE_SIZE - usedSpace).coerceAtLeast(0) + val spaceLeft = (FileUtils.MAX_FILES_SIZE - usedSpace).coerceAtLeast(0) getHumanReadableSize(context, spaceLeft) } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/HumanReadableSizeUtils.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/HumanReadableSizeUtils.kt index 7a5e4f6d1..aa8ed885f 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/HumanReadableSizeUtils.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/HumanReadableSizeUtils.kt @@ -19,17 +19,15 @@ package com.infomaniak.swisstransfer.ui.utils import android.content.Context import android.icu.text.NumberFormat -import android.text.format.Formatter import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.pluralStringResource +import com.infomaniak.core2.FormatterFileSize.formatShortFileSize import com.infomaniak.swisstransfer.R object HumanReadableSizeUtils { - fun getHumanReadableSize(context: Context, sizeInBytes: Long): String { - return Formatter.formatShortFileSize(context, sizeInBytes) - } + fun getHumanReadableSize(context: Context, sizeInBytes: Long): String = context.formatShortFileSize(sizeInBytes) @Composable fun formatSpaceLeft(humanReadableSize: () -> String): String { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/workers/FileChunkSizeManager.kt b/app/src/main/java/com/infomaniak/swisstransfer/workers/FileChunkSizeManager.kt index ee71a9561..530e3f52b 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/workers/FileChunkSizeManager.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/workers/FileChunkSizeManager.kt @@ -64,8 +64,8 @@ class FileChunkSizeManager( class AllowedFileSizeExceededException : Exception() companion object { - private const val CHUNK_MIN_SIZE = 1L * 1024 * 1024 // 1Mo - private const val CHUNK_MAX_SIZE = 50L * 1024 * 1024 // 50Mo + private const val CHUNK_MIN_SIZE = 1L * 1_024 * 1_024 // 1 MB + private const val CHUNK_MAX_SIZE = 50L * 1_024 * 1_024 // 50 MB private const val OPTIMAL_TOTAL_CHUNKS = 200 private const val MAX_CHUNK_COUNT = 10_000 private const val MAX_PARALLEL_CHUNKS = 4 diff --git a/app/src/main/java/com/infomaniak/swisstransfer/workers/UploadWorker.kt b/app/src/main/java/com/infomaniak/swisstransfer/workers/UploadWorker.kt index 855c6236c..db0085152 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/workers/UploadWorker.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/workers/UploadWorker.kt @@ -24,6 +24,7 @@ import androidx.work.* import androidx.work.WorkInfo.State import com.infomaniak.multiplatform_swisstransfer.SharedApiUrlCreator import com.infomaniak.multiplatform_swisstransfer.managers.UploadManager +import com.infomaniak.multiplatform_swisstransfer.utils.FileUtils import com.infomaniak.sentry.SentryLog import com.infomaniak.swisstransfer.ui.screen.newtransfer.ImportLocalStorage import dagger.assisted.Assisted @@ -163,9 +164,8 @@ class UploadWorker @AssistedInject constructor( companion object { private const val TAG = "UploadWorker" - private const val EXPECTED_CHUNK_SIZE = 50L * 1024 * 1024 // 50Mo - private const val TOTAL_FILE_SIZE = 50L * 1024 * 1024 * 1024 // 50Go - private const val MAX_CHUNK_COUNT = (TOTAL_FILE_SIZE / EXPECTED_CHUNK_SIZE).toInt() + private const val EXPECTED_CHUNK_SIZE = 50L * 1_024 * 1_024 // 50 MB + private const val MAX_CHUNK_COUNT = (FileUtils.MAX_FILES_SIZE / EXPECTED_CHUNK_SIZE).toInt() private const val UPLOADED_BYTES_TAG = "uploaded_bytes_tag" private const val TRANSFER_UUID_TAG = "transfer_uuid_tag" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9e7aaa7db..79e8772f3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,7 +21,7 @@ qrose = "1.0.1" recaptcha = "18.6.1" sentry = "4.12.0" serialization = "1.7.3" -swisstransfer = "0.10.0" +swisstransfer = "0.10.1" workmanager = "2.10.0" [libraries]