From 574cc12177feeba80459c9cab5548c69e5389337 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Tue, 12 Nov 2024 15:43:30 +0100 Subject: [PATCH] refactor: Rename `transferLink` into `transferUrl` --- .../swisstransfer/ui/components/QrCode.kt | 6 +++--- .../ui/navigation/NavigationDestination.kt | 2 +- .../main/transferdetails/TransferDetailsScreen.kt | 14 ++++++++------ .../ui/screen/newtransfer/NewTransferNavHost.kt | 6 +++--- .../newtransfer/upload/UploadProgressScreen.kt | 2 +- .../newtransfer/upload/UploadSuccessQrScreen.kt | 14 +++++++------- .../newtransfer/upload/UploadSuccessScreen.kt | 6 +++--- .../swisstransfer/workers/UploadWorker.kt | 4 ++-- 8 files changed, 28 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/QrCode.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/QrCode.kt index c0226afe8..5b7070d50 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/QrCode.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/QrCode.kt @@ -35,12 +35,12 @@ import io.github.alexzhirkevich.qrose.options.solid import io.github.alexzhirkevich.qrose.rememberQrCodePainter @Composable -fun QrCode(transferLink: String) { +fun QrCode(transferUrl: String) { val centralIcon = rememberVectorPainter(AppIcons.QrInfomaniak.image()) val darkPixelsColor = QrBrush.solid(SwissTransferTheme.colors.qrCodeDarkPixels) val lightPixelsColor = QrBrush.solid(SwissTransferTheme.colors.qrCodeLightPixels) - val painter = rememberQrCodePainter(transferLink) { + val painter = rememberQrCodePainter(transferUrl) { colors { dark = darkPixelsColor light = lightPixelsColor @@ -65,7 +65,7 @@ fun QrCode(transferLink: String) { private fun QrCodePreview() { SwissTransferTheme { Surface { - QrCode(transferLink = "https://chk.me/83azQOl") + QrCode(transferUrl = "https://chk.me/83azQOl") } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationDestination.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationDestination.kt index 8fe1226e3..4d6ff6e40 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationDestination.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationDestination.kt @@ -62,7 +62,7 @@ sealed class NewTransferNavigation : NavigationDestination() { @Serializable data class UploadProgressDestination(val transferType: TransferType, val totalSize: Long) : NewTransferNavigation() @Serializable - data class UploadSuccessDestination(val transferType: TransferType, val transferLink: String) : NewTransferNavigation() + data class UploadSuccessDestination(val transferType: TransferType, val transferUrl: String) : NewTransferNavigation() @Serializable data object UploadErrorDestination : NewTransferNavigation() diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsScreen.kt index 9df5404c9..145393218 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsScreen.kt @@ -17,18 +17,19 @@ */ package com.infomaniak.swisstransfer.ui.screen.main.transferdetails -import android.text.format.Formatter import androidx.annotation.StringRes import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.material3.* -import androidx.compose.runtime.* +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel @@ -38,7 +39,8 @@ import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferU import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.* import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons -import com.infomaniak.swisstransfer.ui.images.icons.* +import com.infomaniak.swisstransfer.ui.images.icons.ArrowDownBar +import com.infomaniak.swisstransfer.ui.images.icons.Share import com.infomaniak.swisstransfer.ui.previewparameter.transfersPreviewData import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.components.TransferInfo @@ -57,7 +59,7 @@ fun TransferDetailsScreen( val transfer = transfersPreviewData.first() // TODO: Use real data val transferSenderEmail: String? = "john.smith@ik.me" // TODO - val transferLink = "https://chk.me/83azQOl" // TODO + val transferUrl = "https://chk.me/83azQOl" // TODO var isMultiselectOn: Boolean by rememberSaveable { mutableStateOf(false) } val context = LocalContext.current @@ -96,7 +98,7 @@ fun TransferDetailsScreen( isMultiselectOn = { isMultiselectOn }, onClick = { item -> when (item) { - BottomBarItem.SHARE -> context.shareText(transferLink) + BottomBarItem.SHARE -> context.shareText(transferUrl) BottomBarItem.DOWNLOAD -> { // TODO: Move the multiselect elsewhere, and implement this feature isMultiselectOn = true diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferNavHost.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferNavHost.kt index a2451dfd2..119fcfa3b 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferNavHost.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferNavHost.kt @@ -49,8 +49,8 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un val args = it.toRoute() UploadProgressScreen( totalSizeInBytes = args.totalSize, - navigateToUploadSuccess = { transferLink -> - navController.navigate(UploadSuccessDestination(args.transferType, transferLink)) + navigateToUploadSuccess = { transferUrl -> + navController.navigate(UploadSuccessDestination(args.transferType, transferUrl)) }, navigateToUploadError = { navController.navigate(UploadErrorDestination) }, closeActivity = closeActivity @@ -60,7 +60,7 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un val args = it.toRoute() UploadSuccessScreen( transferType = args.transferType, - transferLink = args.transferLink, + transferUrl = args.transferUrl, closeActivity = closeActivity ) } 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 81abd69f5..e3b4f8cd8 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 @@ -87,7 +87,7 @@ private fun HandleProgressState( val currentUiState = uiState() LaunchedEffect(uiState()) { when (currentUiState) { - is UploadProgressUiState.Success -> navigateToUploadSuccess(currentUiState.transferLink) + is UploadProgressUiState.Success -> navigateToUploadSuccess(currentUiState.transferUrl) is UploadProgressUiState.Cancelled -> navigateToUploadError() else -> Unit } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessQrScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessQrScreen.kt index d2395f5fc..48b3ab30e 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessQrScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessQrScreen.kt @@ -50,7 +50,7 @@ import com.infomaniak.swisstransfer.ui.utils.shareText import kotlinx.coroutines.launch @Composable -fun UploadSuccessQrScreen(transferType: TransferType, transferLink: String, closeActivity: () -> Unit) { +fun UploadSuccessQrScreen(transferType: TransferType, transferUrl: String, closeActivity: () -> Unit) { val context = LocalContext.current val snackbarHostState = remember { SnackbarHostState() } @@ -64,7 +64,7 @@ fun UploadSuccessQrScreen(transferType: TransferType, transferLink: String, clos style = ButtonType.PRIMARY, titleRes = R.string.buttonShare, imageVector = AppIcons.PersonBadgeShare, - onClick = { context.shareText(transferLink) }, + onClick = { context.shareText(transferUrl) }, ) }, bottomButton = { @@ -75,12 +75,12 @@ fun UploadSuccessQrScreen(transferType: TransferType, transferLink: String, clos onClick = closeActivity, ) }, - content = { Content(context, snackbarHostState, transferType, transferLink) }, + content = { Content(context, snackbarHostState, transferType, transferUrl) }, ) } @Composable -private fun Content(context: Context, snackbarHostState: SnackbarHostState, transferType: TransferType, transferLink: String) { +private fun Content(context: Context, snackbarHostState: SnackbarHostState, transferType: TransferType, transferUrl: String) { val scope = rememberCoroutineScope() @@ -108,7 +108,7 @@ private fun Content(context: Context, snackbarHostState: SnackbarHostState, tran Spacer(Modifier.height(Margin.Huge)) - QrCode(transferLink) + QrCode(transferUrl) transferType.descriptionRes?.let { descriptionRes -> Spacer(Modifier.height(Margin.Huge)) @@ -130,7 +130,7 @@ private fun Content(context: Context, snackbarHostState: SnackbarHostState, tran imageVector = AppIcons.DocumentOnDocument, onClick = { context.copyText( - text = transferLink, + text = transferUrl, showSnackbar = { scope.launch { snackbarHostState.showSnackbar(it) } }, ) }, @@ -144,7 +144,7 @@ private fun UploadSuccessQrScreenPreview() { Surface { UploadSuccessQrScreen( transferType = TransferType.LINK, - transferLink = "https://chk.me/83azQOl", + transferUrl = "https://chk.me/83azQOl", closeActivity = {} ) } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessScreen.kt index 4562e7acf..54d498050 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessScreen.kt @@ -27,7 +27,7 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun UploadSuccessScreen( transferType: TransferType, - transferLink: String, + transferUrl: String, closeActivity: () -> Unit, ) { BackHandler(onBack = closeActivity) @@ -35,7 +35,7 @@ fun UploadSuccessScreen( if (transferType == TransferType.MAIL) { UploadSuccessEmailScreen(closeActivity = closeActivity) } else { - UploadSuccessQrScreen(transferType, transferLink, closeActivity) + UploadSuccessQrScreen(transferType, transferUrl, closeActivity) } } @@ -46,7 +46,7 @@ private fun UploadSuccessScreenPreview() { Surface { UploadSuccessScreen( transferType = TransferType.QR_CODE, - transferLink = "https://chk.me/83azQOl", + transferUrl = "https://chk.me/83azQOl", closeActivity = {} ) } 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 c0c5eb246..7bdd720e4 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/workers/UploadWorker.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/workers/UploadWorker.kt @@ -143,12 +143,12 @@ class UploadWorker @AssistedInject constructor( } @Immutable - data class Success(override val uploadedSize: Long, val transferLink: String) : UploadProgressUiState(uploadedSize) { + data class Success(override val uploadedSize: Long, val transferUrl: String) : UploadProgressUiState(uploadedSize) { companion object { fun create(outputData: Data, sharedApiUrlCreator: SharedApiUrlCreator): Success? { return Success( uploadedSize = outputData.getLong(UPLOADED_BYTES_TAG, 0L), - transferLink = outputData.getString(TRANSFER_UUID_TAG) + transferUrl = outputData.getString(TRANSFER_UUID_TAG) ?.let { transferUuid -> sharedApiUrlCreator.shareTransferUrl(transferUuid) } ?: return null ) }