From 53cdf69872c686407deef59651c45283a4cfc049 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Mon, 14 Oct 2024 17:47:18 +0200 Subject: [PATCH 1/9] feat: Add possibility do disable automatic icon tinting --- .../screen/main/settings/components/SettingItem.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/SettingItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/SettingItem.kt index d3b6e97b1..6ed23d66e 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/SettingItem.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/SettingItem.kt @@ -19,6 +19,7 @@ package com.infomaniak.swisstransfer.ui.screen.main.settings.components import android.content.res.Configuration import androidx.annotation.StringRes +import androidx.compose.foundation.Image import androidx.compose.foundation.layout.* import androidx.compose.foundation.selection.selectableGroup import androidx.compose.material3.Icon @@ -51,6 +52,7 @@ fun SettingItem( icon: ImageVector? = null, description: String? = null, endIcon: EndIconType? = null, + shouldTintIcon: Boolean = true, onClick: (() -> Unit)?, ) { val modifier = Modifier @@ -63,11 +65,11 @@ fun SettingItem( isSelected = isSelected, onClick = it, ) { - SettingItemContent(icon, titleRes, description, endIcon) + SettingItemContent(icon, titleRes, description, endIcon, shouldTintIcon) } } ?: run { Box(modifier = modifier, contentAlignment = Alignment.CenterStart) { - SettingItemContent(icon, titleRes, description, endIcon) + SettingItemContent(icon, titleRes, description, endIcon, shouldTintIcon) } } } @@ -78,6 +80,7 @@ private fun SettingItemContent( titleRes: Int, description: String?, endIcon: EndIconType?, + shouldTintIcon: Boolean, ) { Row( modifier = Modifier @@ -87,7 +90,11 @@ private fun SettingItemContent( verticalAlignment = Alignment.CenterVertically, ) { icon?.let { - Icon(imageVector = it, contentDescription = null, tint = SwissTransferTheme.materialColors.primary) + if (shouldTintIcon) { + Icon(imageVector = it, contentDescription = null, tint = SwissTransferTheme.materialColors.primary) + } else { + Image(imageVector = it, contentDescription = null) + } Spacer(modifier = Modifier.width(Margin.Medium)) } From a4ce22bfafcbd0ba64374c10c14b5d3898d2415d Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Mon, 14 Oct 2024 17:48:18 +0200 Subject: [PATCH 2/9] feat: Add Data Management section in Settings --- .../ui/screen/main/settings/SettingsScreen.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt index 70757eeae..5b7f81db6 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt @@ -142,6 +142,15 @@ fun SettingsScreen( description = BuildConfig.VERSION_NAME, onClick = null, ) + SettingDivider() + + SettingTitle(R.string.settingsCategoryDataManagement) + SettingItem( + titleRes = R.string.settingsOptionDataManagement, + isSelected = { selectedSetting == DATA_MANAGEMENT }, + endIcon = CHEVRON, + onClick = { onItemClick(DATA_MANAGEMENT) }, + ) } } } @@ -182,6 +191,7 @@ enum class SettingsOptionScreens { THEME, NOTIFICATIONS, VALIDITY_PERIOD, DOWNLOAD_LIMIT, EMAIL_LANGUAGE, DISCOVER_INFOMANIAK, SHARE_IDEAS, GIVE_FEEDBACK, + DATA_MANAGEMENT, } @PreviewAllWindows From a4da644d66b154f1efbe96306cec9521b298afb8 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Mon, 14 Oct 2024 17:49:13 +0200 Subject: [PATCH 3/9] feat: Add SettingsDataManagementScreen --- .../settings/SettingsDataManagementScreen.kt | 118 ++++++++++++++++++ .../main/settings/SettingsScreenWrapper.kt | 8 ++ 2 files changed, 126 insertions(+) create mode 100644 app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt new file mode 100644 index 000000000..4376612bb --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt @@ -0,0 +1,118 @@ +/* + * Infomaniak SwissTransfer - Android + * Copyright (C) 2024 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 . + */ +package com.infomaniak.swisstransfer.ui.screen.main.settings + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +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 com.infomaniak.swisstransfer.R +import com.infomaniak.swisstransfer.ui.components.SharpRippleButton +import com.infomaniak.swisstransfer.ui.components.SwissTransferTopAppBar +import com.infomaniak.swisstransfer.ui.components.TopAppBarButton +import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons +import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus +import com.infomaniak.swisstransfer.ui.images.icons.Matomo +import com.infomaniak.swisstransfer.ui.images.icons.Sentry +import com.infomaniak.swisstransfer.ui.images.illus.DataProtection +import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold +import com.infomaniak.swisstransfer.ui.screen.main.settings.components.EndIconType.CHEVRON +import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingItem +import com.infomaniak.swisstransfer.ui.theme.Dimens +import com.infomaniak.swisstransfer.ui.theme.Margin +import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow + +@Composable +fun SettingsDataManagementScreen( + navigateBack: (() -> Unit)?, + onViewSourceCodeClicked: () -> Unit, +) { + SmallWindowTopAppBarScaffold( + smallWindowTopAppBar = { + SwissTransferTopAppBar( + titleRes = R.string.settingsOptionDataManagement, + navigationMenu = TopAppBarButton.backButton(navigateBack ?: {}), + ) + }, + ) { + Column( + modifier = Modifier.verticalScroll(rememberScrollState()), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Image( + imageVector = AppIllus.DataProtection, // TODO: Handle dark theme + contentDescription = null, + modifier = Modifier.padding(Margin.Medium), + ) + Text( + text = stringResource(R.string.settingsDataManagementDescription), + style = SwissTransferTheme.typography.bodyRegular, + color = SwissTransferTheme.colors.primaryTextColor, + modifier = Modifier.padding(Margin.Medium), + ) + SharpRippleButton( + modifier = Modifier.fillMaxWidth(), + onClick = { onViewSourceCodeClicked() }, + ) { + Text( + text = stringResource(R.string.settingsDataManagementSourceCode), + style = SwissTransferTheme.typography.bodyMedium, + color = SwissTransferTheme.materialColors.primary, + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = Dimens.SettingHorizontalMargin, vertical = Dimens.SettingVerticalMargin), + ) + } + SettingItem( + titleRes = R.string.matomo, + isSelected = { false }, + icon = AppIcons.Matomo.image(), + endIcon = CHEVRON, + shouldTintIcon = false, + onClick = { /* TODO */ }, + ) + SettingItem( + titleRes = R.string.sentry, + isSelected = { false }, + icon = AppIcons.Sentry.image(), + endIcon = CHEVRON, + shouldTintIcon = false, + onClick = { /* TODO */ }, + ) + } + } +} + +@PreviewSmallWindow +@Composable +private fun SettingsDataManagementScreenPreview() { + SwissTransferTheme { + Surface { + SettingsDataManagementScreen({}, {}) + } + } +} diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt index ebb8ed197..1080d5bfd 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt @@ -123,6 +123,7 @@ private fun DetailPane( emailLanguage: GetSetCallbacks, ) { var lastSelectedScreen by rememberSaveable { mutableStateOf(null) } + val context = LocalContext.current val destination = navigator.currentDestination?.content ?: lastSelectedScreen navigator.currentDestination?.content?.let { lastSelectedScreen = it } @@ -130,6 +131,9 @@ private fun DetailPane( val navigateBackCallback: () -> Unit = { navigator.navigateBack() } val navigateBack: (() -> Unit)? = if (navigator.canNavigateBack()) navigateBackCallback else null + // TODO: Update this URL when we know what we want. + val sourceCodeURL = stringResource(R.string.urlSourceCode) + when (destination) { THEME -> SettingsThemeScreen( theme = theme.get(), @@ -151,6 +155,10 @@ private fun DetailPane( navigateBack = navigateBack, onEmailLanguageChange = { emailLanguage.set(it) }, ) + DATA_MANAGEMENT -> SettingsDataManagementScreen( + navigateBack = navigateBack, + onViewSourceCodeClicked = { context.openUrl(sourceCodeURL) }, + ) NOTIFICATIONS, DISCOVER_INFOMANIAK, SHARE_IDEAS, From 17d43355fe9c09381af154836b79f862bb77ef96 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Tue, 15 Oct 2024 07:26:54 +0200 Subject: [PATCH 4/9] feat: Add navigation to Matomo & Sentry screens --- .../SettingsDataManagementMatomoScreen.kt | 85 +++++++++++++++++++ .../settings/SettingsDataManagementScreen.kt | 9 +- .../SettingsDataManagementSentryScreen.kt | 85 +++++++++++++++++++ .../ui/screen/main/settings/SettingsScreen.kt | 2 +- .../main/settings/SettingsScreenWrapper.kt | 14 ++- 5 files changed, 188 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt create mode 100644 app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt new file mode 100644 index 000000000..f6092d78d --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt @@ -0,0 +1,85 @@ +/* + * Infomaniak SwissTransfer - Android + * Copyright (C) 2024 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 . + */ +package com.infomaniak.swisstransfer.ui.screen.main.settings + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +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 com.infomaniak.swisstransfer.R +import com.infomaniak.swisstransfer.ui.components.SharpRippleButton +import com.infomaniak.swisstransfer.ui.components.SwissTransferTopAppBar +import com.infomaniak.swisstransfer.ui.components.TopAppBarButton +import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons +import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus +import com.infomaniak.swisstransfer.ui.images.icons.Matomo +import com.infomaniak.swisstransfer.ui.images.icons.Sentry +import com.infomaniak.swisstransfer.ui.images.illus.DataProtection +import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold +import com.infomaniak.swisstransfer.ui.screen.main.settings.SettingsOptionScreens.* +import com.infomaniak.swisstransfer.ui.screen.main.settings.components.EndIconType.CHEVRON +import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingItem +import com.infomaniak.swisstransfer.ui.theme.Dimens +import com.infomaniak.swisstransfer.ui.theme.Margin +import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow + +@Composable +fun SettingsDataManagementMatomoScreen( + navigateBack: (() -> Unit)?, + // onItemClick: (SettingsOptionScreens) -> Unit, +) { + SmallWindowTopAppBarScaffold( + smallWindowTopAppBar = { + SwissTransferTopAppBar( + titleRes = R.string.settingsOptionDataManagement, + navigationMenu = TopAppBarButton.backButton(navigateBack ?: {}), + ) + }, + ) { + Column( + modifier = Modifier.verticalScroll(rememberScrollState()), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Text( + text = stringResource(R.string.matomo), + style = SwissTransferTheme.typography.bodyRegular, + color = SwissTransferTheme.colors.primaryTextColor, + modifier = Modifier.padding(Margin.Medium), + ) + } + } +} + +@PreviewSmallWindow +@Composable +private fun SettingsDataManagementScreenPreview() { + SwissTransferTheme { + Surface { + SettingsDataManagementScreen({}, {}) + } + } +} diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt index 4376612bb..8f9b03c5a 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt @@ -39,6 +39,7 @@ import com.infomaniak.swisstransfer.ui.images.icons.Matomo import com.infomaniak.swisstransfer.ui.images.icons.Sentry import com.infomaniak.swisstransfer.ui.images.illus.DataProtection import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold +import com.infomaniak.swisstransfer.ui.screen.main.settings.SettingsOptionScreens.* import com.infomaniak.swisstransfer.ui.screen.main.settings.components.EndIconType.CHEVRON import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingItem import com.infomaniak.swisstransfer.ui.theme.Dimens @@ -49,7 +50,7 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow @Composable fun SettingsDataManagementScreen( navigateBack: (() -> Unit)?, - onViewSourceCodeClicked: () -> Unit, + onItemClick: (SettingsOptionScreens) -> Unit, ) { SmallWindowTopAppBarScaffold( smallWindowTopAppBar = { @@ -76,7 +77,7 @@ fun SettingsDataManagementScreen( ) SharpRippleButton( modifier = Modifier.fillMaxWidth(), - onClick = { onViewSourceCodeClicked() }, + onClick = { onItemClick(DATA_MANAGEMENT_SOURCE_CODE) }, ) { Text( text = stringResource(R.string.settingsDataManagementSourceCode), @@ -93,7 +94,7 @@ fun SettingsDataManagementScreen( icon = AppIcons.Matomo.image(), endIcon = CHEVRON, shouldTintIcon = false, - onClick = { /* TODO */ }, + onClick = { onItemClick(DATA_MANAGEMENT_MATOMO) }, ) SettingItem( titleRes = R.string.sentry, @@ -101,7 +102,7 @@ fun SettingsDataManagementScreen( icon = AppIcons.Sentry.image(), endIcon = CHEVRON, shouldTintIcon = false, - onClick = { /* TODO */ }, + onClick = { onItemClick(DATA_MANAGEMENT_SENTRY) }, ) } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt new file mode 100644 index 000000000..39d42cfdd --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt @@ -0,0 +1,85 @@ +/* + * Infomaniak SwissTransfer - Android + * Copyright (C) 2024 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 . + */ +package com.infomaniak.swisstransfer.ui.screen.main.settings + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +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 com.infomaniak.swisstransfer.R +import com.infomaniak.swisstransfer.ui.components.SharpRippleButton +import com.infomaniak.swisstransfer.ui.components.SwissTransferTopAppBar +import com.infomaniak.swisstransfer.ui.components.TopAppBarButton +import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons +import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus +import com.infomaniak.swisstransfer.ui.images.icons.Matomo +import com.infomaniak.swisstransfer.ui.images.icons.Sentry +import com.infomaniak.swisstransfer.ui.images.illus.DataProtection +import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold +import com.infomaniak.swisstransfer.ui.screen.main.settings.SettingsOptionScreens.* +import com.infomaniak.swisstransfer.ui.screen.main.settings.components.EndIconType.CHEVRON +import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingItem +import com.infomaniak.swisstransfer.ui.theme.Dimens +import com.infomaniak.swisstransfer.ui.theme.Margin +import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow + +@Composable +fun SettingsDataManagementSentryScreen( + navigateBack: (() -> Unit)?, + // onItemClick: (SettingsOptionScreens) -> Unit, +) { + SmallWindowTopAppBarScaffold( + smallWindowTopAppBar = { + SwissTransferTopAppBar( + titleRes = R.string.settingsOptionDataManagement, + navigationMenu = TopAppBarButton.backButton(navigateBack ?: {}), + ) + }, + ) { + Column( + modifier = Modifier.verticalScroll(rememberScrollState()), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Text( + text = stringResource(R.string.sentry), + style = SwissTransferTheme.typography.bodyRegular, + color = SwissTransferTheme.colors.primaryTextColor, + modifier = Modifier.padding(Margin.Medium), + ) + } + } +} + +@PreviewSmallWindow +@Composable +private fun SettingsDataManagementScreenPreview() { + SwissTransferTheme { + Surface { + SettingsDataManagementScreen({}, {}) + } + } +} diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt index 5b7f81db6..338d94fa1 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt @@ -191,7 +191,7 @@ enum class SettingsOptionScreens { THEME, NOTIFICATIONS, VALIDITY_PERIOD, DOWNLOAD_LIMIT, EMAIL_LANGUAGE, DISCOVER_INFOMANIAK, SHARE_IDEAS, GIVE_FEEDBACK, - DATA_MANAGEMENT, + DATA_MANAGEMENT, DATA_MANAGEMENT_SOURCE_CODE, DATA_MANAGEMENT_MATOMO, DATA_MANAGEMENT_SENTRY, } @PreviewAllWindows diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt index 1080d5bfd..69d117fd6 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt @@ -157,12 +157,22 @@ private fun DetailPane( ) DATA_MANAGEMENT -> SettingsDataManagementScreen( navigateBack = navigateBack, - onViewSourceCodeClicked = { context.openUrl(sourceCodeURL) }, + onItemClick = { item -> + if (item == DATA_MANAGEMENT_SOURCE_CODE) { + context.openUrl(sourceCodeURL) + } else { + // Navigate to the detail pane with the passed item + navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, item) + } + }, ) + DATA_MANAGEMENT_MATOMO -> SettingsDataManagementMatomoScreen(navigateBack) + DATA_MANAGEMENT_SENTRY -> SettingsDataManagementSentryScreen(navigateBack) NOTIFICATIONS, DISCOVER_INFOMANIAK, SHARE_IDEAS, - GIVE_FEEDBACK -> Unit + GIVE_FEEDBACK, + DATA_MANAGEMENT_SOURCE_CODE -> Unit null -> NoSelectionEmptyState() } } From 8b5d37b2415bc023c0a9533ed7d8c91c20968aa5 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Tue, 15 Oct 2024 09:48:44 +0200 Subject: [PATCH 5/9] refactor: Update Matomo & Sentry light & dark icons & illus --- .../SettingsDataManagementMatomoScreen.kt | 24 ++++++++----------- .../SettingsDataManagementSentryScreen.kt | 24 ++++++++----------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt index f6092d78d..af4f6d51e 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt @@ -19,7 +19,6 @@ package com.infomaniak.swisstransfer.ui.screen.main.settings import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll @@ -30,19 +29,11 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import com.infomaniak.swisstransfer.R -import com.infomaniak.swisstransfer.ui.components.SharpRippleButton import com.infomaniak.swisstransfer.ui.components.SwissTransferTopAppBar import com.infomaniak.swisstransfer.ui.components.TopAppBarButton -import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus -import com.infomaniak.swisstransfer.ui.images.icons.Matomo -import com.infomaniak.swisstransfer.ui.images.icons.Sentry -import com.infomaniak.swisstransfer.ui.images.illus.DataProtection +import com.infomaniak.swisstransfer.ui.images.illus.Matomo import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold -import com.infomaniak.swisstransfer.ui.screen.main.settings.SettingsOptionScreens.* -import com.infomaniak.swisstransfer.ui.screen.main.settings.components.EndIconType.CHEVRON -import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingItem -import com.infomaniak.swisstransfer.ui.theme.Dimens import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow @@ -55,7 +46,7 @@ fun SettingsDataManagementMatomoScreen( SmallWindowTopAppBarScaffold( smallWindowTopAppBar = { SwissTransferTopAppBar( - titleRes = R.string.settingsOptionDataManagement, + titleRes = R.string.matomo, navigationMenu = TopAppBarButton.backButton(navigateBack ?: {}), ) }, @@ -64,8 +55,13 @@ fun SettingsDataManagementMatomoScreen( modifier = Modifier.verticalScroll(rememberScrollState()), horizontalAlignment = Alignment.CenterHorizontally, ) { + Image( + imageVector = AppIllus.Matomo.image(), + contentDescription = null, + modifier = Modifier.padding(Margin.Medium), + ) Text( - text = stringResource(R.string.matomo), + text = stringResource(R.string.settingsMatomoDescription), style = SwissTransferTheme.typography.bodyRegular, color = SwissTransferTheme.colors.primaryTextColor, modifier = Modifier.padding(Margin.Medium), @@ -76,10 +72,10 @@ fun SettingsDataManagementMatomoScreen( @PreviewSmallWindow @Composable -private fun SettingsDataManagementScreenPreview() { +private fun SettingsDataManagementMatomoScreenPreview() { SwissTransferTheme { Surface { - SettingsDataManagementScreen({}, {}) + SettingsDataManagementMatomoScreen {} } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt index 39d42cfdd..8a1629215 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt @@ -19,7 +19,6 @@ package com.infomaniak.swisstransfer.ui.screen.main.settings import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll @@ -30,19 +29,11 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import com.infomaniak.swisstransfer.R -import com.infomaniak.swisstransfer.ui.components.SharpRippleButton import com.infomaniak.swisstransfer.ui.components.SwissTransferTopAppBar import com.infomaniak.swisstransfer.ui.components.TopAppBarButton -import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus -import com.infomaniak.swisstransfer.ui.images.icons.Matomo -import com.infomaniak.swisstransfer.ui.images.icons.Sentry -import com.infomaniak.swisstransfer.ui.images.illus.DataProtection +import com.infomaniak.swisstransfer.ui.images.illus.Sentry import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold -import com.infomaniak.swisstransfer.ui.screen.main.settings.SettingsOptionScreens.* -import com.infomaniak.swisstransfer.ui.screen.main.settings.components.EndIconType.CHEVRON -import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingItem -import com.infomaniak.swisstransfer.ui.theme.Dimens import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow @@ -55,7 +46,7 @@ fun SettingsDataManagementSentryScreen( SmallWindowTopAppBarScaffold( smallWindowTopAppBar = { SwissTransferTopAppBar( - titleRes = R.string.settingsOptionDataManagement, + titleRes = R.string.sentry, navigationMenu = TopAppBarButton.backButton(navigateBack ?: {}), ) }, @@ -64,8 +55,13 @@ fun SettingsDataManagementSentryScreen( modifier = Modifier.verticalScroll(rememberScrollState()), horizontalAlignment = Alignment.CenterHorizontally, ) { + Image( + imageVector = AppIllus.Sentry.image(), + contentDescription = null, + modifier = Modifier.padding(Margin.Medium), + ) Text( - text = stringResource(R.string.sentry), + text = stringResource(R.string.settingsSentryDescription), style = SwissTransferTheme.typography.bodyRegular, color = SwissTransferTheme.colors.primaryTextColor, modifier = Modifier.padding(Margin.Medium), @@ -76,10 +72,10 @@ fun SettingsDataManagementSentryScreen( @PreviewSmallWindow @Composable -private fun SettingsDataManagementScreenPreview() { +private fun SettingsDataManagementSentryScreenPreview() { SwissTransferTheme { Surface { - SettingsDataManagementScreen({}, {}) + SettingsDataManagementSentryScreen {} } } } From 81224ca3b0064060fb16a0ba21abd56fb2fd685e Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Tue, 15 Oct 2024 11:06:09 +0200 Subject: [PATCH 6/9] feat: Add tracking Switch for Matomo & Sentry --- .../SettingsDataManagementMatomoScreen.kt | 34 +++++++++++++++---- .../SettingsDataManagementSentryScreen.kt | 34 +++++++++++++++---- 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt index af4f6d51e..8ae113590 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt @@ -18,13 +18,17 @@ package com.infomaniak.swisstransfer.ui.screen.main.settings import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.* import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Surface +import androidx.compose.material3.Switch import androidx.compose.material3.Text 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.res.stringResource @@ -39,10 +43,11 @@ import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow @Composable -fun SettingsDataManagementMatomoScreen( - navigateBack: (() -> Unit)?, - // onItemClick: (SettingsOptionScreens) -> Unit, -) { +fun SettingsDataManagementMatomoScreen(navigateBack: (() -> Unit)?) { + + // TODO: Use real value from Realm, and save it to Realm / anywhere else too. + var isMatomoAuthorized by rememberSaveable { mutableStateOf(true) } + SmallWindowTopAppBarScaffold( smallWindowTopAppBar = { SwissTransferTopAppBar( @@ -66,6 +71,23 @@ fun SettingsDataManagementMatomoScreen( color = SwissTransferTheme.colors.primaryTextColor, modifier = Modifier.padding(Margin.Medium), ) + Row( + modifier = Modifier + .fillMaxWidth() + .padding(Margin.Medium), + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + text = stringResource(R.string.settingsAuthorizeTracking), + style = SwissTransferTheme.typography.bodyRegular, + color = SwissTransferTheme.colors.primaryTextColor, + ) + Spacer(Modifier.weight(1.0f)) + Switch( + checked = isMatomoAuthorized, + onCheckedChange = { isMatomoAuthorized = it }, + ) + } } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt index 8a1629215..469d295be 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt @@ -18,13 +18,17 @@ package com.infomaniak.swisstransfer.ui.screen.main.settings import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.* import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Surface +import androidx.compose.material3.Switch import androidx.compose.material3.Text 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.res.stringResource @@ -39,10 +43,11 @@ import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow @Composable -fun SettingsDataManagementSentryScreen( - navigateBack: (() -> Unit)?, - // onItemClick: (SettingsOptionScreens) -> Unit, -) { +fun SettingsDataManagementSentryScreen(navigateBack: (() -> Unit)?) { + + // TODO: Use real value from Realm, and save it to Realm / anywhere else too. + var isSentryAuthorized by rememberSaveable { mutableStateOf(true) } + SmallWindowTopAppBarScaffold( smallWindowTopAppBar = { SwissTransferTopAppBar( @@ -66,6 +71,23 @@ fun SettingsDataManagementSentryScreen( color = SwissTransferTheme.colors.primaryTextColor, modifier = Modifier.padding(Margin.Medium), ) + Row( + modifier = Modifier + .fillMaxWidth() + .padding(Margin.Medium), + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + text = stringResource(R.string.settingsAuthorizeTracking), + style = SwissTransferTheme.typography.bodyRegular, + color = SwissTransferTheme.colors.primaryTextColor, + ) + Spacer(Modifier.weight(1.0f)) + Switch( + checked = isSentryAuthorized, + onCheckedChange = { isSentryAuthorized = it }, + ) + } } } } From d502a6795ecf2b724c82d805085a008c43c84f40 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Tue, 15 Oct 2024 13:21:20 +0200 Subject: [PATCH 7/9] chore: Update imports --- .../main/settings/SettingsDataManagementMatomoScreen.kt | 2 +- .../screen/main/settings/SettingsDataManagementScreen.kt | 8 ++++---- .../main/settings/SettingsDataManagementSentryScreen.kt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt index 8ae113590..d1ceae32f 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt @@ -36,7 +36,7 @@ import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.SwissTransferTopAppBar import com.infomaniak.swisstransfer.ui.components.TopAppBarButton import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus -import com.infomaniak.swisstransfer.ui.images.illus.Matomo +import com.infomaniak.swisstransfer.ui.images.illus.matomo.Matomo import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt index 8f9b03c5a..ea1ab1021 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt @@ -35,9 +35,9 @@ import com.infomaniak.swisstransfer.ui.components.SwissTransferTopAppBar import com.infomaniak.swisstransfer.ui.components.TopAppBarButton import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus -import com.infomaniak.swisstransfer.ui.images.icons.Matomo -import com.infomaniak.swisstransfer.ui.images.icons.Sentry -import com.infomaniak.swisstransfer.ui.images.illus.DataProtection +import com.infomaniak.swisstransfer.ui.images.icons.matomo.Matomo +import com.infomaniak.swisstransfer.ui.images.icons.sentry.Sentry +import com.infomaniak.swisstransfer.ui.images.illus.dataProtection.DataProtection import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold import com.infomaniak.swisstransfer.ui.screen.main.settings.SettingsOptionScreens.* import com.infomaniak.swisstransfer.ui.screen.main.settings.components.EndIconType.CHEVRON @@ -65,7 +65,7 @@ fun SettingsDataManagementScreen( horizontalAlignment = Alignment.CenterHorizontally, ) { Image( - imageVector = AppIllus.DataProtection, // TODO: Handle dark theme + imageVector = AppIllus.DataProtection.image(), contentDescription = null, modifier = Modifier.padding(Margin.Medium), ) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt index 469d295be..3bcc4ffd6 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt @@ -36,7 +36,7 @@ import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.SwissTransferTopAppBar import com.infomaniak.swisstransfer.ui.components.TopAppBarButton import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus -import com.infomaniak.swisstransfer.ui.images.illus.Sentry +import com.infomaniak.swisstransfer.ui.images.illus.sentry.Sentry import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme From 063507f7e19ec63e6c0b0db9fbd51a14fc18592a Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Thu, 17 Oct 2024 14:21:21 +0200 Subject: [PATCH 8/9] feat: Use `@PreviewAllWindows` --- .../main/settings/SettingsDataManagementMatomoScreen.kt | 6 +++--- .../ui/screen/main/settings/SettingsDataManagementScreen.kt | 6 +++--- .../main/settings/SettingsDataManagementSentryScreen.kt | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt index d1ceae32f..3a91ea78e 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt @@ -40,7 +40,7 @@ import com.infomaniak.swisstransfer.ui.images.illus.matomo.Matomo import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun SettingsDataManagementMatomoScreen(navigateBack: (() -> Unit)?) { @@ -92,9 +92,9 @@ fun SettingsDataManagementMatomoScreen(navigateBack: (() -> Unit)?) { } } -@PreviewSmallWindow +@PreviewAllWindows @Composable -private fun SettingsDataManagementMatomoScreenPreview() { +private fun Preview() { SwissTransferTheme { Surface { SettingsDataManagementMatomoScreen {} diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt index ea1ab1021..b59396bca 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt @@ -45,7 +45,7 @@ import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingIt import com.infomaniak.swisstransfer.ui.theme.Dimens import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun SettingsDataManagementScreen( @@ -108,9 +108,9 @@ fun SettingsDataManagementScreen( } } -@PreviewSmallWindow +@PreviewAllWindows @Composable -private fun SettingsDataManagementScreenPreview() { +private fun Preview() { SwissTransferTheme { Surface { SettingsDataManagementScreen({}, {}) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt index 3bcc4ffd6..84af6dfcb 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt @@ -40,7 +40,7 @@ import com.infomaniak.swisstransfer.ui.images.illus.sentry.Sentry import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun SettingsDataManagementSentryScreen(navigateBack: (() -> Unit)?) { @@ -92,9 +92,9 @@ fun SettingsDataManagementSentryScreen(navigateBack: (() -> Unit)?) { } } -@PreviewSmallWindow +@PreviewAllWindows @Composable -private fun SettingsDataManagementSentryScreenPreview() { +private fun Preview() { SwissTransferTheme { Surface { SettingsDataManagementSentryScreen {} From 60606aa098dd2bac0a4b9fe7572c0ee9ebe200cc Mon Sep 17 00:00:00 2001 From: Vincent TE Date: Mon, 4 Nov 2024 09:11:29 +0100 Subject: [PATCH 9/9] review: Remove DATA_SOURCE_CODE --- .../main/settings/SettingsDataManagementScreen.kt | 11 +++++++++-- .../ui/screen/main/settings/SettingsScreen.kt | 2 +- .../screen/main/settings/SettingsScreenWrapper.kt | 13 ++----------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt index b59396bca..204b810fd 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt @@ -28,6 +28,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.SharpRippleButton @@ -39,19 +40,25 @@ import com.infomaniak.swisstransfer.ui.images.icons.matomo.Matomo import com.infomaniak.swisstransfer.ui.images.icons.sentry.Sentry import com.infomaniak.swisstransfer.ui.images.illus.dataProtection.DataProtection import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold -import com.infomaniak.swisstransfer.ui.screen.main.settings.SettingsOptionScreens.* +import com.infomaniak.swisstransfer.ui.screen.main.settings.SettingsOptionScreens.DATA_MANAGEMENT_MATOMO +import com.infomaniak.swisstransfer.ui.screen.main.settings.SettingsOptionScreens.DATA_MANAGEMENT_SENTRY import com.infomaniak.swisstransfer.ui.screen.main.settings.components.EndIconType.CHEVRON import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingItem import com.infomaniak.swisstransfer.ui.theme.Dimens import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows +import com.infomaniak.swisstransfer.ui.utils.openUrl @Composable fun SettingsDataManagementScreen( navigateBack: (() -> Unit)?, onItemClick: (SettingsOptionScreens) -> Unit, ) { + + val context = LocalContext.current + val sourceCodeURL = stringResource(R.string.urlSourceCode) // TODO: Update this URL when we know what we want + SmallWindowTopAppBarScaffold( smallWindowTopAppBar = { SwissTransferTopAppBar( @@ -77,7 +84,7 @@ fun SettingsDataManagementScreen( ) SharpRippleButton( modifier = Modifier.fillMaxWidth(), - onClick = { onItemClick(DATA_MANAGEMENT_SOURCE_CODE) }, + onClick = { context.openUrl(sourceCodeURL) }, ) { Text( text = stringResource(R.string.settingsDataManagementSourceCode), diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt index 338d94fa1..0a2a68384 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt @@ -191,7 +191,7 @@ enum class SettingsOptionScreens { THEME, NOTIFICATIONS, VALIDITY_PERIOD, DOWNLOAD_LIMIT, EMAIL_LANGUAGE, DISCOVER_INFOMANIAK, SHARE_IDEAS, GIVE_FEEDBACK, - DATA_MANAGEMENT, DATA_MANAGEMENT_SOURCE_CODE, DATA_MANAGEMENT_MATOMO, DATA_MANAGEMENT_SENTRY, + DATA_MANAGEMENT, DATA_MANAGEMENT_MATOMO, DATA_MANAGEMENT_SENTRY, } @PreviewAllWindows diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt index 69d117fd6..838f23ce2 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt @@ -123,7 +123,6 @@ private fun DetailPane( emailLanguage: GetSetCallbacks, ) { var lastSelectedScreen by rememberSaveable { mutableStateOf(null) } - val context = LocalContext.current val destination = navigator.currentDestination?.content ?: lastSelectedScreen navigator.currentDestination?.content?.let { lastSelectedScreen = it } @@ -131,9 +130,6 @@ private fun DetailPane( val navigateBackCallback: () -> Unit = { navigator.navigateBack() } val navigateBack: (() -> Unit)? = if (navigator.canNavigateBack()) navigateBackCallback else null - // TODO: Update this URL when we know what we want. - val sourceCodeURL = stringResource(R.string.urlSourceCode) - when (destination) { THEME -> SettingsThemeScreen( theme = theme.get(), @@ -158,12 +154,8 @@ private fun DetailPane( DATA_MANAGEMENT -> SettingsDataManagementScreen( navigateBack = navigateBack, onItemClick = { item -> - if (item == DATA_MANAGEMENT_SOURCE_CODE) { - context.openUrl(sourceCodeURL) - } else { - // Navigate to the detail pane with the passed item - navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, item) - } + // Navigate to the detail pane with the passed item + navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, item) }, ) DATA_MANAGEMENT_MATOMO -> SettingsDataManagementMatomoScreen(navigateBack) @@ -172,7 +164,6 @@ private fun DetailPane( DISCOVER_INFOMANIAK, SHARE_IDEAS, GIVE_FEEDBACK, - DATA_MANAGEMENT_SOURCE_CODE -> Unit null -> NoSelectionEmptyState() } }