Skip to content

Commit

Permalink
refactor: Handle TODO about missing String when transfer is expired
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Nov 7, 2024
1 parent 8632408 commit 9662068
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import com.infomaniak.core2.FORMAT_DATE_SIMPLE
import com.infomaniak.core2.FORMAT_DATE_TITLE
import com.infomaniak.core2.format
import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi
Expand All @@ -48,23 +47,15 @@ import java.util.UUID
fun TransferItem(transfer: TransferUi, onClick: () -> Unit) {

val createdDate = Date(transfer.createdDateTimestamp).format(FORMAT_DATE_TITLE)
val expirationDate = Date(transfer.expirationDateTimestamp)
val remainingDays = transfer.expiresInDays
val remainingDownloads = transfer.downloadLeft
val uploadedSize = HumanReadableSizeUtils.getHumanReadableSize(LocalContext.current, transfer.sizeUploaded)
val files = transfer.files
val filesCount = files.count()
val (expiryText, expiryColor) = when {
remainingDays < 0 -> {
stringResource(R.string.expiredThe, expirationDate.format(FORMAT_DATE_SIMPLE)) to
SwissTransferTheme.materialColors.error
}
remainingDownloads == 0 -> {
"Transfert expiré (TODO)" to SwissTransferTheme.materialColors.error
}
else -> {
stringResource(R.string.expiresIn, remainingDays) to SwissTransferTheme.colors.secondaryTextColor
}
val (expiryText, expiryColor) = if (remainingDays < 0 || remainingDownloads == 0) {
stringResource(R.string.transferExpired) to SwissTransferTheme.materialColors.error
} else {
stringResource(R.string.expiresIn, remainingDays) to SwissTransferTheme.colors.secondaryTextColor
}

Card(
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<string name="contentDescriptionButtonRemove">Datei entfernen</string>
<string name="contentDescriptionButtonShowPassword">Passwort anzeigen</string>
<string name="contentDescriptionCreateNewTransferButton">Neuer Transfer</string>
<string name="expiredThe">Abgelaufen am %s</string>
<string name="expiresIn">Verfällt in %d Tagen</string>
<plurals name="filesCount">
<item quantity="one">%d Datei</item>
Expand Down Expand Up @@ -88,6 +87,7 @@
<string name="snackbarLinkCopiedToClipboard">Link in die Zwischenablage kopiert</string>
<string name="startActivityCantHandleAction">Es wurde keine Anwendung gefunden, die diese Aktion bearbeitet</string>
<string name="textFieldOptional">(Fakultativ)</string>
<string name="transferExpired">Transfer abgelaufen</string>
<string name="transferExpiredButton">Aus dem Verlauf löschen</string>
<string name="transferExpiredDateReachedDescription">Tut mir leid, diese Übertragung ist am %s abgelaufen. Du kannst die Dateien nicht mehr herunterladen oder ansehen.</string>
<string name="transferExpiredLimitReachedDescription">Entschuldigung, diese Übertragung hat die Grenze der %d möglichen Downloads erreicht.</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<string name="contentDescriptionButtonRemove">Eliminar archivo</string>
<string name="contentDescriptionButtonShowPassword">Mostrar contraseña</string>
<string name="contentDescriptionCreateNewTransferButton">Nueva transferencia</string>
<string name="expiredThe">Expirado el %s</string>
<string name="expiresIn">Caduca en %d días</string>
<plurals name="filesCount">
<item quantity="one">%d archivo</item>
Expand Down Expand Up @@ -88,6 +87,7 @@
<string name="snackbarLinkCopiedToClipboard">Enlace copiado en el portapapeles</string>
<string name="startActivityCantHandleAction">No se ha encontrado ninguna aplicación que gestione esta acción</string>
<string name="textFieldOptional">(Opcional)</string>
<string name="transferExpired">Transferencia caducada</string>
<string name="transferExpiredButton">Borrar del historial</string>
<string name="transferExpiredDateReachedDescription">Lo sentimos, esta transferencia expiró el %s. Ya no puede descargar ni ver los archivos.</string>
<string name="transferExpiredLimitReachedDescription">Lo sentimos, esta transferencia ha alcanzado el límite de %d descargas posibles.</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<string name="contentDescriptionButtonRemove">Supprimer le fichier</string>
<string name="contentDescriptionButtonShowPassword">Afficher le mot de passe</string>
<string name="contentDescriptionCreateNewTransferButton">Nouveau transfert</string>
<string name="expiredThe">Expiré le %s</string>
<string name="expiresIn">Expire dans %d jours</string>
<plurals name="filesCount">
<item quantity="one">%d fichier</item>
Expand Down Expand Up @@ -89,6 +88,7 @@
<string name="snackbarLinkCopiedToClipboard">Lien copié dans le presse-papiers</string>
<string name="startActivityCantHandleAction">Aucune application n’a été trouvée pour gérer cette action</string>
<string name="textFieldOptional">(Facultatif)</string>
<string name="transferExpired">Transfert expiré</string>
<string name="transferExpiredButton">Supprimer de l’historique</string>
<string name="transferExpiredDateReachedDescription">Désolé, ce transfert a expiré le %s. Tu ne peux plus télécharger ni consulter les fichiers.</string>
<string name="transferExpiredLimitReachedDescription">Désolé, ce transfert a atteint la limite de %d téléchargements possibles.</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<string name="contentDescriptionButtonRemove">Rimuovi il file</string>
<string name="contentDescriptionButtonShowPassword">Mostra password</string>
<string name="contentDescriptionCreateNewTransferButton">Nuovo trasferimento</string>
<string name="expiredThe">Scaduto il %s</string>
<string name="expiresIn">Scade tra %d giorni</string>
<plurals name="filesCount">
<item quantity="one">%d file</item>
Expand Down Expand Up @@ -88,6 +87,7 @@
<string name="snackbarLinkCopiedToClipboard">Link copiato negli appunti</string>
<string name="startActivityCantHandleAction">Non è stata trovata alcuna applicazione in grado di gestire questa azione</string>
<string name="textFieldOptional">(Opzionale)</string>
<string name="transferExpired">Trasferimento scaduto</string>
<string name="transferExpiredButton">Cancellare dalla cronologia</string>
<string name="transferExpiredDateReachedDescription">Spiacente, questo trasferimento è scaduto il %s. Non è più possibile scaricare o visualizzare i file.</string>
<string name="transferExpiredLimitReachedDescription">Spiacente, questo trasferimento ha raggiunto il limite di %d download possibili.</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<string name="contentDescriptionButtonRemove">Remove file</string>
<string name="contentDescriptionButtonShowPassword">Show password</string>
<string name="contentDescriptionCreateNewTransferButton">New transfer</string>
<string name="expiredThe">Expired on %s</string>
<string name="expiresIn">Expires in %d days</string>
<plurals name="filesCount">
<item quantity="one">%d file</item>
Expand Down Expand Up @@ -93,6 +92,7 @@
<string name="snackbarLinkCopiedToClipboard">Link copied to clipboard</string>
<string name="startActivityCantHandleAction">No application has been found to handle this action</string>
<string name="textFieldOptional">(Optional)</string>
<string name="transferExpired">Transfer expired</string>
<string name="transferExpiredButton">Delete from history</string>
<string name="transferExpiredDateReachedDescription">Sorry, this transfer expired on %s. You can no longer download or view the files.</string>
<string name="transferExpiredLimitReachedDescription">Sorry, this transfer has reached the limit of %d possible downloads.</string>
Expand Down

0 comments on commit 9662068

Please sign in to comment.