Skip to content

Commit 80345dc

Browse files
committed
Move push history entry point from notification settings to developer settings.
Closes #5159
1 parent 516c3cf commit 80345dc

File tree

5 files changed

+33
-21
lines changed

5 files changed

+33
-21
lines changed

features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/PreferencesFlowNode.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,12 @@ class PreferencesFlowNode @AssistedInject constructor(
167167
createNode<PreferencesRootNode>(buildContext, plugins = listOf(callback))
168168
}
169169
NavTarget.DeveloperSettings -> {
170-
createNode<DeveloperSettingsNode>(buildContext)
170+
val developerSettingsCallback = object : DeveloperSettingsNode.Callback {
171+
override fun onPushHistoryClick() {
172+
backstack.push(NavTarget.PushHistory)
173+
}
174+
}
175+
createNode<DeveloperSettingsNode>(buildContext, listOf(developerSettingsCallback))
171176
}
172177
NavTarget.About -> {
173178
val callback = object : AboutNode.Callback {
@@ -189,10 +194,6 @@ class PreferencesFlowNode @AssistedInject constructor(
189194
override fun onTroubleshootNotificationsClick() {
190195
backstack.push(NavTarget.TroubleshootNotifications)
191196
}
192-
193-
override fun onPushHistoryClick() {
194-
backstack.push(NavTarget.PushHistory)
195-
}
196197
}
197198
createNode<NotificationSettingsNode>(buildContext, listOf(notificationSettingsCallback))
198199
}

features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsNode.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.airbnb.android.showkase.models.Showkase
1414
import com.bumble.appyx.core.modality.BuildContext
1515
import com.bumble.appyx.core.node.Node
1616
import com.bumble.appyx.core.plugin.Plugin
17+
import com.bumble.appyx.core.plugin.plugins
1718
import dagger.assisted.Assisted
1819
import dagger.assisted.AssistedInject
1920
import io.element.android.anvilannotations.ContributesNode
@@ -26,6 +27,16 @@ class DeveloperSettingsNode @AssistedInject constructor(
2627
@Assisted plugins: List<Plugin>,
2728
private val presenter: DeveloperSettingsPresenter,
2829
) : Node(buildContext, plugins = plugins) {
30+
interface Callback : Plugin {
31+
fun onPushHistoryClick()
32+
}
33+
34+
private val callbacks = plugins<Callback>()
35+
36+
private fun onPushHistoryClick() {
37+
callbacks.forEach { it.onPushHistoryClick() }
38+
}
39+
2940
@Composable
3041
override fun View(modifier: Modifier) {
3142
val activity = requireNotNull(LocalActivity.current)
@@ -39,6 +50,7 @@ class DeveloperSettingsNode @AssistedInject constructor(
3950
state = state,
4051
modifier = modifier,
4152
onOpenShowkase = ::openShowkase,
53+
onPushHistoryClick = ::onPushHistoryClick,
4254
onBackClick = ::navigateUp
4355
)
4456
}

features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsView.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import kotlinx.collections.immutable.toPersistentList
4242
fun DeveloperSettingsView(
4343
state: DeveloperSettingsState,
4444
onOpenShowkase: () -> Unit,
45+
onPushHistoryClick: () -> Unit,
4546
onBackClick: () -> Unit,
4647
modifier: Modifier = Modifier,
4748
) {
@@ -57,6 +58,7 @@ fun DeveloperSettingsView(
5758
) {
5859
FeatureListContent(state)
5960
}
61+
NotificationCategory(onPushHistoryClick)
6062
ElementCallCategory(state = state)
6163

6264
PreferenceCategory(title = "Rust SDK") {
@@ -159,6 +161,18 @@ private fun ElementCallCategory(
159161
}
160162
}
161163

164+
@Composable
165+
private fun NotificationCategory(onPushHistoryClick: () -> Unit) {
166+
PreferenceCategory(title = stringResource(id = R.string.screen_notification_settings_title)) {
167+
ListItem(
168+
headlineContent = {
169+
Text(stringResource(R.string.troubleshoot_notifications_entry_point_push_history_title))
170+
},
171+
onClick = onPushHistoryClick,
172+
)
173+
}
174+
}
175+
162176
@Composable
163177
private fun FeatureListContent(
164178
state: DeveloperSettingsState,
@@ -179,6 +193,7 @@ internal fun DeveloperSettingsViewPreview(@PreviewParameter(DeveloperSettingsSta
179193
DeveloperSettingsView(
180194
state = state,
181195
onOpenShowkase = {},
196+
onPushHistoryClick = {},
182197
onBackClick = {}
183198
)
184199
}

features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsNode.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class NotificationSettingsNode @AssistedInject constructor(
2727
interface Callback : Plugin {
2828
fun editDefaultNotificationMode(isOneToOne: Boolean)
2929
fun onTroubleshootNotificationsClick()
30-
fun onPushHistoryClick()
3130
}
3231

3332
private val callbacks = plugins<Callback>()
@@ -40,10 +39,6 @@ class NotificationSettingsNode @AssistedInject constructor(
4039
callbacks.forEach { it.onTroubleshootNotificationsClick() }
4140
}
4241

43-
private fun onPushHistoryClick() {
44-
callbacks.forEach { it.onPushHistoryClick() }
45-
}
46-
4742
@Composable
4843
override fun View(modifier: Modifier) {
4944
val state = presenter.present()
@@ -52,7 +47,6 @@ class NotificationSettingsNode @AssistedInject constructor(
5247
onOpenEditDefault = { openEditDefault(isOneToOne = it) },
5348
onBackClick = ::navigateUp,
5449
onTroubleshootNotificationsClick = ::onTroubleshootNotificationsClick,
55-
onPushHistoryClick = ::onPushHistoryClick,
5650
modifier = modifier,
5751
)
5852
}

features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ fun NotificationSettingsView(
5151
state: NotificationSettingsState,
5252
onOpenEditDefault: (isOneToOne: Boolean) -> Unit,
5353
onTroubleshootNotificationsClick: () -> Unit,
54-
onPushHistoryClick: () -> Unit,
5554
onBackClick: () -> Unit,
5655
modifier: Modifier = Modifier,
5756
) {
@@ -84,7 +83,6 @@ fun NotificationSettingsView(
8483
// onCallsNotificationsChanged = { state.eventSink(NotificationSettingsEvents.SetCallNotificationsEnabled(it)) },
8584
onInviteForMeNotificationsChange = { state.eventSink(NotificationSettingsEvents.SetInviteForMeNotificationsEnabled(it)) },
8685
onTroubleshootNotificationsClick = onTroubleshootNotificationsClick,
87-
onPushHistoryClick = onPushHistoryClick,
8886
)
8987
}
9088
AsyncActionView(
@@ -108,7 +106,6 @@ private fun NotificationSettingsContentView(
108106
// onCallsNotificationsChanged: (Boolean) -> Unit,
109107
onInviteForMeNotificationsChange: (Boolean) -> Unit,
110108
onTroubleshootNotificationsClick: () -> Unit,
111-
onPushHistoryClick: () -> Unit,
112109
) {
113110
val context = LocalContext.current
114111
val systemSettings: NotificationSettingsState.AppSettings = state.appSettings
@@ -207,12 +204,6 @@ private fun NotificationSettingsContentView(
207204
},
208205
onClick = onTroubleshootNotificationsClick
209206
)
210-
ListItem(
211-
headlineContent = {
212-
Text(stringResource(R.string.troubleshoot_notifications_entry_point_push_history_title))
213-
},
214-
onClick = onPushHistoryClick
215-
)
216207
}
217208
if (state.showAdvancedSettings) {
218209
PreferenceCategory(title = stringResource(id = CommonStrings.common_advanced_settings)) {
@@ -313,6 +304,5 @@ internal fun NotificationSettingsViewPreview(@PreviewParameter(NotificationSetti
313304
onBackClick = {},
314305
onOpenEditDefault = {},
315306
onTroubleshootNotificationsClick = {},
316-
onPushHistoryClick = {},
317307
)
318308
}

0 commit comments

Comments
 (0)