From 16b9d365101b11a7c438658a4a2308239d5e9cce Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Wed, 27 Nov 2024 12:27:36 +0100 Subject: [PATCH] refactor: Clean code --- .../library/filetypes/icons/Points.kt | 2 -- .../library/filetypes/icons/Video.kt | 2 -- .../swisstransfer/ui/LaunchActivity.kt | 2 -- .../swisstransfer/ui/images/icons/Bell.kt | 8 ++++---- .../FileUiListPreviewParameterProvider.kt | 18 +++++++++--------- .../newtransfer/ImportationFilesManager.kt | 4 ++-- .../newtransfer/upload/UploadProgressScreen.kt | 2 +- 7 files changed, 16 insertions(+), 22 deletions(-) diff --git a/FileTypes/src/main/java/com/infomaniak/library/filetypes/icons/Points.kt b/FileTypes/src/main/java/com/infomaniak/library/filetypes/icons/Points.kt index d3597354e..aada416bd 100644 --- a/FileTypes/src/main/java/com/infomaniak/library/filetypes/icons/Points.kt +++ b/FileTypes/src/main/java/com/infomaniak/library/filetypes/icons/Points.kt @@ -8,8 +8,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.PathFillType.Companion.NonZero import androidx.compose.ui.graphics.SolidColor -import androidx.compose.ui.graphics.StrokeCap.Companion.Butt -import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector.Builder import androidx.compose.ui.graphics.vector.path diff --git a/FileTypes/src/main/java/com/infomaniak/library/filetypes/icons/Video.kt b/FileTypes/src/main/java/com/infomaniak/library/filetypes/icons/Video.kt index 5f057830a..eaf8aef26 100644 --- a/FileTypes/src/main/java/com/infomaniak/library/filetypes/icons/Video.kt +++ b/FileTypes/src/main/java/com/infomaniak/library/filetypes/icons/Video.kt @@ -8,8 +8,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.PathFillType.Companion.NonZero import androidx.compose.ui.graphics.SolidColor -import androidx.compose.ui.graphics.StrokeCap.Companion.Butt -import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector.Builder import androidx.compose.ui.graphics.vector.path diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/LaunchActivity.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/LaunchActivity.kt index bfb0af411..83d7dfd2c 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/LaunchActivity.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/LaunchActivity.kt @@ -24,8 +24,6 @@ import androidx.activity.ComponentActivity import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import com.infomaniak.swisstransfer.ui.utils.AccountUtils import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.launch import javax.inject.Inject @AndroidEntryPoint diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/Bell.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/Bell.kt index 6ed385a12..6480b9bf6 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/Bell.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/Bell.kt @@ -38,9 +38,9 @@ import androidx.compose.ui.graphics.StrokeJoin.Companion.Round as strokeJoinRoun val AppIcons.Bell: ImageVector get() { - if (_notificationBell != null) return _notificationBell!! + if (_bell != null) return _bell!! - _notificationBell = Builder( + _bell = Builder( name = "Bell", defaultWidth = 24.0.dp, defaultHeight = 24.0.dp, @@ -72,10 +72,10 @@ val AppIcons.Bell: ImageVector } }.build() - return _notificationBell!! + return _bell!! } -private var _notificationBell: ImageVector? = null +private var _bell: ImageVector? = null @Preview @Composable 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 c9165df0e..889f48a26 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 @@ -28,52 +28,52 @@ class FileUiListPreviewParameter : PreviewParameterProvider> { val filesPreviewData = listOf( FileUi( // Non-preview file (i.e. pdf, txt, etc.) - fileName = "How to not get fired.pdf", uid = "How to not get fired.pdf", + fileName = "How to not get fired.pdf", + isFolder = false, fileSize = 10_302_130L, mimeType = null, localPath = "", - isFolder = false, ), FileUi( // Preview file (i.e. png, jpg, etc.) - fileName = "Opening images tutorial.png", uid = "Opening images tutorial.png", + fileName = "Opening images tutorial.png", + isFolder = false, fileSize = 456_782L, mimeType = null, localPath = "https://picsum.photos/200/300", - isFolder = false, ), 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", + fileName = "The 5 step guide to turning it off and on again.docx", + isFolder = false, fileSize = 89_723_143L, mimeType = null, localPath = "", - isFolder = false, ), FileUi( uid = UUID.randomUUID().toString(), fileName = "Learning to Copy and Paste: A Complete Guide.docx", + isFolder = false, fileSize = 237_866_728L, mimeType = null, localPath = null, - isFolder = false, ), FileUi( uid = UUID.randomUUID().toString(), fileName = "Introduction to Turning It Off and On Again.pptx", + isFolder = false, fileSize = 98_723_143L, mimeType = null, localPath = null, - isFolder = false, ), FileUi( uid = UUID.randomUUID().toString(), fileName = "The 5-Step Guide to Not Breaking Your Code.txt", + isFolder = false, fileSize = 57_689_032L, mimeType = null, localPath = null, - isFolder = false, ), ) 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 22d115628..8bfcc0c20 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 @@ -103,10 +103,10 @@ class ImportationFilesManager @Inject constructor( FileUi( uid = fileToImport.fileName, fileName = fileToImport.fileName, + isFolder = false, fileSize = fileToImport.fileSizeInBytes, mimeType = FileType.guessMimeTypeFromFileName(fileToImport.fileName), localPath = copiedFile.toUri().toString(), - isFolder = false, ) ) } @@ -134,10 +134,10 @@ class ImportationFilesManager @Inject constructor( FileUi( uid = localFile.name, fileName = localFile.name, + isFolder = false, fileSize = fileSizeInBytes, mimeType = null, localPath = localFile.toUri().toString(), - isFolder = false, ) } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadProgressScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadProgressScreen.kt index 30e739b92..59629e4e3 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadProgressScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadProgressScreen.kt @@ -187,7 +187,7 @@ private fun UploadProgressScreenPreview() { totalSizeInBytes = 76_321_894L, adScreenType = UploadProgressAdType.INDEPENDENCE, onCancel = {}, - showBottomSheet = GetSetCallbacks(get = { false }, set = { }), + showBottomSheet = GetSetCallbacks(get = { false }, set = {}), ) } }