Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fun TransferItem(
Column(modifier = Modifier.weight(1.0f)) {

Text(
text = createdDate,
text = transfer.title ?: createdDate,
style = SwissTransferTheme.typography.bodyMedium,
color = SwissTransferTheme.colors.primaryTextColor,
maxLines = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ val transfersPreviewData = listOf(
sizeUploaded = 237_866_728L,
downloadLimit = 250,
downloadLeft = 123,
title = "Transfer title",
message = "3ème transfert. RAS.",
password = "my password",
files = filesPreviewData,
Expand All @@ -56,6 +57,7 @@ val transfersPreviewData = listOf(
sizeUploaded = 237_866_728L,
downloadLimit = 250,
downloadLeft = 123,
title = null,
message = null,
password = "my password",
files = filesPreviewData,
Expand All @@ -69,6 +71,7 @@ val transfersPreviewData = listOf(
sizeUploaded = 89_723_143L,
downloadLimit = 20,
downloadLeft = 0,
title = null,
message = null,
password = null,
files = filesPreviewData,
Expand All @@ -82,6 +85,7 @@ val transfersPreviewData = listOf(
sizeUploaded = 57_689_032L,
downloadLimit = 1,
downloadLeft = 1,
title = null,
message = "Coucou c'est moi le message de description du transfert.",
password = "password",
files = filesPreviewData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,12 @@ private fun TransferDetailsScreen(
}
}

val title = getTransfer().title ?: getTransfer().createdDateTimestamp.toDateFromSeconds().format(FORMAT_DATE_FULL)

SwissTransferScaffold(
topBar = {
SwissTransferTopAppBar(
title = getTransfer().createdDateTimestamp.toDateFromSeconds().format(FORMAT_DATE_FULL),
title = title,
navigationIcon = { if (windowAdaptiveInfo.isWindowSmall()) TopAppBarButtons.Back(onClick = navigateBack ?: {}) },
actions = {
when (direction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
Expand All @@ -56,13 +57,14 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.PermissionState
import com.google.accompanist.permissions.rememberPermissionState
import com.infomaniak.core.common.mapSync
import com.infomaniak.core.ui.compose.bottomstickybuttonscaffolds.BottomStickyButtonScaffold
import com.infomaniak.core.ui.compose.margin.Margin
import com.infomaniak.core.ui.compose.preview.PreviewAllWindows
import com.infomaniak.core.common.mapSync
import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi
import com.infomaniak.multiplatform_swisstransfer.common.matomo.MatomoScreen
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.LocalUser
import com.infomaniak.swisstransfer.ui.MatomoSwissTransfer
import com.infomaniak.swisstransfer.ui.components.ButtonType
import com.infomaniak.swisstransfer.ui.components.LargeButton
Expand All @@ -84,6 +86,7 @@ import com.infomaniak.swisstransfer.ui.screen.newtransfer.pickfiles.components.T
import com.infomaniak.swisstransfer.ui.screen.newtransfer.pickfiles.components.TransferTypeUi
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.GetSetCallbacks
import com.infomaniak.swisstransfer.ui.utils.isApiV2
import com.infomaniak.swisstransfer.upload.UploadForegroundService
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.consumeEach
Expand Down Expand Up @@ -178,6 +181,7 @@ fun PickFilesScreen(
PickFilesScreen(
files = { files },
canSendStatus = { canSendStatus },
transferTitleState = pickFilesViewModel.transferTitleState,
emailTextFieldCallbacks = emailTextFieldCallbacks,
transferMessageCallbacks = pickFilesViewModel.transferMessageCallbacks,
selectedTransferType = GetSetCallbacks(
Expand Down Expand Up @@ -213,6 +217,7 @@ private fun HandleStartupFilePick(openFilePickerEvent: ReceiveChannel<Unit>, pic
private fun PickFilesScreen(
files: () -> List<FileUi>,
canSendStatus: () -> CanSendStatus,
transferTitleState: MutableState<String>,
emailTextFieldCallbacks: EmailTextFieldCallbacks,
transferMessageCallbacks: GetSetCallbacks<String>,
selectedTransferType: GetSetCallbacks<TransferTypeUi>,
Expand Down Expand Up @@ -251,6 +256,7 @@ private fun PickFilesScreen(
Spacer(Modifier.height(Margin.Medium))
ImportTextFields(
horizontalPaddingModifier = modifier,
transferTitleState = transferTitleState,
emailTextFieldCallbacks = emailTextFieldCallbacks,
transferMessageCallbacks = transferMessageCallbacks,
shouldShowEmailAddressesFields = { shouldShowEmailAddressesFields },
Expand Down Expand Up @@ -283,11 +289,21 @@ private fun FilesToImport(
@Composable
private fun ColumnScope.ImportTextFields(
horizontalPaddingModifier: Modifier,
transferTitleState: MutableState<String>,
emailTextFieldCallbacks: EmailTextFieldCallbacks,
transferMessageCallbacks: GetSetCallbacks<String>,
shouldShowEmailAddressesFields: () -> Boolean,
) {
val modifier = horizontalPaddingModifier.fillMaxWidth()
if (LocalUser.current.isApiV2()) {
SwissTransferTextField(
modifier = modifier,
label = stringResource(R.string.transferTitlePlaceholder),
isRequired = false,
maxLineNumber = 1,
onValueChange = { transferTitleState.value = it }
)
}
EmailAddressesTextFields(modifier, emailTextFieldCallbacks, shouldShowEmailAddressesFields)
SwissTransferTextField(
modifier = modifier,
Expand Down Expand Up @@ -318,6 +334,7 @@ private fun ColumnScope.EmailAddressesTextFields(
maxLineNumber = 1,
imeAction = ImeAction.Next,
isError = isAuthorError,
isReadOnly = LocalUser.current.isApiV2(),
supportingText = getEmailError(isAuthorError),
onValueChange = transferAuthorEmail.set,
)
Expand Down Expand Up @@ -511,6 +528,7 @@ private fun Preview(@PreviewParameter(FileUiListPreviewParameter::class) files:
PickFilesScreen(
files = { files },
canSendStatus = { CanSendStatus.Yes },
transferTitleState = remember { mutableStateOf("") },
emailTextFieldCallbacks = emailTextFieldCallbacks,
transferMessageCallbacks = GetSetCallbacks(get = { "" }, set = {}),
selectedTransferType = GetSetCallbacks(get = { TransferTypeUi.Mail }, set = {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import com.infomaniak.swisstransfer.ui.screen.newtransfer.pickfiles.PickFilesVie
import com.infomaniak.swisstransfer.ui.screen.newtransfer.pickfiles.PickFilesViewModel.CanSendStatus.Issue
import com.infomaniak.swisstransfer.ui.screen.newtransfer.pickfiles.components.TransferTypeUi
import com.infomaniak.swisstransfer.ui.screen.newtransfer.pickfiles.components.TransferTypeUi.Companion.toTransferTypeUi
import com.infomaniak.swisstransfer.ui.utils.AccountUtils
import com.infomaniak.swisstransfer.ui.utils.GetSetCallbacks
import com.infomaniak.swisstransfer.upload.NewTransferParams
import com.infomaniak.swisstransfer.upload.UploadForegroundService
Expand All @@ -66,8 +67,10 @@ import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import splitties.coroutines.repeatWhileActive
Expand All @@ -76,6 +79,7 @@ import javax.inject.Inject

@HiltViewModel
class PickFilesViewModel @Inject constructor(
private val accountUtils: AccountUtils,
private val appSettingsManager: AppSettingsManager,
private val newTransferOpenManager: NewTransferOpenManager,
private val savedStateHandle: SavedStateHandle,
Expand Down Expand Up @@ -147,7 +151,7 @@ class PickFilesViewModel @Inject constructor(
private var validatedRecipientsEmails by mutableStateOf<Set<String>>(emptySet())
//endregion

//region Transfer title TODO[ST-v2]: Add title text input for users connected via v2 API.
//region Transfer title
val transferTitleState = mutableStateOf("")
private var transferTitle by transferTitleState
//endregion
Expand Down Expand Up @@ -193,6 +197,11 @@ class PickFilesViewModel @Inject constructor(
initialValue = emptyList(),
)

viewModelScope.launch {
accountUtils.currentUserFlow.mapNotNull { it?.email }.distinctUntilChanged().collect { userEmail ->
transferAuthorEmail = userEmail
}
}
viewModelScope.launch { handleSessionStart() }
viewModelScope.launch(ioDispatcher) {
if (isFirstViewModelCreation) {
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/com/infomaniak/swisstransfer/ui/utils/UserExt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Infomaniak SwissTransfer - Android
* Copyright (C) 2026 Infomaniak Network SA
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.infomaniak.swisstransfer.ui.utils

import com.infomaniak.core.auth.models.user.User

fun User?.isApiV2() = this != null
1 change: 1 addition & 0 deletions app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<item quantity="one">%s tilbage</item>
<item quantity="other">%s tilbage</item>
</plurals>
<string name="transferTitlePlaceholder">Giv din overførsel en titel</string>
<string name="transferTypeEmail">E-mail</string>
<string name="transferTypeLink">Link</string>
<string name="transferTypeQrCode">QR-kode</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<item quantity="one">%s übrig</item>
<item quantity="other">%s übrig</item>
</plurals>
<string name="transferTitlePlaceholder">Gib deinem Transfer einen Titel</string>
<string name="transferTypeEmail">E-Mail</string>
<string name="transferTypeLink">Link</string>
<string name="transferTypeQrCode">QR Code</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<item quantity="one">%s απομένει</item>
<item quantity="other">%s απομένουν</item>
</plurals>
<string name="transferTitlePlaceholder">Δώσε έναν τίτλο στη μεταφορά σου</string>
<string name="transferTypeEmail">Email</string>
<string name="transferTypeLink">Σύνδεσμος</string>
<string name="transferTypeQrCode">Κωδικός QR</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<item quantity="one">Queda %s</item>
<item quantity="other">Quedan %s</item>
</plurals>
<string name="transferTitlePlaceholder">Pon un título a tu transferencia</string>
<string name="transferTypeEmail">Correo electrónico</string>
<string name="transferTypeLink">Enlace</string>
<string name="transferTypeQrCode">QR Code</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<item quantity="one">%s jäljellä</item>
<item quantity="other">%s jäljellä</item>
</plurals>
<string name="transferTitlePlaceholder">Anna siirrollesi otsikko</string>
<string name="transferTypeEmail">Sähköposti</string>
<string name="transferTypeLink">Linkki</string>
<string name="transferTypeQrCode">QR-koodi</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<item quantity="one">%s restant</item>
<item quantity="other">%s restants</item>
</plurals>
<string name="transferTitlePlaceholder">Donne un titre à ton transfert</string>
<string name="transferTypeEmail">E-mail</string>
<string name="transferTypeLink">Lien</string>
<string name="transferTypeQrCode">QR Code</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<item quantity="one">%s rimasto</item>
<item quantity="other">%s rimasti</item>
</plurals>
<string name="transferTitlePlaceholder">Dai un titolo al tuo trasferimento</string>
<string name="transferTypeEmail">Email</string>
<string name="transferTypeLink">Link</string>
<string name="transferTypeQrCode">QR Code</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-nb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<item quantity="one">%s igjen</item>
<item quantity="other">%s igjen</item>
</plurals>
<string name="transferTitlePlaceholder">Gi overføringen din en tittel</string>
<string name="transferTypeEmail">E-post</string>
<string name="transferTypeLink">Lenke</string>
<string name="transferTypeQrCode">QR-kode</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<item quantity="one">%s over</item>
<item quantity="other">%s over</item>
</plurals>
<string name="transferTitlePlaceholder">Geef je transfer een titel</string>
<string name="transferTypeEmail">E-mail</string>
<string name="transferTypeLink">Link</string>
<string name="transferTypeQrCode">QR-code</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
<item quantity="many">%s pozostało</item>
<item quantity="other">%s pozostało</item>
</plurals>
<string name="transferTitlePlaceholder">Nadaj tytuł swojemu transferowi</string>
<string name="transferTypeEmail">E-mail</string>
<string name="transferTypeLink">Link</string>
<string name="transferTypeQrCode">Kod QR</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<item quantity="one">%s restante</item>
<item quantity="other">%s restantes</item>
</plurals>
<string name="transferTitlePlaceholder">Dê um título à sua transferência</string>
<string name="transferTypeEmail">E-mail</string>
<string name="transferTypeLink">Ligação</string>
<string name="transferTypeQrCode">Código QR</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<item quantity="one">%s kvar</item>
<item quantity="other">%s kvar</item>
</plurals>
<string name="transferTitlePlaceholder">Ge din överföring en titel</string>
<string name="transferTypeEmail">E-post</string>
<string name="transferTypeLink">Länk</string>
<string name="transferTypeQrCode">QR-kod</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
<item quantity="one">%s left</item>
<item quantity="other">%s left</item>
</plurals>
<string name="transferTitlePlaceholder">Give a title to your transfer</string>
<string name="transferTypeEmail">Email</string>
<string name="transferTypeLink">Link</string>
<string name="transferTypeQrCode">QR Code</string>
Expand Down
Loading