diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt index 2226dbfc8f..d915fc5609 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt @@ -37,7 +37,7 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow // TODO: Get the data class from the shared kmp code -data class FileUiItem( +data class FileUi( val uid: String, val fileName: String, val fileSizeInBytes: Long, @@ -47,7 +47,7 @@ data class FileUiItem( @Composable fun FileItem( - file: FileUiItem, + file: FileUi, isRemoveButtonVisible: Boolean, isCheckboxVisible: Boolean, isChecked: () -> Boolean = { false }, @@ -133,7 +133,7 @@ private fun FileItemContent( @PreviewSmallWindow @PreviewLargeWindow @Composable -private fun FileItemPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { +private fun FileItemPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { Surface { Column( diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt index 9917627047..60b38c5139 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt @@ -34,7 +34,7 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow @Composable fun FileItemList( modifier: Modifier = Modifier, - files: List, + files: List, isRemoveButtonVisible: Boolean, isCheckboxVisible: Boolean, isUidChecked: (String) -> Boolean, @@ -63,7 +63,7 @@ fun FileItemList( @PreviewSmallWindow @PreviewLargeWindow @Composable -private fun FileItemListPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { +private fun FileItemListPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { FileItemList( files = files, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FilePreview.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FilePreview.kt index 3040a4b0ca..e83e17fa7b 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FilePreview.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FilePreview.kt @@ -42,7 +42,7 @@ import com.infomaniak.swisstransfer.ui.utils.hasPreview @Composable fun FilePreview( - file: FileUiItem, + file: FileUi, circleColor: Color, circleSize: Dp, ) { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileTile.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileTile.kt index 5418982087..11733b5d74 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileTile.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileTile.kt @@ -37,7 +37,7 @@ import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme @Composable fun SmallFileTile( modifier: Modifier = Modifier, - file: FileUiItem, + file: FileUi, smallFileTileSize: SmallFileTileSize, onRemove: (() -> Unit)? = null, ) { @@ -67,7 +67,7 @@ enum class SmallFileTileSize(val size: Dp, val shape: Shape) { @Preview(name = "Light") @Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) @Composable -private fun SmallFileTilePreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { +private fun SmallFileTilePreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { Surface(color = SwissTransferTheme.materialColors.surfaceContainerHighest) { Column(Modifier.padding(16.dp)) { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/previewparameter/FileUiListPreviewParameterProvider.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/previewparameter/FileUiListPreviewParameterProvider.kt index d731a27cd3..f04da36a5c 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/previewparameter/FileUiListPreviewParameterProvider.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/previewparameter/FileUiListPreviewParameterProvider.kt @@ -18,26 +18,26 @@ package com.infomaniak.swisstransfer.ui.previewparameter import androidx.compose.ui.tooling.preview.PreviewParameterProvider -import com.infomaniak.swisstransfer.ui.components.FileUiItem +import com.infomaniak.swisstransfer.ui.components.FileUi -class FileUiListPreviewParameter : PreviewParameterProvider> { - override val values: Sequence> = sequenceOf( +class FileUiListPreviewParameter : PreviewParameterProvider> { + override val values: Sequence> = sequenceOf( listOf( - FileUiItem( + FileUi( fileName = "How to not get fired.pdf", uid = "How to not get fired.pdf", fileSizeInBytes = 10302130, mimeType = null, uri = "", ), - FileUiItem( + FileUi( fileName = "Opening images tutorial.png", uid = "Opening images tutorial.png", fileSizeInBytes = 456782, mimeType = null, uri = "https://picsum.photos/200/300", ), - FileUiItem( + FileUi( fileName = "The 5 step guide to turning it off and on again.docx", uid = "The 5 step guide to turning it off and on again.docx", fileSizeInBytes = 89723143, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt index ed9808204a..b93d2965e1 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt @@ -29,7 +29,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.EmptyState import com.infomaniak.swisstransfer.ui.components.FileItemList -import com.infomaniak.swisstransfer.ui.components.FileUiItem +import com.infomaniak.swisstransfer.ui.components.FileUi import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus import com.infomaniak.swisstransfer.ui.images.illus.MascotSearching import com.infomaniak.swisstransfer.ui.screen.main.components.BrandTopAppBarScaffold @@ -73,21 +73,21 @@ private fun ReceivedScreen( ) } else { val files = listOf( - FileUiItem( + FileUi( fileName = "The 5-Step Guide to Not Breaking Your Code.txt", uid = "The 5-Step Guide to Not Breaking Your Code.txt", fileSizeInBytes = 57689032, mimeType = null, uri = "", ), - FileUiItem( + FileUi( fileName = "Introduction to Turning It Off and On Again.pptx", uid = "Introduction to Turning It Off and On Again.pptx", fileSizeInBytes = 89723143, mimeType = null, uri = "", ), - FileUiItem( + FileUi( fileName = "Learning to Copy and Paste: A Complete Guide.docx", uid = "Learning to Copy and Paste: A Complete Guide.docx", fileSizeInBytes = 237866728, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt index d46b31297d..2ae862e252 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt @@ -22,7 +22,7 @@ import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.infomaniak.swisstransfer.ui.components.FileItemList -import com.infomaniak.swisstransfer.ui.components.FileUiItem +import com.infomaniak.swisstransfer.ui.components.FileUi import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow @@ -31,21 +31,21 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow @Composable fun SentListScreen(transfers: List) { val transfers = listOf( - FileUiItem( + FileUi( fileName = "The 5-Step Guide to Not Breaking Your Code.txt", uid = "The 5-Step Guide to Not Breaking Your Code.txt", fileSizeInBytes = 57689032, mimeType = null, uri = "", ), - FileUiItem( + FileUi( fileName = "Introduction to Turning It Off and On Again.pptx", uid = "Introduction to Turning It Off and On Again.pptx", fileSizeInBytes = 89723143, mimeType = null, uri = "", ), - FileUiItem( + FileUi( fileName = "Learning to Copy and Paste: A Complete Guide.docx", uid = "Learning to Copy and Paste: A Complete Guide.docx", fileSizeInBytes = 237866728, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferViewModel.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferViewModel.kt index 01029191c2..4696748f65 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferViewModel.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferViewModel.kt @@ -20,7 +20,7 @@ package com.infomaniak.swisstransfer.ui.screen.newtransfer import android.net.Uri import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.infomaniak.swisstransfer.ui.components.FileUiItem +import com.infomaniak.swisstransfer.ui.components.FileUi import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -32,8 +32,8 @@ import javax.inject.Inject @HiltViewModel class NewTransferViewModel @Inject constructor(private val transferFilesManager: TransferFilesManager) : ViewModel() { - private val _files = MutableStateFlow>(emptyList()) - val files: StateFlow> = _files + private val _files = MutableStateFlow>(emptyList()) + val files: StateFlow> = _files private val _failedFileCount = MutableSharedFlow() val failedFileCount: SharedFlow = _failedFileCount diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/TransferFilesManager.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/TransferFilesManager.kt index 72a463e932..729af2e5b5 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/TransferFilesManager.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/TransferFilesManager.kt @@ -22,7 +22,7 @@ import android.content.Context import android.database.Cursor import android.net.Uri import android.provider.OpenableColumns -import com.infomaniak.swisstransfer.ui.components.FileUiItem +import com.infomaniak.swisstransfer.ui.components.FileUi import com.infomaniak.swisstransfer.ui.utils.FileNameUtils import dagger.hilt.android.qualifiers.ApplicationContext import javax.inject.Inject @@ -30,9 +30,9 @@ import javax.inject.Singleton @Singleton class TransferFilesManager @Inject constructor(@ApplicationContext private val appContext: Context) { - fun getFiles(uris: List, alreadyUsedFileNames: Set): MutableSet { + fun getFiles(uris: List, alreadyUsedFileNames: Set): MutableSet { val currentUsedFileNames = alreadyUsedFileNames.toMutableSet() - val files = mutableSetOf() + val files = mutableSetOf() uris.forEach { uri -> getFile(uri, currentUsedFileNames)?.let { file -> @@ -44,13 +44,13 @@ class TransferFilesManager @Inject constructor(@ApplicationContext private val a return files } - private fun getFile(uri: Uri, alreadyUsedFileNames: Set): FileUiItem? { + private fun getFile(uri: Uri, alreadyUsedFileNames: Set): FileUi? { val contentResolver: ContentResolver = appContext.contentResolver val cursor: Cursor? = contentResolver.query(uri, null, null, null, null) return cursor?.getFileNameAndSize()?.let { (name, size) -> val uniqueName = FileNameUtils.postfixExistingFileNames(name, alreadyUsedFileNames) - FileUiItem(fileName = uniqueName, uid = uniqueName, fileSizeInBytes = size, mimeType = null, uri = uri.toString()) + FileUi(fileName = uniqueName, uid = uniqueName, fileSizeInBytes = size, mimeType = null, uri = uri.toString()) } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt index 9828a4dbae..03beaf964c 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt @@ -52,7 +52,7 @@ fun ImportFilesScreen( @Composable private fun ImportFilesScreen( - files: () -> List, + files: () -> List, removeFileByUid: (uid: String) -> Unit, addFiles: (List) -> Unit, closeActivity: () -> Unit, @@ -116,7 +116,7 @@ private fun getFormattedSizeWithUnits(usedSpace: Long, context: Context): String @PreviewSmallWindow @PreviewLargeWindow @Composable -private fun ImportFilesScreenPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { +private fun ImportFilesScreenPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { ImportFilesScreen({ files }, {}, {}, closeActivity = {}) } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/SelectedFilesCard.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/SelectedFilesCard.kt index 757778269c..314f671999 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/SelectedFilesCard.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/SelectedFilesCard.kt @@ -52,7 +52,7 @@ import kotlinx.parcelize.Parcelize @Composable fun SelectedFilesCard( modifier: Modifier = Modifier, - files: () -> List, + files: () -> List, formattedSizeWithUnits: () -> String, showUploadSourceChoiceBottomSheet: () -> Unit, removeFileByUid: (uid: String) -> Unit, @@ -163,7 +163,7 @@ private data class TransferLazyRowKey( @Preview(name = "Light") @Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) @Composable -private fun SelectedFilesCardPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { +private fun SelectedFilesCardPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { SelectedFilesCard( modifier = Modifier.padding(Margin.Medium), diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/FileUiItemExt.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/FileUiItemExt.kt index e78f6ccb3b..82bcd098ee 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/FileUiItemExt.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/FileUiItemExt.kt @@ -18,8 +18,8 @@ package com.infomaniak.swisstransfer.ui.utils import com.infomaniak.library.filetypes.FileType -import com.infomaniak.swisstransfer.ui.components.FileUiItem +import com.infomaniak.swisstransfer.ui.components.FileUi -val FileUiItem.fileType: FileType get() = mimeType?.let { FileType.guessFromMimeType(it) } ?: FileType.guessFromFileName(fileName) +val FileUi.fileType: FileType get() = mimeType?.let { FileType.guessFromMimeType(it) } ?: FileType.guessFromFileName(fileName) -val FileUiItem.hasPreview: Boolean get() = fileType == FileType.IMAGE +val FileUi.hasPreview: Boolean get() = fileType == FileType.IMAGE