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..3a91ea78e
--- /dev/null
+++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt
@@ -0,0 +1,103 @@
+/*
+ * 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.*
+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
+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.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.PreviewAllWindows
+
+@Composable
+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(
+ titleRes = R.string.matomo,
+ navigationMenu = TopAppBarButton.backButton(navigateBack ?: {}),
+ )
+ },
+ ) {
+ Column(
+ modifier = Modifier.verticalScroll(rememberScrollState()),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ ) {
+ Image(
+ imageVector = AppIllus.Matomo.image(),
+ contentDescription = null,
+ modifier = Modifier.padding(Margin.Medium),
+ )
+ Text(
+ text = stringResource(R.string.settingsMatomoDescription),
+ style = SwissTransferTheme.typography.bodyRegular,
+ 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 },
+ )
+ }
+ }
+ }
+}
+
+@PreviewAllWindows
+@Composable
+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
new file mode 100644
index 000000000..204b810fd
--- /dev/null
+++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt
@@ -0,0 +1,126 @@
+/*
+ * 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.platform.LocalContext
+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.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.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(
+ titleRes = R.string.settingsOptionDataManagement,
+ navigationMenu = TopAppBarButton.backButton(navigateBack ?: {}),
+ )
+ },
+ ) {
+ Column(
+ modifier = Modifier.verticalScroll(rememberScrollState()),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ ) {
+ Image(
+ imageVector = AppIllus.DataProtection.image(),
+ 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 = { context.openUrl(sourceCodeURL) },
+ ) {
+ 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 = { onItemClick(DATA_MANAGEMENT_MATOMO) },
+ )
+ SettingItem(
+ titleRes = R.string.sentry,
+ isSelected = { false },
+ icon = AppIcons.Sentry.image(),
+ endIcon = CHEVRON,
+ shouldTintIcon = false,
+ onClick = { onItemClick(DATA_MANAGEMENT_SENTRY) },
+ )
+ }
+ }
+}
+
+@PreviewAllWindows
+@Composable
+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
new file mode 100644
index 000000000..84af6dfcb
--- /dev/null
+++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt
@@ -0,0 +1,103 @@
+/*
+ * 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.*
+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
+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.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.PreviewAllWindows
+
+@Composable
+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(
+ titleRes = R.string.sentry,
+ navigationMenu = TopAppBarButton.backButton(navigateBack ?: {}),
+ )
+ },
+ ) {
+ Column(
+ modifier = Modifier.verticalScroll(rememberScrollState()),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ ) {
+ Image(
+ imageVector = AppIllus.Sentry.image(),
+ contentDescription = null,
+ modifier = Modifier.padding(Margin.Medium),
+ )
+ Text(
+ text = stringResource(R.string.settingsSentryDescription),
+ style = SwissTransferTheme.typography.bodyRegular,
+ 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 },
+ )
+ }
+ }
+ }
+}
+
+@PreviewAllWindows
+@Composable
+private fun Preview() {
+ SwissTransferTheme {
+ Surface {
+ SettingsDataManagementSentryScreen {}
+ }
+ }
+}
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..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
@@ -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, 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 ebb8ed197..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
@@ -151,10 +151,19 @@ private fun DetailPane(
navigateBack = navigateBack,
onEmailLanguageChange = { emailLanguage.set(it) },
)
+ DATA_MANAGEMENT -> SettingsDataManagementScreen(
+ navigateBack = navigateBack,
+ onItemClick = { item ->
+ // 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,
null -> NoSelectionEmptyState()
}
}
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))
}