Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Display an error screen when coming from a deeplink and transfer is null #442

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
@@ -0,0 +1,42 @@
/*
* Infomaniak SwissTransfer - Android
* Copyright (C) 2025 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.components

import androidx.compose.foundation.layout.RowScope
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ActionsOnlyTopAppBar(
actions: @Composable RowScope.() -> Unit = {},
) {
TopAppBar(
colors = TopAppBarDefaults.topAppBarColors(
containerColor = SwissTransferTheme.materialColors.tertiary,
titleContentColor = SwissTransferTheme.colors.toolbarTextColor,
actionIconContentColor = SwissTransferTheme.colors.toolbarIconColor,
navigationIconContentColor = SwissTransferTheme.colors.toolbarIconColor,
),
title = { },
actions = actions,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Infomaniak SwissTransfer - Android
* Copyright (C) 2025 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.components

import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EmptyTopAppBar() {
TopAppBar(
colors = TopAppBarDefaults.topAppBarColors(
containerColor = SwissTransferTheme.materialColors.tertiary,
titleContentColor = SwissTransferTheme.colors.toolbarTextColor,
actionIconContentColor = SwissTransferTheme.colors.toolbarIconColor,
navigationIconContentColor = SwissTransferTheme.colors.toolbarIconColor,
),
title = { },
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Infomaniak SwissTransfer - Android
* Copyright (C) 2025 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.screen.main.received

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.components.ActionsOnlyTopAppBar
import com.infomaniak.swisstransfer.ui.components.EmptyTopAppBar
import com.infomaniak.swisstransfer.ui.components.TopAppBarButtons
import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus
import com.infomaniak.swisstransfer.ui.images.illus.mascotDead.MascotDead
import com.infomaniak.swisstransfer.ui.screen.main.components.SwissTransferScaffold
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows

@Composable
fun TransferExpiredDownloadCreditScreen(onCloseClicked: (() -> Unit)? = null) {
SwissTransferScaffold(
topBar = {
onCloseClicked?.let {
ActionsOnlyTopAppBar(actions = { TopAppBarButtons.Close(onClick = it) })
} ?: EmptyTopAppBar()
},
) {
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {

val paddedModifier = Modifier.padding(horizontal = Margin.Medium)

Image(
modifier = paddedModifier,
imageVector = AppIllus.MascotDead.image(),
contentDescription = null
)

Spacer(Modifier.height(Margin.Large))

Text(
text = stringResource(R.string.transferExpiredTitle),
textAlign = TextAlign.Center,
style = SwissTransferTheme.typography.bodyMedium,
color = SwissTransferTheme.colors.primaryTextColor,
modifier = paddedModifier,
)

Spacer(Modifier.height(Margin.Large))

// TODO: Waiting for a general string.
Text(
text = stringResource(R.string.deeplinkTransferExpired),
textAlign = TextAlign.Center,
style = SwissTransferTheme.typography.bodyRegular,
color = SwissTransferTheme.colors.secondaryTextColor,
modifier = paddedModifier,
)
}
}
}

@PreviewAllWindows
@Composable
private fun Preview() {
SwissTransferTheme {
Surface {
TransferExpiredDownloadCreditScreen(onCloseClicked = {})
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Infomaniak SwissTransfer - Android
* Copyright (C) 2024 Infomaniak Network SA
* Copyright (C) 2024-2025 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
Expand Down Expand Up @@ -56,6 +56,7 @@ import com.infomaniak.swisstransfer.ui.images.icons.QrCode
import com.infomaniak.swisstransfer.ui.images.icons.Share
import com.infomaniak.swisstransfer.ui.previewparameter.TransferUiListPreviewParameter
import com.infomaniak.swisstransfer.ui.screen.main.components.SwissTransferScaffold
import com.infomaniak.swisstransfer.ui.screen.main.received.TransferExpiredDownloadCreditScreen
import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.TransferDetailsViewModel.TransferDetailsUiState.Deleted
import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.TransferDetailsViewModel.TransferDetailsUiState.Success
import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.components.PasswordBottomSheet
Expand All @@ -79,7 +80,6 @@ import kotlinx.coroutines.flow.emptyFlow
fun TransferDetailsScreen(
transferUuid: String,
direction: TransferDirection,
hasTransfer: () -> Boolean,
navigateBack: (() -> Unit)?,
transferDetailsViewModel: TransferDetailsViewModel = hiltViewModel<TransferDetailsViewModel>(),
navigateToFolder: (folderUuid: String) -> Unit,
Expand All @@ -97,11 +97,11 @@ fun TransferDetailsScreen(
val context = LocalContext.current
when (val state = uiState) {
is Deleted -> {
if (windowAdaptiveInfo.isWindowSmall()) {
navigateBack?.invoke()
} else {
NoSelectionEmptyState(hasTransfer())
}
TransferExpiredDownloadCreditScreen(
onCloseClicked = if (windowAdaptiveInfo.isWindowSmall()) {
{ navigateBack?.invoke() }
} else null
)
}
is TransferDetailsViewModel.TransferDetailsUiState.Loading -> {
SwissTransferScaffold(topBar = { SwissTransferTopAppBar(title = "") }) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Infomaniak SwissTransfer - Android
* Copyright (C) 2024 Infomaniak Network SA
* Copyright (C) 2024-2025 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
Expand Down Expand Up @@ -29,7 +29,6 @@ import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi
import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferUi
import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection
import com.infomaniak.multiplatform_swisstransfer.managers.TransferManager
import com.infomaniak.multiplatform_swisstransfer.network.exceptions.DownloadQuotaExceededException
import com.infomaniak.multiplatform_swisstransfer.network.exceptions.FetchTransferException.*
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.di.UserAgent
Expand Down Expand Up @@ -140,7 +139,6 @@ class TransferDetailsViewModel @Inject constructor(
}.cancellable().onFailure { exception ->
when (exception) {
is ExpiredDateFetchTransferException -> longToast(R.string.deeplinkTransferExpired)
is DownloadQuotaExceededException -> longToast(R.string.deeplinkTransferExpired)
is NotFoundFetchTransferException -> longToast(R.string.deeplinkTransferNotFound)
is PasswordNeededFetchTransferException, is WrongPasswordFetchTransferException -> throw exception
else -> SentryLog.e(TAG, "An error has occurred when deeplink a transfer", exception)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Infomaniak SwissTransfer - Android
* Copyright (C) 2024 Infomaniak Network SA
* Copyright (C) 2024-2025 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
Expand Down Expand Up @@ -182,7 +182,6 @@ private fun DetailPane(
TransferDetailsScreen(
transferUuid = destinationContent.transferUuid,
direction = destinationContent.direction,
hasTransfer = hasTransfer,
navigateBack = ScreenWrapperUtils.getBackNavigation(navigator),
navigateToFolder = { selectedFolderUuid ->
navigator.navigateToFolder(
Expand Down