From a4373aeea4e3265c0dfa4b3eae25565d154adfc2 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 12 Aug 2025 17:32:03 +0200 Subject: [PATCH] Move push history entry point from notification settings to developer settings. Closes #5159 --- .../preferences/impl/PreferencesFlowNode.kt | 11 ++++++----- .../impl/developer/DeveloperSettingsNode.kt | 12 ++++++++++++ .../impl/developer/DeveloperSettingsView.kt | 15 +++++++++++++++ .../notifications/NotificationSettingsNode.kt | 6 ------ .../notifications/NotificationSettingsView.kt | 10 ---------- 5 files changed, 33 insertions(+), 21 deletions(-) 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 234b4c683b..b38b835f36 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 @@ -167,7 +167,12 @@ class PreferencesFlowNode @AssistedInject constructor( createNode(buildContext, plugins = listOf(callback)) } NavTarget.DeveloperSettings -> { - createNode(buildContext) + val developerSettingsCallback = object : DeveloperSettingsNode.Callback { + override fun onPushHistoryClick() { + backstack.push(NavTarget.PushHistory) + } + } + createNode(buildContext, listOf(developerSettingsCallback)) } NavTarget.About -> { val callback = object : AboutNode.Callback { @@ -189,10 +194,6 @@ class PreferencesFlowNode @AssistedInject constructor( override fun onTroubleshootNotificationsClick() { backstack.push(NavTarget.TroubleshootNotifications) } - - override fun onPushHistoryClick() { - backstack.push(NavTarget.PushHistory) - } } createNode(buildContext, listOf(notificationSettingsCallback)) } diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsNode.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsNode.kt index fafe5fc920..392a6af903 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsNode.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsNode.kt @@ -14,6 +14,7 @@ import com.airbnb.android.showkase.models.Showkase import com.bumble.appyx.core.modality.BuildContext import com.bumble.appyx.core.node.Node import com.bumble.appyx.core.plugin.Plugin +import com.bumble.appyx.core.plugin.plugins import dagger.assisted.Assisted import dagger.assisted.AssistedInject import io.element.android.anvilannotations.ContributesNode @@ -26,6 +27,16 @@ class DeveloperSettingsNode @AssistedInject constructor( @Assisted plugins: List, private val presenter: DeveloperSettingsPresenter, ) : Node(buildContext, plugins = plugins) { + interface Callback : Plugin { + fun onPushHistoryClick() + } + + private val callbacks = plugins() + + private fun onPushHistoryClick() { + callbacks.forEach { it.onPushHistoryClick() } + } + @Composable override fun View(modifier: Modifier) { val activity = requireNotNull(LocalActivity.current) @@ -39,6 +50,7 @@ class DeveloperSettingsNode @AssistedInject constructor( state = state, modifier = modifier, onOpenShowkase = ::openShowkase, + onPushHistoryClick = ::onPushHistoryClick, onBackClick = ::navigateUp ) } diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsView.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsView.kt index 9a9cc61d68..e00b178dee 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsView.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsView.kt @@ -42,6 +42,7 @@ import kotlinx.collections.immutable.toPersistentList fun DeveloperSettingsView( state: DeveloperSettingsState, onOpenShowkase: () -> Unit, + onPushHistoryClick: () -> Unit, onBackClick: () -> Unit, modifier: Modifier = Modifier, ) { @@ -57,6 +58,7 @@ fun DeveloperSettingsView( ) { FeatureListContent(state) } + NotificationCategory(onPushHistoryClick) ElementCallCategory(state = state) PreferenceCategory(title = "Rust SDK") { @@ -159,6 +161,18 @@ private fun ElementCallCategory( } } +@Composable +private fun NotificationCategory(onPushHistoryClick: () -> Unit) { + PreferenceCategory(title = stringResource(id = R.string.screen_notification_settings_title)) { + ListItem( + headlineContent = { + Text(stringResource(R.string.troubleshoot_notifications_entry_point_push_history_title)) + }, + onClick = onPushHistoryClick, + ) + } +} + @Composable private fun FeatureListContent( state: DeveloperSettingsState, @@ -179,6 +193,7 @@ internal fun DeveloperSettingsViewPreview(@PreviewParameter(DeveloperSettingsSta DeveloperSettingsView( state = state, onOpenShowkase = {}, + onPushHistoryClick = {}, onBackClick = {} ) } diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsNode.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsNode.kt index 75f38f60ee..15a6afcd89 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsNode.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsNode.kt @@ -27,7 +27,6 @@ class NotificationSettingsNode @AssistedInject constructor( interface Callback : Plugin { fun editDefaultNotificationMode(isOneToOne: Boolean) fun onTroubleshootNotificationsClick() - fun onPushHistoryClick() } private val callbacks = plugins() @@ -40,10 +39,6 @@ class NotificationSettingsNode @AssistedInject constructor( callbacks.forEach { it.onTroubleshootNotificationsClick() } } - private fun onPushHistoryClick() { - callbacks.forEach { it.onPushHistoryClick() } - } - @Composable override fun View(modifier: Modifier) { val state = presenter.present() @@ -52,7 +47,6 @@ class NotificationSettingsNode @AssistedInject constructor( onOpenEditDefault = { openEditDefault(isOneToOne = it) }, onBackClick = ::navigateUp, onTroubleshootNotificationsClick = ::onTroubleshootNotificationsClick, - onPushHistoryClick = ::onPushHistoryClick, modifier = modifier, ) } diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt index f73fecaf3c..26b2de590e 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt @@ -51,7 +51,6 @@ fun NotificationSettingsView( state: NotificationSettingsState, onOpenEditDefault: (isOneToOne: Boolean) -> Unit, onTroubleshootNotificationsClick: () -> Unit, - onPushHistoryClick: () -> Unit, onBackClick: () -> Unit, modifier: Modifier = Modifier, ) { @@ -84,7 +83,6 @@ fun NotificationSettingsView( // onCallsNotificationsChanged = { state.eventSink(NotificationSettingsEvents.SetCallNotificationsEnabled(it)) }, onInviteForMeNotificationsChange = { state.eventSink(NotificationSettingsEvents.SetInviteForMeNotificationsEnabled(it)) }, onTroubleshootNotificationsClick = onTroubleshootNotificationsClick, - onPushHistoryClick = onPushHistoryClick, ) } AsyncActionView( @@ -108,7 +106,6 @@ private fun NotificationSettingsContentView( // onCallsNotificationsChanged: (Boolean) -> Unit, onInviteForMeNotificationsChange: (Boolean) -> Unit, onTroubleshootNotificationsClick: () -> Unit, - onPushHistoryClick: () -> Unit, ) { val context = LocalContext.current val systemSettings: NotificationSettingsState.AppSettings = state.appSettings @@ -207,12 +204,6 @@ private fun NotificationSettingsContentView( }, onClick = onTroubleshootNotificationsClick ) - ListItem( - headlineContent = { - Text(stringResource(R.string.troubleshoot_notifications_entry_point_push_history_title)) - }, - onClick = onPushHistoryClick - ) } if (state.showAdvancedSettings) { PreferenceCategory(title = stringResource(id = CommonStrings.common_advanced_settings)) { @@ -313,6 +304,5 @@ internal fun NotificationSettingsViewPreview(@PreviewParameter(NotificationSetti onBackClick = {}, onOpenEditDefault = {}, onTroubleshootNotificationsClick = {}, - onPushHistoryClick = {}, ) }