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 9b62562a3..b46138a76 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 @@ -29,21 +29,13 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.style.TextOverflow 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.swisstransfer.ui.previewparameter.FileUiListPreviewParameter import com.infomaniak.swisstransfer.ui.theme.CustomShapes import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows -// TODO: Get the data class from the shared kmp code -data class FileUi( - val uid: String, - val fileName: String, - val fileSize: Long, - val mimeType: String?, - val localPath: String, -) - @Composable fun FileItem( file: FileUi, 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 cb596ec8e..b17f4cbc0 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 @@ -25,6 +25,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier 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.swisstransfer.ui.previewparameter.FileUiListPreviewParameter import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme 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 ce0eadc61..61a9f7eb4 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 @@ -36,6 +36,7 @@ import androidx.compose.ui.unit.Dp import coil.compose.AsyncImage import coil.request.ImageRequest import com.infomaniak.library.filetypes.FileType +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi import com.infomaniak.swisstransfer.ui.theme.LocalIsDarkMode import com.infomaniak.swisstransfer.ui.utils.fileType import com.infomaniak.swisstransfer.ui.utils.hasPreview @@ -47,9 +48,10 @@ fun FilePreview( circleSize: Dp, ) { var displayPreview by rememberSaveable { mutableStateOf(file.hasPreview) } + val previewUri = file.localPath - if (displayPreview) { - FileThumbnail(file.localPath, onError = { displayPreview = false }) + if (displayPreview && previewUri != null) { + FileThumbnail(previewUri, onError = { displayPreview = false }) } else { FileIcon(file.fileType, circleColor, circleSize) } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileItem.kt index 38421c248..9f378631a 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileItem.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileItem.kt @@ -30,6 +30,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.times +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi import com.infomaniak.swisstransfer.ui.previewparameter.FileUiListPreviewParameter import com.infomaniak.swisstransfer.ui.theme.CustomShapes import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme 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 3b2a48c1e..ed5152de1 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,7 +18,7 @@ package com.infomaniak.swisstransfer.ui.previewparameter import androidx.compose.ui.tooling.preview.PreviewParameterProvider -import com.infomaniak.swisstransfer.ui.components.FileUi +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi class FileUiListPreviewParameter : PreviewParameterProvider> { override val values: Sequence> = sequenceOf( 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 d68ca56bc..066c3655c 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 @@ -26,10 +26,10 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi 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.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 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 36300d53e..0b2f49302 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 @@ -21,8 +21,8 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi import com.infomaniak.swisstransfer.ui.components.FileItemList -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.PreviewAllWindows diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/FilesMutableStateFlow.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/FilesMutableStateFlow.kt index 1373c9ca7..10a37b719 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/FilesMutableStateFlow.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/FilesMutableStateFlow.kt @@ -17,7 +17,7 @@ */ package com.infomaniak.swisstransfer.ui.screen.newtransfer -import com.infomaniak.swisstransfer.ui.components.FileUi +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.sync.Mutex diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportationFilesManager.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportationFilesManager.kt index 07b70bb27..d51755307 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportationFilesManager.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportationFilesManager.kt @@ -23,8 +23,8 @@ import android.database.Cursor import android.net.Uri import android.provider.OpenableColumns import androidx.core.net.toUri +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi import com.infomaniak.sentry.SentryLog -import com.infomaniak.swisstransfer.ui.components.FileUi import com.infomaniak.swisstransfer.ui.utils.FileNameUtils import dagger.hilt.android.qualifiers.ApplicationContext import io.sentry.Sentry 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 90d41e36b..7aea6d63a 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 @@ -32,6 +32,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.* import com.infomaniak.swisstransfer.ui.previewparameter.FileUiListPreviewParameter 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 0d1ec92da..f8782635d 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 @@ -32,6 +32,7 @@ import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.tooling.preview.Preview 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.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.* import com.infomaniak.swisstransfer.ui.images.AppImages 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 82bcd098e..1ae514a8e 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,7 +18,7 @@ package com.infomaniak.swisstransfer.ui.utils import com.infomaniak.library.filetypes.FileType -import com.infomaniak.swisstransfer.ui.components.FileUi +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi val FileUi.fileType: FileType get() = mimeType?.let { FileType.guessFromMimeType(it) } ?: FileType.guessFromFileName(fileName)