Browse Source

Add Notifications section in app settings

pull/1037/head
yostyle 1 year ago
parent
commit
e8b80b9a55
  1. 1
      changelog.d/510.misc
  2. 4
      features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/PreferencesFlowNode.kt
  3. 6
      features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootNode.kt
  4. 8
      features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt

1
changelog.d/510.misc

@ -0,0 +1 @@
Add a sub-screen "Notifications" in the existing application Settings

4
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() { override fun onOpenDeveloperSettings() {
backstack.push(NavTarget.DeveloperSettings) backstack.push(NavTarget.DeveloperSettings)
} }
override fun onOpenNotificationSettings() {
TODO("Not yet implemented")
}
} }
createNode<PreferencesRootNode>(buildContext, plugins = listOf(callback)) createNode<PreferencesRootNode>(buildContext, plugins = listOf(callback))
} }

6
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 onOpenAnalytics()
fun onOpenAbout() fun onOpenAbout()
fun onOpenDeveloperSettings() fun onOpenDeveloperSettings()
fun onOpenNotificationSettings()
} }
private fun onOpenBugReport() { private fun onOpenBugReport() {
@ -72,6 +73,10 @@ class PreferencesRootNode @AssistedInject constructor(
} }
} }
private fun onOpenNotificationSettings() {
plugins<Callback>().forEach { it.onOpenNotificationSettings() }
}
@Composable @Composable
override fun View(modifier: Modifier) { override fun View(modifier: Modifier) {
val state = presenter.present() val state = presenter.present()
@ -87,6 +92,7 @@ class PreferencesRootNode @AssistedInject constructor(
onOpenDeveloperSettings = this::onOpenDeveloperSettings, onOpenDeveloperSettings = this::onOpenDeveloperSettings,
onSuccessLogout = { onSuccessLogout(activity, it) }, onSuccessLogout = { onSuccessLogout(activity, it) },
onManageAccountClicked = { onManageAccountClicked(activity, state.accountManagementUrl) }, onManageAccountClicked = { onManageAccountClicked(activity, state.accountManagementUrl) },
onOpenNotificationSettings = this::onOpenNotificationSettings
) )
} }

8
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.Help
import androidx.compose.material.icons.outlined.InsertChart import androidx.compose.material.icons.outlined.InsertChart
import androidx.compose.material.icons.outlined.ManageAccounts import androidx.compose.material.icons.outlined.ManageAccounts
import androidx.compose.material.icons.outlined.Notifications
import androidx.compose.material.icons.outlined.VerifiedUser import androidx.compose.material.icons.outlined.VerifiedUser
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@ -58,6 +59,7 @@ fun PreferencesRootView(
onOpenAbout: () -> Unit, onOpenAbout: () -> Unit,
onOpenDeveloperSettings: () -> Unit, onOpenDeveloperSettings: () -> Unit,
onSuccessLogout: (String?) -> Unit, onSuccessLogout: (String?) -> Unit,
onOpenNotificationSettings: () -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
val snackbarHostState = rememberSnackbarHostState(snackbarMessage = state.snackbarMessage) val snackbarHostState = rememberSnackbarHostState(snackbarMessage = state.snackbarMessage)
@ -92,6 +94,11 @@ fun PreferencesRootView(
onClick = onOpenAnalytics, onClick = onOpenAnalytics,
) )
} }
PreferenceText(
title = "Notifications",
icon = Icons.Outlined.Notifications,
onClick = onOpenNotificationSettings,
)
PreferenceText( PreferenceText(
title = stringResource(id = CommonStrings.action_report_bug), title = stringResource(id = CommonStrings.action_report_bug),
icon = Icons.Outlined.BugReport, icon = Icons.Outlined.BugReport,
@ -153,5 +160,6 @@ private fun ContentToPreview(matrixUser: MatrixUser) {
onVerifyClicked = {}, onVerifyClicked = {},
onSuccessLogout = {}, onSuccessLogout = {},
onManageAccountClicked = {}, onManageAccountClicked = {},
onOpenNotificationSettings = {},
) )
} }

Loading…
Cancel
Save