Skip to content

Commit

Permalink
refactor: Clean code (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne authored Dec 20, 2024
2 parents 3530d1c + 7341746 commit ca6a6d0
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ enum class FileType(val icon: ImageVector, private val colorLight: Color, privat
}

companion object {
//TODO Move this method into Core2
// TODO: Move this method into Core2
fun guessMimeTypeFromFileName(fileName: String): String? {
return fileName.extractExtension()?.let { extension ->
MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ android {
useSupportLibrary = true
}

//TODO: Remove preprod url when api is in prod
// TODO: Remove Preprod url when API is in Prod
val preprodHost = "swisstransfer.preprod.dev.infomaniak.ch"
val prodHost = "www.swisstransfer.com"
resValue("string", "preprod_host", preprodHost)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ private fun TextLayoutResult.getBoundingBoxesForRange(start: Int, end: Int): Lis
firstBoundingBoxRect = currentRect
}

// Check if we reached the end of the current bounding box (i.e. if we reached a new line or the last character in the range)
// Check if we reached the end of the current bounding box
// (i.e. if we reached a new line or the last character in the range)
if (previousRect != null && (areOnDifferentLines(previousRect, currentRect) || isLastCharacter)) {
val lastBoundingBoxRect = if (isLastCharacter) currentRect else previousRect
boundingBoxes.add(firstBoundingBoxRect.copy(right = lastBoundingBoxRect.right))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ fun TransferItem(
itemCount = files.count(),
maxLines = 1,
horizontalArrangement = Arrangement.spacedBy(Margin.Mini),
overflow = ContextualFlowRowOverflow.expandIndicator { TransferFilePreview(remainingFilesCount = totalItemCount - shownItemCount) },
overflow = ContextualFlowRowOverflow.expandIndicator {
TransferFilePreview(remainingFilesCount = totalItemCount - shownItemCount)
},
) { index ->
TransferFilePreview(file = files[index])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ sealed class MainNavigation : NavigationDestination() {
data class ReceivedDestination(val transferUuid: String? = null) : MainNavigation() {

companion object {
fun NavGraphBuilder.receivedDestination(
content: @Composable (AnimatedContentScope.(NavBackStackEntry) -> Unit),
) {
fun NavGraphBuilder.receivedDestination(content: @Composable (AnimatedContentScope.(NavBackStackEntry) -> Unit)) {
val preprodBasePath = "${BuildConfig.PREPROD_URL}/d/{${ReceivedDestination::transferUuid.name}}"
val prodBasePath = "${BuildConfig.PROD_URL}/d/${ReceivedDestination::transferUuid.name}"
val deepLinks = listOf(
Expand Down Expand Up @@ -99,10 +97,7 @@ sealed class NewTransferNavigation : NavigationDestination() {
@Serializable
data object ImportFilesDestination : NewTransferNavigation()
@Serializable
data object TransferTypeDestination : NewTransferNavigation()
@Serializable
data object ValidateUserEmailDestination : NewTransferNavigation()

@Serializable
data class UploadProgressDestination(val transferType: TransferTypeUi, val totalSize: Long) : NewTransferNavigation()
@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package com.infomaniak.swisstransfer.ui.screen.main.settings

import android.os.Build
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
Expand Down Expand Up @@ -48,7 +49,6 @@ import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.GetSetCallbacks
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows
import android.os.Build

@Composable
fun SettingsScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un
UploadSuccessScreen(
transferType = args.transferType,
transferUrl = args.transferUrl,
closeActivity = closeActivity
closeActivity = closeActivity,
)
}
composable<UploadErrorDestination> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ fun ImportFilesScreen(
resetSendActionResult = importFilesViewModel::resetSendActionResult,
)


LaunchedEffect(Unit) { importFilesViewModel.initTransferOptionsValues() }

val transferOptionsCallbacks = importFilesViewModel.getTransferOptionsCallbacks(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class UploadFileTask(
val totalChunks = fileChunkSizeManager.computeFileChunks(fileSize = uploadFileSession.size, fileChunkSize = chunkSize)
val parallelChunks = fileChunkSizeManager.computeParallelChunks(fileChunkSize = chunkSize)


SentryLog.d(TAG, "chunkSize:$chunkSize | totalChunks:$totalChunks | parallelChunks:$parallelChunks")

uploadFileSession.getLocalIoFile(uploadSession.uuid).inputStream().buffered().use { inputStream ->
Expand Down

0 comments on commit ca6a6d0

Please sign in to comment.