From e8b80b9a551b269a7690c1b759d5f9d2a7216bfd Mon Sep 17 00:00:00 2001 From: yostyle Date: Tue, 8 Aug 2023 15:22:49 +0200 Subject: [PATCH] Add Notifications section in app settings --- changelog.d/510.misc | 1 + .../features/preferences/impl/PreferencesFlowNode.kt | 4 ++++ .../features/preferences/impl/root/PreferencesRootNode.kt | 6 ++++++ .../features/preferences/impl/root/PreferencesRootView.kt | 8 ++++++++ 4 files changed, 19 insertions(+) create mode 100644 changelog.d/510.misc diff --git a/changelog.d/510.misc b/changelog.d/510.misc new file mode 100644 index 0000000000..556aeab74f --- /dev/null +++ b/changelog.d/510.misc @@ -0,0 +1 @@ +Add a sub-screen "Notifications" in the existing application Settings diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/PreferencesFlowNode.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/PreferencesFlowNode.kt index e5b8254488..66f9d45ebd 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/PreferencesFlowNode.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/PreferencesFlowNode.kt @@ -90,6 +90,10 @@ class PreferencesFlowNode @AssistedInject constructor( override fun onOpenDeveloperSettings() { backstack.push(NavTarget.DeveloperSettings) } + + override fun onOpenNotificationSettings() { + TODO("Not yet implemented") + } } createNode(buildContext, plugins = listOf(callback)) } diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootNode.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootNode.kt index e90569b40e..0f297d14dd 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootNode.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootNode.kt @@ -44,6 +44,7 @@ class PreferencesRootNode @AssistedInject constructor( fun onOpenAnalytics() fun onOpenAbout() fun onOpenDeveloperSettings() + fun onOpenNotificationSettings() } private fun onOpenBugReport() { @@ -72,6 +73,10 @@ class PreferencesRootNode @AssistedInject constructor( } } + private fun onOpenNotificationSettings() { + plugins().forEach { it.onOpenNotificationSettings() } + } + @Composable override fun View(modifier: Modifier) { val state = presenter.present() @@ -87,6 +92,7 @@ class PreferencesRootNode @AssistedInject constructor( onOpenDeveloperSettings = this::onOpenDeveloperSettings, onSuccessLogout = { onSuccessLogout(activity, it) }, onManageAccountClicked = { onManageAccountClicked(activity, state.accountManagementUrl) }, + onOpenNotificationSettings = this::onOpenNotificationSettings ) } diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt index c24a2ec875..24f489628c 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt @@ -24,6 +24,7 @@ import androidx.compose.material.icons.outlined.DeveloperMode import androidx.compose.material.icons.outlined.Help import androidx.compose.material.icons.outlined.InsertChart import androidx.compose.material.icons.outlined.ManageAccounts +import androidx.compose.material.icons.outlined.Notifications import androidx.compose.material.icons.outlined.VerifiedUser import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -58,6 +59,7 @@ fun PreferencesRootView( onOpenAbout: () -> Unit, onOpenDeveloperSettings: () -> Unit, onSuccessLogout: (String?) -> Unit, + onOpenNotificationSettings: () -> Unit, modifier: Modifier = Modifier, ) { val snackbarHostState = rememberSnackbarHostState(snackbarMessage = state.snackbarMessage) @@ -92,6 +94,11 @@ fun PreferencesRootView( onClick = onOpenAnalytics, ) } + PreferenceText( + title = "Notifications", + icon = Icons.Outlined.Notifications, + onClick = onOpenNotificationSettings, + ) PreferenceText( title = stringResource(id = CommonStrings.action_report_bug), icon = Icons.Outlined.BugReport, @@ -153,5 +160,6 @@ private fun ContentToPreview(matrixUser: MatrixUser) { onVerifyClicked = {}, onSuccessLogout = {}, onManageAccountClicked = {}, + onOpenNotificationSettings = {}, ) }