Skip to content

Commit c6fb2c0

Browse files
authored
Merge pull request #5161 from element-hq/feature/bma/movePushHistory
Move push history entry point from notification settings to developer settings
2 parents e1095c0 + 7271fe6 commit c6fb2c0

13 files changed

+64
-53
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
}

features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsViewTest.kt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ class DeveloperSettingsViewTest {
5252
}
5353
}
5454

55+
@Config(qualifiers = "h1500dp")
56+
@Test
57+
fun `clicking on push history notification invokes the expected callback`() {
58+
val eventsRecorder = EventsRecorder<DeveloperSettingsEvents>(expectEvents = false)
59+
ensureCalledOnce {
60+
rule.setDeveloperSettingsView(
61+
state = aDeveloperSettingsState(
62+
eventSink = eventsRecorder
63+
),
64+
onPushHistoryClick = it
65+
)
66+
rule.clickOn(R.string.troubleshoot_notifications_entry_point_push_history_title)
67+
}
68+
}
69+
5570
@Config(qualifiers = "h1500dp")
5671
@Test
5772
fun `clicking on element call url open the dialogs and submit emits the expected event`() {
@@ -68,7 +83,7 @@ class DeveloperSettingsViewTest {
6883
eventsRecorder.assertSingle(DeveloperSettingsEvents.SetCustomElementCallBaseUrl("https://call.element.dev"))
6984
}
7085

71-
@Config(qualifiers = "h1200dp")
86+
@Config(qualifiers = "h2000dp")
7287
@Test
7388
fun `clicking on open showkase invokes the expected callback`() {
7489
val eventsRecorder = EventsRecorder<DeveloperSettingsEvents>(expectEvents = false)
@@ -97,7 +112,7 @@ class DeveloperSettingsViewTest {
97112
eventsRecorder.assertSingle(DeveloperSettingsEvents.SetTracingLogLevel(LogLevelItem.DEBUG))
98113
}
99114

100-
@Config(qualifiers = "h1700dp")
115+
@Config(qualifiers = "h2000dp")
101116
@Test
102117
fun `clicking on clear cache emits the expected event`() {
103118
val eventsRecorder = EventsRecorder<DeveloperSettingsEvents>()
@@ -114,12 +129,14 @@ class DeveloperSettingsViewTest {
114129
private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setDeveloperSettingsView(
115130
state: DeveloperSettingsState,
116131
onOpenShowkase: () -> Unit = EnsureNeverCalled(),
132+
onPushHistoryClick: () -> Unit = EnsureNeverCalled(),
117133
onBackClick: () -> Unit = EnsureNeverCalled()
118134
) {
119135
setContent {
120136
DeveloperSettingsView(
121137
state = state,
122138
onOpenShowkase = onOpenShowkase,
139+
onPushHistoryClick = onPushHistoryClick,
123140
onBackClick = onBackClick,
124141
)
125142
}

features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsViewTest.kt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,6 @@ class NotificationSettingsViewTest {
6666
eventsRecorder.assertSingle(NotificationSettingsEvents.RefreshSystemNotificationsEnabled)
6767
}
6868

69-
@Config(qualifiers = "h1024dp")
70-
@Test
71-
fun `clicking on push history notification invokes the expected callback`() {
72-
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
73-
ensureCalledOnce {
74-
rule.setNotificationSettingsView(
75-
state = aValidNotificationSettingsState(
76-
eventSink = eventsRecorder
77-
),
78-
onPushHistoryClick = it
79-
)
80-
rule.clickOn(R.string.troubleshoot_notifications_entry_point_push_history_title)
81-
}
82-
eventsRecorder.assertSingle(NotificationSettingsEvents.RefreshSystemNotificationsEnabled)
83-
}
84-
8569
@Config(qualifiers = "h1024dp")
8670
@Test
8771
fun `clicking on group chats invokes the expected callback`() {
@@ -300,15 +284,13 @@ private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setNotif
300284
state: NotificationSettingsState,
301285
onOpenEditDefault: (isOneToOne: Boolean) -> Unit = EnsureNeverCalledWithParam(),
302286
onTroubleshootNotificationsClick: () -> Unit = EnsureNeverCalled(),
303-
onPushHistoryClick: () -> Unit = EnsureNeverCalled(),
304287
onBackClick: () -> Unit = EnsureNeverCalled(),
305288
) {
306289
setContent {
307290
NotificationSettingsView(
308291
state = state,
309292
onOpenEditDefault = onOpenEditDefault,
310293
onTroubleshootNotificationsClick = onTroubleshootNotificationsClick,
311-
onPushHistoryClick = onPushHistoryClick,
312294
onBackClick = onBackClick,
313295
)
314296
}
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)