Skip to content

Commit d63bc62

Browse files
fix: Display an error screen when coming from a deeplink and transfer is null
1 parent 6c7c9c5 commit d63bc62

File tree

6 files changed

+184
-13
lines changed

6 files changed

+184
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Infomaniak SwissTransfer - Android
3+
* Copyright (C) 2025 Infomaniak Network SA
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package com.infomaniak.swisstransfer.ui.components
19+
20+
import androidx.compose.foundation.layout.RowScope
21+
import androidx.compose.material3.ExperimentalMaterial3Api
22+
import androidx.compose.material3.TopAppBar
23+
import androidx.compose.material3.TopAppBarDefaults
24+
import androidx.compose.runtime.Composable
25+
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
26+
27+
@OptIn(ExperimentalMaterial3Api::class)
28+
@Composable
29+
fun ActionsOnlyTopAppBar(
30+
actions: @Composable RowScope.() -> Unit = {},
31+
) {
32+
TopAppBar(
33+
colors = TopAppBarDefaults.topAppBarColors(
34+
containerColor = SwissTransferTheme.materialColors.tertiary,
35+
titleContentColor = SwissTransferTheme.colors.toolbarTextColor,
36+
actionIconContentColor = SwissTransferTheme.colors.toolbarIconColor,
37+
navigationIconContentColor = SwissTransferTheme.colors.toolbarIconColor,
38+
),
39+
title = { },
40+
actions = actions,
41+
)
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Infomaniak SwissTransfer - Android
3+
* Copyright (C) 2025 Infomaniak Network SA
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package com.infomaniak.swisstransfer.ui.components
19+
20+
import androidx.compose.material3.ExperimentalMaterial3Api
21+
import androidx.compose.material3.TopAppBar
22+
import androidx.compose.material3.TopAppBarDefaults
23+
import androidx.compose.runtime.Composable
24+
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
25+
26+
@OptIn(ExperimentalMaterial3Api::class)
27+
@Composable
28+
fun EmptyTopAppBar() {
29+
TopAppBar(
30+
colors = TopAppBarDefaults.topAppBarColors(
31+
containerColor = SwissTransferTheme.materialColors.tertiary,
32+
titleContentColor = SwissTransferTheme.colors.toolbarTextColor,
33+
actionIconContentColor = SwissTransferTheme.colors.toolbarIconColor,
34+
navigationIconContentColor = SwissTransferTheme.colors.toolbarIconColor,
35+
),
36+
title = { },
37+
)
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Infomaniak SwissTransfer - Android
3+
* Copyright (C) 2025 Infomaniak Network SA
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package com.infomaniak.swisstransfer.ui.screen.main.received
19+
20+
import androidx.compose.foundation.Image
21+
import androidx.compose.foundation.layout.*
22+
import androidx.compose.material3.Surface
23+
import androidx.compose.material3.Text
24+
import androidx.compose.runtime.Composable
25+
import androidx.compose.ui.Alignment
26+
import androidx.compose.ui.Modifier
27+
import androidx.compose.ui.res.stringResource
28+
import androidx.compose.ui.text.style.TextAlign
29+
import com.infomaniak.swisstransfer.R
30+
import com.infomaniak.swisstransfer.ui.components.ActionsOnlyTopAppBar
31+
import com.infomaniak.swisstransfer.ui.components.EmptyTopAppBar
32+
import com.infomaniak.swisstransfer.ui.components.TopAppBarButtons
33+
import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus
34+
import com.infomaniak.swisstransfer.ui.images.illus.mascotDead.MascotDead
35+
import com.infomaniak.swisstransfer.ui.screen.main.components.SwissTransferScaffold
36+
import com.infomaniak.swisstransfer.ui.theme.Margin
37+
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
38+
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows
39+
40+
@Composable
41+
fun TransferExpiredDownloadCreditScreen(onCloseClicked: (() -> Unit)? = null) {
42+
SwissTransferScaffold(
43+
topBar = {
44+
onCloseClicked?.let {
45+
ActionsOnlyTopAppBar(actions = { TopAppBarButtons.Close(onClick = it) })
46+
} ?: EmptyTopAppBar()
47+
},
48+
) {
49+
Column(
50+
modifier = Modifier.fillMaxSize(),
51+
horizontalAlignment = Alignment.CenterHorizontally,
52+
verticalArrangement = Arrangement.Center,
53+
) {
54+
55+
val paddedModifier = Modifier.padding(horizontal = Margin.Medium)
56+
57+
Image(
58+
modifier = paddedModifier,
59+
imageVector = AppIllus.MascotDead.image(),
60+
contentDescription = null
61+
)
62+
63+
Spacer(Modifier.height(Margin.Large))
64+
65+
Text(
66+
text = stringResource(R.string.transferExpiredTitle),
67+
textAlign = TextAlign.Center,
68+
style = SwissTransferTheme.typography.bodyMedium,
69+
color = SwissTransferTheme.colors.primaryTextColor,
70+
modifier = paddedModifier,
71+
)
72+
73+
Spacer(Modifier.height(Margin.Large))
74+
75+
// TODO: Waiting for a general string.
76+
Text(
77+
text = stringResource(R.string.deeplinkTransferExpired),
78+
textAlign = TextAlign.Center,
79+
style = SwissTransferTheme.typography.bodyRegular,
80+
color = SwissTransferTheme.colors.secondaryTextColor,
81+
modifier = paddedModifier,
82+
)
83+
}
84+
}
85+
}
86+
87+
@PreviewAllWindows
88+
@Composable
89+
private fun Preview() {
90+
SwissTransferTheme {
91+
Surface {
92+
TransferExpiredDownloadCreditScreen(onCloseClicked = {})
93+
}
94+
}
95+
}

app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsScreen.kt

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Infomaniak SwissTransfer - Android
3-
* Copyright (C) 2024 Infomaniak Network SA
3+
* Copyright (C) 2024-2025 Infomaniak Network SA
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -56,12 +56,12 @@ import com.infomaniak.swisstransfer.ui.images.icons.QrCode
5656
import com.infomaniak.swisstransfer.ui.images.icons.Share
5757
import com.infomaniak.swisstransfer.ui.previewparameter.TransferUiListPreviewParameter
5858
import com.infomaniak.swisstransfer.ui.screen.main.components.SwissTransferScaffold
59+
import com.infomaniak.swisstransfer.ui.screen.main.received.TransferExpiredDownloadCreditScreen
5960
import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.TransferDetailsViewModel.TransferDetailsUiState.Deleted
6061
import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.TransferDetailsViewModel.TransferDetailsUiState.Success
6162
import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.components.PasswordBottomSheet
6263
import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.components.QrCodeBottomSheet
6364
import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.components.TransferInfo
64-
import com.infomaniak.swisstransfer.ui.screen.main.transfers.NoSelectionEmptyState
6565
import com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.components.DeeplinkPasswordAlertDialog
6666
import com.infomaniak.swisstransfer.ui.theme.LocalWindowAdaptiveInfo
6767
import com.infomaniak.swisstransfer.ui.theme.Margin
@@ -79,7 +79,6 @@ import kotlinx.coroutines.flow.emptyFlow
7979
fun TransferDetailsScreen(
8080
transferUuid: String,
8181
direction: TransferDirection,
82-
hasTransfer: () -> Boolean,
8382
navigateBack: (() -> Unit)?,
8483
transferDetailsViewModel: TransferDetailsViewModel = hiltViewModel<TransferDetailsViewModel>(),
8584
navigateToFolder: (folderUuid: String) -> Unit,
@@ -97,11 +96,11 @@ fun TransferDetailsScreen(
9796
val context = LocalContext.current
9897
when (val state = uiState) {
9998
is Deleted -> {
100-
if (windowAdaptiveInfo.isWindowSmall()) {
101-
navigateBack?.invoke()
102-
} else {
103-
NoSelectionEmptyState(hasTransfer())
104-
}
99+
TransferExpiredDownloadCreditScreen(
100+
onCloseClicked = if (windowAdaptiveInfo.isWindowSmall()) {
101+
{ navigateBack?.invoke() }
102+
} else null
103+
)
105104
}
106105
is TransferDetailsViewModel.TransferDetailsUiState.Loading -> {
107106
SwissTransferScaffold(topBar = { SwissTransferTopAppBar(title = "") }) {}

app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsViewModel.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Infomaniak SwissTransfer - Android
3-
* Copyright (C) 2024 Infomaniak Network SA
3+
* Copyright (C) 2024-2025 Infomaniak Network SA
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -28,7 +28,6 @@ import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi
2828
import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferUi
2929
import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection
3030
import com.infomaniak.multiplatform_swisstransfer.managers.TransferManager
31-
import com.infomaniak.multiplatform_swisstransfer.network.exceptions.DownloadQuotaExceededException
3231
import com.infomaniak.multiplatform_swisstransfer.network.exceptions.FetchTransferException.*
3332
import com.infomaniak.swisstransfer.R
3433
import com.infomaniak.swisstransfer.di.UserAgent
@@ -137,7 +136,6 @@ class TransferDetailsViewModel @Inject constructor(
137136
}.onFailure { exception ->
138137
when (exception) {
139138
is ExpiredDateFetchTransferException -> longToast(R.string.deeplinkTransferExpired)
140-
is DownloadQuotaExceededException -> longToast(R.string.deeplinkTransferExpired)
141139
is NotFoundFetchTransferException -> longToast(R.string.deeplinkTransferNotFound)
142140
is PasswordNeededFetchTransferException, is WrongPasswordFetchTransferException -> throw exception
143141
else -> SentryLog.e(TAG, "An error has occurred when deeplink a transfer", exception)

app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersScreenWrapper.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Infomaniak SwissTransfer - Android
3-
* Copyright (C) 2024 Infomaniak Network SA
3+
* Copyright (C) 2024-2025 Infomaniak Network SA
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -174,7 +174,6 @@ private fun DetailPane(
174174
TransferDetailsScreen(
175175
transferUuid = destinationContent.transferUuid,
176176
direction = destinationContent.direction,
177-
hasTransfer = hasTransfer,
178177
navigateBack = ScreenWrapperUtils.getBackNavigation(navigator),
179178
navigateToFolder = { selectedFolderUuid ->
180179
navigator.navigateToFolder(

0 commit comments

Comments
 (0)