mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 10:32:34 +00:00
NotificationSettingsEvents -> NotificationSettingsEvent
This commit is contained in:
+24
-24
@@ -10,28 +10,28 @@ package io.element.android.features.preferences.impl.notifications
|
|||||||
|
|
||||||
import io.element.android.libraries.preferences.api.store.NotificationSound
|
import io.element.android.libraries.preferences.api.store.NotificationSound
|
||||||
|
|
||||||
sealed interface NotificationSettingsEvents {
|
sealed interface NotificationSettingsEvent {
|
||||||
data object RefreshSystemNotificationsEnabled : NotificationSettingsEvents
|
data object RefreshSystemNotificationsEnabled : NotificationSettingsEvent
|
||||||
data class SetNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvents
|
data class SetNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvent
|
||||||
data class SetAtRoomNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvents
|
data class SetAtRoomNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvent
|
||||||
data class SetCallNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvents
|
data class SetCallNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvent
|
||||||
data class SetInviteForMeNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvents
|
data class SetInviteForMeNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvent
|
||||||
data object FixConfigurationMismatch : NotificationSettingsEvents
|
data object FixConfigurationMismatch : NotificationSettingsEvent
|
||||||
data object ClearConfigurationMismatchError : NotificationSettingsEvents
|
data object ClearConfigurationMismatchError : NotificationSettingsEvent
|
||||||
data object ClearNotificationChangeError : NotificationSettingsEvents
|
data object ClearNotificationChangeError : NotificationSettingsEvent
|
||||||
data object ChangePushProvider : NotificationSettingsEvents
|
data object ChangePushProvider : NotificationSettingsEvent
|
||||||
data object CancelChangePushProvider : NotificationSettingsEvents
|
data object CancelChangePushProvider : NotificationSettingsEvent
|
||||||
data class SetPushProvider(val index: Int) : NotificationSettingsEvents
|
data class SetPushProvider(val index: Int) : NotificationSettingsEvent
|
||||||
data class SetMessageSound(val sound: NotificationSound) : NotificationSettingsEvents
|
data class SetMessageSound(val sound: NotificationSound) : NotificationSettingsEvent
|
||||||
data class SetCallRingtone(val sound: NotificationSound) : NotificationSettingsEvents
|
data class SetCallRingtone(val sound: NotificationSound) : NotificationSettingsEvent
|
||||||
data object DismissMessageSoundCopyError : NotificationSettingsEvents
|
data object DismissMessageSoundCopyError : NotificationSettingsEvent
|
||||||
data object DismissCallRingtoneCopyError : NotificationSettingsEvents
|
data object DismissCallRingtoneCopyError : NotificationSettingsEvent
|
||||||
data object ShowMessageSoundDialog : NotificationSettingsEvents
|
data object ShowMessageSoundDialog : NotificationSettingsEvent
|
||||||
data object DismissMessageSoundDialog : NotificationSettingsEvents
|
data object DismissMessageSoundDialog : NotificationSettingsEvent
|
||||||
data class SelectMessageSoundPreset(val sound: NotificationSound) : NotificationSettingsEvents
|
data class SelectMessageSoundPreset(val sound: NotificationSound) : NotificationSettingsEvent
|
||||||
data object LaunchMessageSoundPicker : NotificationSettingsEvents
|
data object LaunchMessageSoundPicker : NotificationSettingsEvent
|
||||||
data object ShowCallRingtoneDialog : NotificationSettingsEvents
|
data object ShowCallRingtoneDialog : NotificationSettingsEvent
|
||||||
data object DismissCallRingtoneDialog : NotificationSettingsEvents
|
data object DismissCallRingtoneDialog : NotificationSettingsEvent
|
||||||
data class SelectCallRingtonePreset(val sound: NotificationSound) : NotificationSettingsEvents
|
data class SelectCallRingtonePreset(val sound: NotificationSound) : NotificationSettingsEvent
|
||||||
data object LaunchCallRingtonePicker : NotificationSettingsEvents
|
data object LaunchCallRingtonePicker : NotificationSettingsEvent
|
||||||
}
|
}
|
||||||
+24
-24
@@ -196,38 +196,38 @@ class NotificationSettingsPresenter(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleEvent(event: NotificationSettingsEvents) {
|
fun handleEvent(event: NotificationSettingsEvent) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is NotificationSettingsEvents.SetAtRoomNotificationsEnabled -> {
|
is NotificationSettingsEvent.SetAtRoomNotificationsEnabled -> {
|
||||||
localCoroutineScope.setAtRoomNotificationsEnabled(event.enabled, changeNotificationSettingAction)
|
localCoroutineScope.setAtRoomNotificationsEnabled(event.enabled, changeNotificationSettingAction)
|
||||||
}
|
}
|
||||||
is NotificationSettingsEvents.SetCallNotificationsEnabled -> {
|
is NotificationSettingsEvent.SetCallNotificationsEnabled -> {
|
||||||
localCoroutineScope.setCallNotificationsEnabled(event.enabled, changeNotificationSettingAction)
|
localCoroutineScope.setCallNotificationsEnabled(event.enabled, changeNotificationSettingAction)
|
||||||
}
|
}
|
||||||
is NotificationSettingsEvents.SetInviteForMeNotificationsEnabled -> {
|
is NotificationSettingsEvent.SetInviteForMeNotificationsEnabled -> {
|
||||||
localCoroutineScope.setInviteForMeNotificationsEnabled(event.enabled, changeNotificationSettingAction)
|
localCoroutineScope.setInviteForMeNotificationsEnabled(event.enabled, changeNotificationSettingAction)
|
||||||
}
|
}
|
||||||
is NotificationSettingsEvents.SetNotificationsEnabled -> sessionCoroutineScope.setNotificationsEnabled(userPushStore, event.enabled)
|
is NotificationSettingsEvent.SetNotificationsEnabled -> sessionCoroutineScope.setNotificationsEnabled(userPushStore, event.enabled)
|
||||||
NotificationSettingsEvents.ClearConfigurationMismatchError -> {
|
NotificationSettingsEvent.ClearConfigurationMismatchError -> {
|
||||||
matrixSettings.value = NotificationSettingsState.MatrixSettings.Invalid(fixFailed = false)
|
matrixSettings.value = NotificationSettingsState.MatrixSettings.Invalid(fixFailed = false)
|
||||||
}
|
}
|
||||||
NotificationSettingsEvents.FixConfigurationMismatch -> localCoroutineScope.fixConfigurationMismatch(matrixSettings)
|
NotificationSettingsEvent.FixConfigurationMismatch -> localCoroutineScope.fixConfigurationMismatch(matrixSettings)
|
||||||
NotificationSettingsEvents.RefreshSystemNotificationsEnabled -> {
|
NotificationSettingsEvent.RefreshSystemNotificationsEnabled -> {
|
||||||
systemNotificationsEnabled.value = systemNotificationsEnabledProvider.notificationsEnabled()
|
systemNotificationsEnabled.value = systemNotificationsEnabledProvider.notificationsEnabled()
|
||||||
refreshFullScreenIntentSettings++
|
refreshFullScreenIntentSettings++
|
||||||
}
|
}
|
||||||
NotificationSettingsEvents.ClearNotificationChangeError -> changeNotificationSettingAction.value = AsyncAction.Uninitialized
|
NotificationSettingsEvent.ClearNotificationChangeError -> changeNotificationSettingAction.value = AsyncAction.Uninitialized
|
||||||
NotificationSettingsEvents.ChangePushProvider -> showChangePushProviderDialog = true
|
NotificationSettingsEvent.ChangePushProvider -> showChangePushProviderDialog = true
|
||||||
NotificationSettingsEvents.CancelChangePushProvider -> showChangePushProviderDialog = false
|
NotificationSettingsEvent.CancelChangePushProvider -> showChangePushProviderDialog = false
|
||||||
is NotificationSettingsEvents.SetPushProvider -> localCoroutineScope.changePushProvider(distributors.getOrNull(event.index))
|
is NotificationSettingsEvent.SetPushProvider -> localCoroutineScope.changePushProvider(distributors.getOrNull(event.index))
|
||||||
is NotificationSettingsEvents.SetMessageSound -> applyMessageSound(
|
is NotificationSettingsEvent.SetMessageSound -> applyMessageSound(
|
||||||
sound = event.sound,
|
sound = event.sound,
|
||||||
sessionCoroutineScope = sessionCoroutineScope,
|
sessionCoroutineScope = sessionCoroutineScope,
|
||||||
onCopyError = { messageSoundCopyError = true },
|
onCopyError = { messageSoundCopyError = true },
|
||||||
onCopySuccess = { messageSoundCopyError = false },
|
onCopySuccess = { messageSoundCopyError = false },
|
||||||
onChannelFailure = { failure -> changeNotificationSettingAction.value = AsyncAction.Failure(failure) },
|
onChannelFailure = { failure -> changeNotificationSettingAction.value = AsyncAction.Failure(failure) },
|
||||||
)
|
)
|
||||||
is NotificationSettingsEvents.SelectMessageSoundPreset -> {
|
is NotificationSettingsEvent.SelectMessageSoundPreset -> {
|
||||||
showMessageSoundDialog = false
|
showMessageSoundDialog = false
|
||||||
applyMessageSound(
|
applyMessageSound(
|
||||||
sound = event.sound,
|
sound = event.sound,
|
||||||
@@ -237,13 +237,13 @@ class NotificationSettingsPresenter(
|
|||||||
onChannelFailure = { failure -> changeNotificationSettingAction.value = AsyncAction.Failure(failure) },
|
onChannelFailure = { failure -> changeNotificationSettingAction.value = AsyncAction.Failure(failure) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
NotificationSettingsEvents.ShowMessageSoundDialog -> showMessageSoundDialog = true
|
NotificationSettingsEvent.ShowMessageSoundDialog -> showMessageSoundDialog = true
|
||||||
NotificationSettingsEvents.DismissMessageSoundDialog -> showMessageSoundDialog = false
|
NotificationSettingsEvent.DismissMessageSoundDialog -> showMessageSoundDialog = false
|
||||||
NotificationSettingsEvents.LaunchMessageSoundPicker -> {
|
NotificationSettingsEvent.LaunchMessageSoundPicker -> {
|
||||||
showMessageSoundDialog = false
|
showMessageSoundDialog = false
|
||||||
pendingMessageSoundPickerLaunch++
|
pendingMessageSoundPickerLaunch++
|
||||||
}
|
}
|
||||||
is NotificationSettingsEvents.SetCallRingtone -> {
|
is NotificationSettingsEvent.SetCallRingtone -> {
|
||||||
legacyCallRingtone = null
|
legacyCallRingtone = null
|
||||||
applyCallRingtone(
|
applyCallRingtone(
|
||||||
sound = event.sound,
|
sound = event.sound,
|
||||||
@@ -253,7 +253,7 @@ class NotificationSettingsPresenter(
|
|||||||
onChannelFailure = { failure -> changeNotificationSettingAction.value = AsyncAction.Failure(failure) },
|
onChannelFailure = { failure -> changeNotificationSettingAction.value = AsyncAction.Failure(failure) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is NotificationSettingsEvents.SelectCallRingtonePreset -> {
|
is NotificationSettingsEvent.SelectCallRingtonePreset -> {
|
||||||
showCallRingtoneDialog = false
|
showCallRingtoneDialog = false
|
||||||
legacyCallRingtone = null
|
legacyCallRingtone = null
|
||||||
applyCallRingtone(
|
applyCallRingtone(
|
||||||
@@ -264,16 +264,16 @@ class NotificationSettingsPresenter(
|
|||||||
onChannelFailure = { failure -> changeNotificationSettingAction.value = AsyncAction.Failure(failure) },
|
onChannelFailure = { failure -> changeNotificationSettingAction.value = AsyncAction.Failure(failure) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
NotificationSettingsEvents.ShowCallRingtoneDialog -> showCallRingtoneDialog = true
|
NotificationSettingsEvent.ShowCallRingtoneDialog -> showCallRingtoneDialog = true
|
||||||
NotificationSettingsEvents.DismissCallRingtoneDialog -> showCallRingtoneDialog = false
|
NotificationSettingsEvent.DismissCallRingtoneDialog -> showCallRingtoneDialog = false
|
||||||
NotificationSettingsEvents.LaunchCallRingtonePicker -> {
|
NotificationSettingsEvent.LaunchCallRingtonePicker -> {
|
||||||
showCallRingtoneDialog = false
|
showCallRingtoneDialog = false
|
||||||
pendingCallRingtonePickerLaunch++
|
pendingCallRingtonePickerLaunch++
|
||||||
}
|
}
|
||||||
NotificationSettingsEvents.DismissMessageSoundCopyError -> {
|
NotificationSettingsEvent.DismissMessageSoundCopyError -> {
|
||||||
messageSoundCopyError = false
|
messageSoundCopyError = false
|
||||||
}
|
}
|
||||||
NotificationSettingsEvents.DismissCallRingtoneCopyError -> {
|
NotificationSettingsEvent.DismissCallRingtoneCopyError -> {
|
||||||
callRingtoneCopyError = false
|
callRingtoneCopyError = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -30,7 +30,7 @@ data class NotificationSettingsState(
|
|||||||
val showCallRingtoneDialog: Boolean,
|
val showCallRingtoneDialog: Boolean,
|
||||||
/**
|
/**
|
||||||
* One-shot trigger for launching the system ringtone picker. Each
|
* One-shot trigger for launching the system ringtone picker. Each
|
||||||
* [NotificationSettingsEvents.LaunchMessageSoundPicker] increments the value;
|
* [NotificationSettingsEvent.LaunchMessageSoundPicker] increments the value;
|
||||||
* the view watches this in `LaunchedEffect` and calls the launcher whenever it goes above 0.
|
* the view watches this in `LaunchedEffect` and calls the launcher whenever it goes above 0.
|
||||||
* **Always start at 0** in initial state, providers, and previews — a non-zero seed will
|
* **Always start at 0** in initial state, providers, and previews — a non-zero seed will
|
||||||
* auto-open the picker on screen entry.
|
* auto-open the picker on screen entry.
|
||||||
@@ -42,7 +42,7 @@ data class NotificationSettingsState(
|
|||||||
* auto-opens on screen entry.
|
* auto-opens on screen entry.
|
||||||
*/
|
*/
|
||||||
val pendingCallRingtonePickerLaunch: Int,
|
val pendingCallRingtonePickerLaunch: Int,
|
||||||
val eventSink: (NotificationSettingsEvents) -> Unit,
|
val eventSink: (NotificationSettingsEvent) -> Unit,
|
||||||
) {
|
) {
|
||||||
sealed interface MatrixSettings {
|
sealed interface MatrixSettings {
|
||||||
data object Uninitialized : MatrixSettings
|
data object Uninitialized : MatrixSettings
|
||||||
|
|||||||
+2
-2
@@ -101,7 +101,7 @@ fun aValidNotificationSettingsState(
|
|||||||
showCallRingtoneDialog: Boolean = false,
|
showCallRingtoneDialog: Boolean = false,
|
||||||
pendingMessageSoundPickerLaunch: Int = 0,
|
pendingMessageSoundPickerLaunch: Int = 0,
|
||||||
pendingCallRingtonePickerLaunch: Int = 0,
|
pendingCallRingtonePickerLaunch: Int = 0,
|
||||||
eventSink: (NotificationSettingsEvents) -> Unit = {},
|
eventSink: (NotificationSettingsEvent) -> Unit = {},
|
||||||
) = NotificationSettingsState(
|
) = NotificationSettingsState(
|
||||||
matrixSettings = NotificationSettingsState.MatrixSettings.Valid(
|
matrixSettings = NotificationSettingsState.MatrixSettings.Valid(
|
||||||
atRoomNotificationsEnabled = atRoomNotificationsEnabled,
|
atRoomNotificationsEnabled = atRoomNotificationsEnabled,
|
||||||
@@ -138,7 +138,7 @@ fun aValidNotificationSettingsState(
|
|||||||
|
|
||||||
fun aInvalidNotificationSettingsState(
|
fun aInvalidNotificationSettingsState(
|
||||||
fixFailed: Boolean = false,
|
fixFailed: Boolean = false,
|
||||||
eventSink: (NotificationSettingsEvents) -> Unit = {},
|
eventSink: (NotificationSettingsEvent) -> Unit = {},
|
||||||
) = NotificationSettingsState(
|
) = NotificationSettingsState(
|
||||||
matrixSettings = NotificationSettingsState.MatrixSettings.Invalid(
|
matrixSettings = NotificationSettingsState.MatrixSettings.Invalid(
|
||||||
fixFailed = fixFailed,
|
fixFailed = fixFailed,
|
||||||
|
|||||||
+25
-25
@@ -74,7 +74,7 @@ fun NotificationSettingsView(
|
|||||||
) {
|
) {
|
||||||
OnLifecycleEvent { _, event ->
|
OnLifecycleEvent { _, event ->
|
||||||
when (event) {
|
when (event) {
|
||||||
Lifecycle.Event.ON_RESUME -> state.eventSink.invoke(NotificationSettingsEvents.RefreshSystemNotificationsEnabled)
|
Lifecycle.Event.ON_RESUME -> state.eventSink.invoke(NotificationSettingsEvent.RefreshSystemNotificationsEnabled)
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,27 +86,27 @@ fun NotificationSettingsView(
|
|||||||
when (state.matrixSettings) {
|
when (state.matrixSettings) {
|
||||||
is NotificationSettingsState.MatrixSettings.Invalid -> InvalidNotificationSettingsView(
|
is NotificationSettingsState.MatrixSettings.Invalid -> InvalidNotificationSettingsView(
|
||||||
showError = state.matrixSettings.fixFailed,
|
showError = state.matrixSettings.fixFailed,
|
||||||
onContinueClick = { state.eventSink(NotificationSettingsEvents.FixConfigurationMismatch) },
|
onContinueClick = { state.eventSink(NotificationSettingsEvent.FixConfigurationMismatch) },
|
||||||
onDismissError = { state.eventSink(NotificationSettingsEvents.ClearConfigurationMismatchError) },
|
onDismissError = { state.eventSink(NotificationSettingsEvent.ClearConfigurationMismatchError) },
|
||||||
)
|
)
|
||||||
NotificationSettingsState.MatrixSettings.Uninitialized -> return@PreferencePage
|
NotificationSettingsState.MatrixSettings.Uninitialized -> return@PreferencePage
|
||||||
is NotificationSettingsState.MatrixSettings.Valid -> NotificationSettingsContentView(
|
is NotificationSettingsState.MatrixSettings.Valid -> NotificationSettingsContentView(
|
||||||
matrixSettings = state.matrixSettings,
|
matrixSettings = state.matrixSettings,
|
||||||
state = state,
|
state = state,
|
||||||
onNotificationsEnabledChange = { state.eventSink(NotificationSettingsEvents.SetNotificationsEnabled(it)) },
|
onNotificationsEnabledChange = { state.eventSink(NotificationSettingsEvent.SetNotificationsEnabled(it)) },
|
||||||
onGroupChatsClick = { onOpenEditDefault(false) },
|
onGroupChatsClick = { onOpenEditDefault(false) },
|
||||||
onDirectChatsClick = { onOpenEditDefault(true) },
|
onDirectChatsClick = { onOpenEditDefault(true) },
|
||||||
onMentionNotificationsChange = { state.eventSink(NotificationSettingsEvents.SetAtRoomNotificationsEnabled(it)) },
|
onMentionNotificationsChange = { state.eventSink(NotificationSettingsEvent.SetAtRoomNotificationsEnabled(it)) },
|
||||||
// TODO We are removing the call notification toggle until support for call notifications has been added
|
// TODO We are removing the call notification toggle until support for call notifications has been added
|
||||||
// onCallsNotificationsChanged = { state.eventSink(NotificationSettingsEvents.SetCallNotificationsEnabled(it)) },
|
// onCallsNotificationsChanged = { state.eventSink(NotificationSettingsEvent.SetCallNotificationsEnabled(it)) },
|
||||||
onInviteForMeNotificationsChange = { state.eventSink(NotificationSettingsEvents.SetInviteForMeNotificationsEnabled(it)) },
|
onInviteForMeNotificationsChange = { state.eventSink(NotificationSettingsEvent.SetInviteForMeNotificationsEnabled(it)) },
|
||||||
onTroubleshootNotificationsClick = onTroubleshootNotificationsClick,
|
onTroubleshootNotificationsClick = onTroubleshootNotificationsClick,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
AsyncActionView(
|
AsyncActionView(
|
||||||
async = state.changeNotificationSettingAction,
|
async = state.changeNotificationSettingAction,
|
||||||
errorMessage = { stringResource(R.string.screen_notification_settings_edit_failed_updating_default_mode) },
|
errorMessage = { stringResource(R.string.screen_notification_settings_edit_failed_updating_default_mode) },
|
||||||
onErrorDismiss = { state.eventSink(NotificationSettingsEvents.ClearNotificationChangeError) },
|
onErrorDismiss = { state.eventSink(NotificationSettingsEvent.ClearNotificationChangeError) },
|
||||||
onSuccess = {},
|
onSuccess = {},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -249,7 +249,7 @@ private fun NotificationSettingsContentView(
|
|||||||
},
|
},
|
||||||
onClick = {
|
onClick = {
|
||||||
if (state.currentPushDistributor.isReady()) {
|
if (state.currentPushDistributor.isReady()) {
|
||||||
state.eventSink(NotificationSettingsEvents.ChangePushProvider)
|
state.eventSink(NotificationSettingsEvent.ChangePushProvider)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -269,10 +269,10 @@ private fun NotificationSettingsContentView(
|
|||||||
initialSelection = state.availablePushDistributors.indexOf(state.currentPushDistributor.dataOrNull()),
|
initialSelection = state.availablePushDistributors.indexOf(state.currentPushDistributor.dataOrNull()),
|
||||||
onSelectOption = { index ->
|
onSelectOption = { index ->
|
||||||
state.eventSink(
|
state.eventSink(
|
||||||
NotificationSettingsEvents.SetPushProvider(index)
|
NotificationSettingsEvent.SetPushProvider(index)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
onDismissRequest = { state.eventSink(NotificationSettingsEvents.CancelChangePushProvider) },
|
onDismissRequest = { state.eventSink(NotificationSettingsEvent.CancelChangePushProvider) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -286,7 +286,7 @@ private fun SoundsPreferenceCategory(state: NotificationSettingsState) {
|
|||||||
type = RingtoneManager.TYPE_NOTIFICATION,
|
type = RingtoneManager.TYPE_NOTIFICATION,
|
||||||
current = state.messageSound.sound,
|
current = state.messageSound.sound,
|
||||||
defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI,
|
defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI,
|
||||||
onSoundPick = { sound -> state.eventSink(NotificationSettingsEvents.SetMessageSound(sound)) },
|
onSoundPick = { sound -> state.eventSink(NotificationSettingsEvent.SetMessageSound(sound)) },
|
||||||
)
|
)
|
||||||
// Skip the initial 0 emission so the picker doesn't auto-open on screen entry; only
|
// Skip the initial 0 emission so the picker doesn't auto-open on screen entry; only
|
||||||
// increments fired by LaunchMessageSoundPicker should launch it.
|
// increments fired by LaunchMessageSoundPicker should launch it.
|
||||||
@@ -298,11 +298,11 @@ private fun SoundsPreferenceCategory(state: NotificationSettingsState) {
|
|||||||
ListItem(
|
ListItem(
|
||||||
content = { Text(stringResource(id = R.string.screen_notification_settings_message_sound_label)) },
|
content = { Text(stringResource(id = R.string.screen_notification_settings_message_sound_label)) },
|
||||||
supportingContent = { Text(state.messageSound.displayName) },
|
supportingContent = { Text(state.messageSound.displayName) },
|
||||||
onClick = { state.eventSink(NotificationSettingsEvents.ShowMessageSoundDialog) },
|
onClick = { state.eventSink(NotificationSettingsEvent.ShowMessageSoundDialog) },
|
||||||
)
|
)
|
||||||
if (state.messageSound.copyError) {
|
if (state.messageSound.copyError) {
|
||||||
SoundCopyErrorRow(
|
SoundCopyErrorRow(
|
||||||
onDismissClick = { state.eventSink(NotificationSettingsEvents.DismissMessageSoundCopyError) },
|
onDismissClick = { state.eventSink(NotificationSettingsEvent.DismissMessageSoundCopyError) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (state.showMessageSoundDialog) {
|
if (state.showMessageSoundDialog) {
|
||||||
@@ -313,7 +313,7 @@ private fun SoundsPreferenceCategory(state: NotificationSettingsState) {
|
|||||||
type = RingtoneManager.TYPE_RINGTONE,
|
type = RingtoneManager.TYPE_RINGTONE,
|
||||||
current = state.callRingtone.sound,
|
current = state.callRingtone.sound,
|
||||||
defaultUri = Settings.System.DEFAULT_RINGTONE_URI,
|
defaultUri = Settings.System.DEFAULT_RINGTONE_URI,
|
||||||
onSoundPick = { sound -> state.eventSink(NotificationSettingsEvents.SetCallRingtone(sound)) },
|
onSoundPick = { sound -> state.eventSink(NotificationSettingsEvent.SetCallRingtone(sound)) },
|
||||||
)
|
)
|
||||||
// Skip the initial 0 emission so the picker doesn't auto-open on screen entry; only
|
// Skip the initial 0 emission so the picker doesn't auto-open on screen entry; only
|
||||||
// increments fired by LaunchCallRingtonePicker should launch it.
|
// increments fired by LaunchCallRingtonePicker should launch it.
|
||||||
@@ -325,11 +325,11 @@ private fun SoundsPreferenceCategory(state: NotificationSettingsState) {
|
|||||||
ListItem(
|
ListItem(
|
||||||
content = { Text(stringResource(id = R.string.screen_notification_settings_call_ringtone_label)) },
|
content = { Text(stringResource(id = R.string.screen_notification_settings_call_ringtone_label)) },
|
||||||
supportingContent = { Text(state.callRingtone.displayName) },
|
supportingContent = { Text(state.callRingtone.displayName) },
|
||||||
onClick = { state.eventSink(NotificationSettingsEvents.ShowCallRingtoneDialog) },
|
onClick = { state.eventSink(NotificationSettingsEvent.ShowCallRingtoneDialog) },
|
||||||
)
|
)
|
||||||
if (state.callRingtone.copyError) {
|
if (state.callRingtone.copyError) {
|
||||||
SoundCopyErrorRow(
|
SoundCopyErrorRow(
|
||||||
onDismissClick = { state.eventSink(NotificationSettingsEvents.DismissCallRingtoneCopyError) },
|
onDismissClick = { state.eventSink(NotificationSettingsEvent.DismissCallRingtoneCopyError) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (state.showCallRingtoneDialog) {
|
if (state.showCallRingtoneDialog) {
|
||||||
@@ -368,13 +368,13 @@ private fun MessageSoundDialog(state: NotificationSettingsState) {
|
|||||||
initialSelection = initialSelection,
|
initialSelection = initialSelection,
|
||||||
onSelectOption = { index ->
|
onSelectOption = { index ->
|
||||||
when (index) {
|
when (index) {
|
||||||
0 -> state.eventSink(NotificationSettingsEvents.SelectMessageSoundPreset(NotificationSound.ElementDefault))
|
0 -> state.eventSink(NotificationSettingsEvent.SelectMessageSoundPreset(NotificationSound.ElementDefault))
|
||||||
1 -> state.eventSink(NotificationSettingsEvents.SelectMessageSoundPreset(NotificationSound.ElementFade))
|
1 -> state.eventSink(NotificationSettingsEvent.SelectMessageSoundPreset(NotificationSound.ElementFade))
|
||||||
2 -> state.eventSink(NotificationSettingsEvents.SelectMessageSoundPreset(NotificationSound.SystemDefault))
|
2 -> state.eventSink(NotificationSettingsEvent.SelectMessageSoundPreset(NotificationSound.SystemDefault))
|
||||||
else -> state.eventSink(NotificationSettingsEvents.LaunchMessageSoundPicker)
|
else -> state.eventSink(NotificationSettingsEvent.LaunchMessageSoundPicker)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDismissRequest = { state.eventSink(NotificationSettingsEvents.DismissMessageSoundDialog) },
|
onDismissRequest = { state.eventSink(NotificationSettingsEvent.DismissMessageSoundDialog) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,11 +402,11 @@ private fun CallRingtoneDialog(state: NotificationSettingsState) {
|
|||||||
initialSelection = initialSelection,
|
initialSelection = initialSelection,
|
||||||
onSelectOption = { index ->
|
onSelectOption = { index ->
|
||||||
when (index) {
|
when (index) {
|
||||||
0 -> state.eventSink(NotificationSettingsEvents.SelectCallRingtonePreset(NotificationSound.SystemDefault))
|
0 -> state.eventSink(NotificationSettingsEvent.SelectCallRingtonePreset(NotificationSound.SystemDefault))
|
||||||
else -> state.eventSink(NotificationSettingsEvents.LaunchCallRingtonePicker)
|
else -> state.eventSink(NotificationSettingsEvent.LaunchCallRingtonePicker)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDismissRequest = { state.eventSink(NotificationSettingsEvents.DismissCallRingtoneDialog) },
|
onDismissRequest = { state.eventSink(NotificationSettingsEvent.DismissCallRingtoneDialog) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+51
-51
@@ -120,7 +120,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
val presenter = createNotificationSettingsPresenter(notificationSettingsService)
|
val presenter = createNotificationSettingsPresenter(notificationSettingsService)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(NotificationSettingsEvents.FixConfigurationMismatch)
|
initialState.eventSink(NotificationSettingsEvent.FixConfigurationMismatch)
|
||||||
val fixedState = consumeItemsUntilPredicate(timeout = 2000.milliseconds) {
|
val fixedState = consumeItemsUntilPredicate(timeout = 2000.milliseconds) {
|
||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
@@ -148,14 +148,14 @@ class NotificationSettingsPresenterTest {
|
|||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
assertThat(loadedState.appSettings.appNotificationsEnabled).isTrue()
|
assertThat(loadedState.appSettings.appNotificationsEnabled).isTrue()
|
||||||
loadedState.eventSink(NotificationSettingsEvents.SetNotificationsEnabled(false))
|
loadedState.eventSink(NotificationSettingsEvent.SetNotificationsEnabled(false))
|
||||||
val updatedState = consumeItemsUntilPredicate {
|
val updatedState = consumeItemsUntilPredicate {
|
||||||
!it.appSettings.appNotificationsEnabled
|
!it.appSettings.appNotificationsEnabled
|
||||||
}.last()
|
}.last()
|
||||||
assertThat(updatedState.appSettings.appNotificationsEnabled).isFalse()
|
assertThat(updatedState.appSettings.appNotificationsEnabled).isFalse()
|
||||||
unregisterWithResult.assertions().isCalledOnce()
|
unregisterWithResult.assertions().isCalledOnce()
|
||||||
// Enable notification again
|
// Enable notification again
|
||||||
loadedState.eventSink(NotificationSettingsEvents.SetNotificationsEnabled(true))
|
loadedState.eventSink(NotificationSettingsEvent.SetNotificationsEnabled(true))
|
||||||
val updatedState2 = consumeItemsUntilPredicate {
|
val updatedState2 = consumeItemsUntilPredicate {
|
||||||
it.appSettings.appNotificationsEnabled
|
it.appSettings.appNotificationsEnabled
|
||||||
}.last()
|
}.last()
|
||||||
@@ -173,7 +173,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
}.last()
|
}.last()
|
||||||
val validMatrixState = loadedState.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid
|
val validMatrixState = loadedState.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid
|
||||||
assertThat(validMatrixState?.callNotificationsEnabled).isFalse()
|
assertThat(validMatrixState?.callNotificationsEnabled).isFalse()
|
||||||
loadedState.eventSink(NotificationSettingsEvents.SetCallNotificationsEnabled(true))
|
loadedState.eventSink(NotificationSettingsEvent.SetCallNotificationsEnabled(true))
|
||||||
val updatedState = consumeItemsUntilPredicate {
|
val updatedState = consumeItemsUntilPredicate {
|
||||||
(it.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid)?.callNotificationsEnabled == true
|
(it.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid)?.callNotificationsEnabled == true
|
||||||
}.last()
|
}.last()
|
||||||
@@ -192,7 +192,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
}.last()
|
}.last()
|
||||||
val validMatrixState = loadedState.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid
|
val validMatrixState = loadedState.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid
|
||||||
assertThat(validMatrixState?.inviteForMeNotificationsEnabled).isFalse()
|
assertThat(validMatrixState?.inviteForMeNotificationsEnabled).isFalse()
|
||||||
loadedState.eventSink(NotificationSettingsEvents.SetInviteForMeNotificationsEnabled(true))
|
loadedState.eventSink(NotificationSettingsEvent.SetInviteForMeNotificationsEnabled(true))
|
||||||
val updatedState = consumeItemsUntilPredicate {
|
val updatedState = consumeItemsUntilPredicate {
|
||||||
(it.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid)?.inviteForMeNotificationsEnabled == true
|
(it.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid)?.inviteForMeNotificationsEnabled == true
|
||||||
}.last()
|
}.last()
|
||||||
@@ -211,7 +211,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
}.last()
|
}.last()
|
||||||
val validMatrixState = loadedState.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid
|
val validMatrixState = loadedState.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid
|
||||||
assertThat(validMatrixState?.atRoomNotificationsEnabled).isFalse()
|
assertThat(validMatrixState?.atRoomNotificationsEnabled).isFalse()
|
||||||
loadedState.eventSink(NotificationSettingsEvents.SetAtRoomNotificationsEnabled(true))
|
loadedState.eventSink(NotificationSettingsEvent.SetAtRoomNotificationsEnabled(true))
|
||||||
val updatedState = consumeItemsUntilPredicate {
|
val updatedState = consumeItemsUntilPredicate {
|
||||||
(it.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid)?.atRoomNotificationsEnabled == true
|
(it.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid)?.atRoomNotificationsEnabled == true
|
||||||
}.last()
|
}.last()
|
||||||
@@ -232,12 +232,12 @@ class NotificationSettingsPresenterTest {
|
|||||||
}.last()
|
}.last()
|
||||||
val validMatrixState = loadedState.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid
|
val validMatrixState = loadedState.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid
|
||||||
assertThat(validMatrixState?.atRoomNotificationsEnabled).isFalse()
|
assertThat(validMatrixState?.atRoomNotificationsEnabled).isFalse()
|
||||||
loadedState.eventSink(NotificationSettingsEvents.SetAtRoomNotificationsEnabled(true))
|
loadedState.eventSink(NotificationSettingsEvent.SetAtRoomNotificationsEnabled(true))
|
||||||
val errorState = consumeItemsUntilPredicate {
|
val errorState = consumeItemsUntilPredicate {
|
||||||
it.changeNotificationSettingAction.isFailure()
|
it.changeNotificationSettingAction.isFailure()
|
||||||
}.last()
|
}.last()
|
||||||
assertThat(errorState.changeNotificationSettingAction.isFailure()).isTrue()
|
assertThat(errorState.changeNotificationSettingAction.isFailure()).isTrue()
|
||||||
errorState.eventSink(NotificationSettingsEvents.ClearNotificationChangeError)
|
errorState.eventSink(NotificationSettingsEvent.ClearNotificationChangeError)
|
||||||
val clearErrorState = consumeItemsUntilPredicate {
|
val clearErrorState = consumeItemsUntilPredicate {
|
||||||
it.changeNotificationSettingAction.isUninitialized()
|
it.changeNotificationSettingAction.isUninitialized()
|
||||||
}.last()
|
}.last()
|
||||||
@@ -258,16 +258,16 @@ class NotificationSettingsPresenterTest {
|
|||||||
Distributor(value = "aDistributorValue0", name = "aDistributorName0"),
|
Distributor(value = "aDistributorValue0", name = "aDistributorName0"),
|
||||||
Distributor(value = "aDistributorValue1", name = "aDistributorName1"),
|
Distributor(value = "aDistributorValue1", name = "aDistributorName1"),
|
||||||
)
|
)
|
||||||
initialState.eventSink.invoke(NotificationSettingsEvents.ChangePushProvider)
|
initialState.eventSink.invoke(NotificationSettingsEvent.ChangePushProvider)
|
||||||
val withDialog = awaitItem()
|
val withDialog = awaitItem()
|
||||||
assertThat(withDialog.showChangePushProviderDialog).isTrue()
|
assertThat(withDialog.showChangePushProviderDialog).isTrue()
|
||||||
// Cancel
|
// Cancel
|
||||||
withDialog.eventSink(NotificationSettingsEvents.CancelChangePushProvider)
|
withDialog.eventSink(NotificationSettingsEvent.CancelChangePushProvider)
|
||||||
val withoutDialog = awaitItem()
|
val withoutDialog = awaitItem()
|
||||||
assertThat(withoutDialog.showChangePushProviderDialog).isFalse()
|
assertThat(withoutDialog.showChangePushProviderDialog).isFalse()
|
||||||
withDialog.eventSink.invoke(NotificationSettingsEvents.ChangePushProvider)
|
withDialog.eventSink.invoke(NotificationSettingsEvent.ChangePushProvider)
|
||||||
assertThat(awaitItem().showChangePushProviderDialog).isTrue()
|
assertThat(awaitItem().showChangePushProviderDialog).isTrue()
|
||||||
withDialog.eventSink(NotificationSettingsEvents.SetPushProvider(1))
|
withDialog.eventSink(NotificationSettingsEvent.SetPushProvider(1))
|
||||||
val withNewProvider = awaitItem()
|
val withNewProvider = awaitItem()
|
||||||
assertThat(withNewProvider.showChangePushProviderDialog).isFalse()
|
assertThat(withNewProvider.showChangePushProviderDialog).isFalse()
|
||||||
assertThat(withNewProvider.currentPushDistributor).isInstanceOf(AsyncData.Loading::class.java)
|
assertThat(withNewProvider.currentPushDistributor).isInstanceOf(AsyncData.Loading::class.java)
|
||||||
@@ -290,10 +290,10 @@ class NotificationSettingsPresenterTest {
|
|||||||
Distributor(value = "aDistributorValue0", name = "aDistributorName0"),
|
Distributor(value = "aDistributorValue0", name = "aDistributorName0"),
|
||||||
Distributor(value = "aDistributorValue1", name = "aDistributorName1"),
|
Distributor(value = "aDistributorValue1", name = "aDistributorName1"),
|
||||||
)
|
)
|
||||||
initialState.eventSink.invoke(NotificationSettingsEvents.ChangePushProvider)
|
initialState.eventSink.invoke(NotificationSettingsEvent.ChangePushProvider)
|
||||||
assertThat(awaitItem().showChangePushProviderDialog).isTrue()
|
assertThat(awaitItem().showChangePushProviderDialog).isTrue()
|
||||||
// Choose the same value (index 0)
|
// Choose the same value (index 0)
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetPushProvider(0))
|
initialState.eventSink(NotificationSettingsEvent.SetPushProvider(0))
|
||||||
val withNewProvider = awaitItem()
|
val withNewProvider = awaitItem()
|
||||||
assertThat(withNewProvider.showChangePushProviderDialog).isFalse()
|
assertThat(withNewProvider.showChangePushProviderDialog).isFalse()
|
||||||
expectNoEvents()
|
expectNoEvents()
|
||||||
@@ -318,7 +318,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
expectNoEvents()
|
expectNoEvents()
|
||||||
|
|
||||||
// Refresh
|
// Refresh
|
||||||
initialState.eventSink.invoke(NotificationSettingsEvents.RefreshSystemNotificationsEnabled)
|
initialState.eventSink.invoke(NotificationSettingsEvent.RefreshSystemNotificationsEnabled)
|
||||||
assertThat(awaitItem().fullScreenIntentPermissionsState.permissionGranted).isTrue()
|
assertThat(awaitItem().fullScreenIntentPermissionsState.permissionGranted).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,10 +334,10 @@ class NotificationSettingsPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitLastSequentialItem()
|
val initialState = awaitLastSequentialItem()
|
||||||
initialState.eventSink.invoke(NotificationSettingsEvents.ChangePushProvider)
|
initialState.eventSink.invoke(NotificationSettingsEvent.ChangePushProvider)
|
||||||
val withDialog = awaitItem()
|
val withDialog = awaitItem()
|
||||||
assertThat(withDialog.showChangePushProviderDialog).isTrue()
|
assertThat(withDialog.showChangePushProviderDialog).isTrue()
|
||||||
withDialog.eventSink(NotificationSettingsEvents.SetPushProvider(1))
|
withDialog.eventSink(NotificationSettingsEvent.SetPushProvider(1))
|
||||||
val withNewProvider = awaitItem()
|
val withNewProvider = awaitItem()
|
||||||
assertThat(withNewProvider.showChangePushProviderDialog).isFalse()
|
assertThat(withNewProvider.showChangePushProviderDialog).isFalse()
|
||||||
assertThat(withNewProvider.currentPushDistributor).isInstanceOf(AsyncData.Loading::class.java)
|
assertThat(withNewProvider.currentPushDistributor).isInstanceOf(AsyncData.Loading::class.java)
|
||||||
@@ -384,7 +384,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
}.last()
|
}.last()
|
||||||
assertThat(initialState.messageSound.sound).isEqualTo(NotificationSound.SystemDefault)
|
assertThat(initialState.messageSound.sound).isEqualTo(NotificationSound.SystemDefault)
|
||||||
|
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetMessageSound(customSound))
|
initialState.eventSink(NotificationSettingsEvent.SetMessageSound(customSound))
|
||||||
|
|
||||||
val updatedState = consumeItemsUntilPredicate { it.messageSound.sound == customSound }.last()
|
val updatedState = consumeItemsUntilPredicate { it.messageSound.sound == customSound }.last()
|
||||||
assertThat(updatedState.messageSound.sound).isEqualTo(customSound)
|
assertThat(updatedState.messageSound.sound).isEqualTo(customSound)
|
||||||
@@ -410,7 +410,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
}.last()
|
}.last()
|
||||||
assertThat(initialState.callRingtone.sound).isEqualTo(NotificationSound.SystemDefault)
|
assertThat(initialState.callRingtone.sound).isEqualTo(NotificationSound.SystemDefault)
|
||||||
|
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetCallRingtone(NotificationSound.Silent))
|
initialState.eventSink(NotificationSettingsEvent.SetCallRingtone(NotificationSound.Silent))
|
||||||
|
|
||||||
val updatedState = consumeItemsUntilPredicate { it.callRingtone.sound == NotificationSound.Silent }.last()
|
val updatedState = consumeItemsUntilPredicate { it.callRingtone.sound == NotificationSound.Silent }.last()
|
||||||
assertThat(updatedState.callRingtone.sound).isEqualTo(NotificationSound.Silent)
|
assertThat(updatedState.callRingtone.sound).isEqualTo(NotificationSound.Silent)
|
||||||
@@ -435,11 +435,11 @@ class NotificationSettingsPresenterTest {
|
|||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
|
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://a")))
|
initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://a")))
|
||||||
consumeItemsUntilPredicate { it.messageSound.sound == NotificationSound.Custom("content://a") }
|
consumeItemsUntilPredicate { it.messageSound.sound == NotificationSound.Custom("content://a") }
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://b")))
|
initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://b")))
|
||||||
consumeItemsUntilPredicate { it.messageSound.sound == NotificationSound.Custom("content://b") }
|
consumeItemsUntilPredicate { it.messageSound.sound == NotificationSound.Custom("content://b") }
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.SystemDefault))
|
initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.SystemDefault))
|
||||||
consumeItemsUntilPredicate { it.messageSound.sound == NotificationSound.SystemDefault }
|
consumeItemsUntilPredicate { it.messageSound.sound == NotificationSound.SystemDefault }
|
||||||
|
|
||||||
assertThat(versions).containsExactly(1, 2, 3).inOrder()
|
assertThat(versions).containsExactly(1, 2, 3).inOrder()
|
||||||
@@ -461,7 +461,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
consumeItemsUntilPredicate {
|
consumeItemsUntilPredicate {
|
||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid &&
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid &&
|
||||||
it.messageSound.sound == NotificationSound.Custom("content://existing")
|
it.messageSound.sound == NotificationSound.Custom("content://existing")
|
||||||
}.last().eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.SystemDefault))
|
}.last().eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.SystemDefault))
|
||||||
consumeItemsUntilPredicate { it.messageSound.sound == NotificationSound.SystemDefault }
|
consumeItemsUntilPredicate { it.messageSound.sound == NotificationSound.SystemDefault }
|
||||||
assertThat(appPreferencesStore.getNotificationSoundChannelConfig().messageSound).isEqualTo(NotificationSound.SystemDefault)
|
assertThat(appPreferencesStore.getNotificationSoundChannelConfig().messageSound).isEqualTo(NotificationSound.SystemDefault)
|
||||||
recreateRecorder.assertions().isCalledOnce().with(value(NotificationSound.SystemDefault), value(1))
|
recreateRecorder.assertions().isCalledOnce().with(value(NotificationSound.SystemDefault), value(1))
|
||||||
@@ -483,7 +483,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
|
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://x")))
|
initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://x")))
|
||||||
|
|
||||||
val errorState = consumeItemsUntilPredicate {
|
val errorState = consumeItemsUntilPredicate {
|
||||||
it.changeNotificationSettingAction.isFailure()
|
it.changeNotificationSettingAction.isFailure()
|
||||||
@@ -670,7 +670,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
val initialState = consumeItemsUntilPredicate {
|
val initialState = consumeItemsUntilPredicate {
|
||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://media/source")))
|
initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://media/source")))
|
||||||
advanceUntilIdle()
|
advanceUntilIdle()
|
||||||
|
|
||||||
val expectedSound = NotificationSound.Custom("content://my.app.fileprovider/notification_sounds/message_sound.ogg")
|
val expectedSound = NotificationSound.Custom("content://my.app.fileprovider/notification_sounds/message_sound.ogg")
|
||||||
@@ -695,7 +695,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
val initialState = consumeItemsUntilPredicate {
|
val initialState = consumeItemsUntilPredicate {
|
||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://broken")))
|
initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://broken")))
|
||||||
|
|
||||||
val errorState = consumeItemsUntilPredicate { it.messageSound.copyError }.last()
|
val errorState = consumeItemsUntilPredicate { it.messageSound.copyError }.last()
|
||||||
assertThat(errorState.messageSound.copyError).isTrue()
|
assertThat(errorState.messageSound.copyError).isTrue()
|
||||||
@@ -703,7 +703,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
assertThat(appPreferencesStore.getNotificationSoundChannelConfig().messageSound).isEqualTo(priorChoice)
|
assertThat(appPreferencesStore.getNotificationSoundChannelConfig().messageSound).isEqualTo(priorChoice)
|
||||||
|
|
||||||
// Dismissing the inline error clears the flag without altering persistence.
|
// Dismissing the inline error clears the flag without altering persistence.
|
||||||
errorState.eventSink(NotificationSettingsEvents.DismissMessageSoundCopyError)
|
errorState.eventSink(NotificationSettingsEvent.DismissMessageSoundCopyError)
|
||||||
val cleared = consumeItemsUntilPredicate { !it.messageSound.copyError }.last()
|
val cleared = consumeItemsUntilPredicate { !it.messageSound.copyError }.last()
|
||||||
assertThat(cleared.messageSound.copyError).isFalse()
|
assertThat(cleared.messageSound.copyError).isFalse()
|
||||||
assertThat(appPreferencesStore.getNotificationSoundChannelConfig().messageSound).isEqualTo(priorChoice)
|
assertThat(appPreferencesStore.getNotificationSoundChannelConfig().messageSound).isEqualTo(priorChoice)
|
||||||
@@ -725,7 +725,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
val initialState = consumeItemsUntilPredicate {
|
val initialState = consumeItemsUntilPredicate {
|
||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetCallRingtone(NotificationSound.Custom("content://broken")))
|
initialState.eventSink(NotificationSettingsEvent.SetCallRingtone(NotificationSound.Custom("content://broken")))
|
||||||
|
|
||||||
val errorState = consumeItemsUntilPredicate { it.callRingtone.copyError }.last()
|
val errorState = consumeItemsUntilPredicate { it.callRingtone.copyError }.last()
|
||||||
assertThat(errorState.callRingtone.copyError).isTrue()
|
assertThat(errorState.callRingtone.copyError).isTrue()
|
||||||
@@ -733,7 +733,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
assertThat(appPreferencesStore.getNotificationSoundChannelConfig().callRingtone).isEqualTo(priorChoice)
|
assertThat(appPreferencesStore.getNotificationSoundChannelConfig().callRingtone).isEqualTo(priorChoice)
|
||||||
|
|
||||||
// Dismissing the inline error clears the flag without altering persistence.
|
// Dismissing the inline error clears the flag without altering persistence.
|
||||||
errorState.eventSink(NotificationSettingsEvents.DismissCallRingtoneCopyError)
|
errorState.eventSink(NotificationSettingsEvent.DismissCallRingtoneCopyError)
|
||||||
val cleared = consumeItemsUntilPredicate { !it.callRingtone.copyError }.last()
|
val cleared = consumeItemsUntilPredicate { !it.callRingtone.copyError }.last()
|
||||||
assertThat(cleared.callRingtone.copyError).isFalse()
|
assertThat(cleared.callRingtone.copyError).isFalse()
|
||||||
assertThat(appPreferencesStore.getNotificationSoundChannelConfig().callRingtone).isEqualTo(priorChoice)
|
assertThat(appPreferencesStore.getNotificationSoundChannelConfig().callRingtone).isEqualTo(priorChoice)
|
||||||
@@ -759,8 +759,8 @@ class NotificationSettingsPresenterTest {
|
|||||||
val initialState = consumeItemsUntilPredicate {
|
val initialState = consumeItemsUntilPredicate {
|
||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.SystemDefault))
|
initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.SystemDefault))
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetCallRingtone(NotificationSound.Silent))
|
initialState.eventSink(NotificationSettingsEvent.SetCallRingtone(NotificationSound.Silent))
|
||||||
advanceUntilIdle()
|
advanceUntilIdle()
|
||||||
assertThat(copierCalls).isEmpty()
|
assertThat(copierCalls).isEmpty()
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
@@ -791,8 +791,8 @@ class NotificationSettingsPresenterTest {
|
|||||||
val initialState = consumeItemsUntilPredicate {
|
val initialState = consumeItemsUntilPredicate {
|
||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.SystemDefault))
|
initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.SystemDefault))
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetCallRingtone(NotificationSound.Silent))
|
initialState.eventSink(NotificationSettingsEvent.SetCallRingtone(NotificationSound.Silent))
|
||||||
advanceUntilIdle()
|
advanceUntilIdle()
|
||||||
assertThat(deleteCalls).containsExactly(
|
assertThat(deleteCalls).containsExactly(
|
||||||
NotificationSoundCopier.SoundSlot.Message,
|
NotificationSoundCopier.SoundSlot.Message,
|
||||||
@@ -835,8 +835,8 @@ class NotificationSettingsPresenterTest {
|
|||||||
|
|
||||||
// Re-pick the persisted sound for both slots — neither should churn the channel,
|
// Re-pick the persisted sound for both slots — neither should churn the channel,
|
||||||
// bump the version, or hit the copier / delete sweep.
|
// bump the version, or hit the copier / delete sweep.
|
||||||
initial.eventSink(NotificationSettingsEvents.SelectMessageSoundPreset(NotificationSound.ElementDefault))
|
initial.eventSink(NotificationSettingsEvent.SelectMessageSoundPreset(NotificationSound.ElementDefault))
|
||||||
initial.eventSink(NotificationSettingsEvents.SetCallRingtone(NotificationSound.Silent))
|
initial.eventSink(NotificationSettingsEvent.SetCallRingtone(NotificationSound.Silent))
|
||||||
advanceUntilIdle()
|
advanceUntilIdle()
|
||||||
|
|
||||||
val config = appPreferencesStore.getNotificationSoundChannelConfig()
|
val config = appPreferencesStore.getNotificationSoundChannelConfig()
|
||||||
@@ -873,8 +873,8 @@ class NotificationSettingsPresenterTest {
|
|||||||
val initial = consumeItemsUntilPredicate {
|
val initial = consumeItemsUntilPredicate {
|
||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
initial.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://A")))
|
initial.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://A")))
|
||||||
initial.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://B")))
|
initial.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://B")))
|
||||||
advanceUntilIdle()
|
advanceUntilIdle()
|
||||||
|
|
||||||
assertThat(copyOrder).containsExactly("content://A", "content://B").inOrder()
|
assertThat(copyOrder).containsExactly("content://A", "content://B").inOrder()
|
||||||
@@ -908,7 +908,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
val initialState = consumeItemsUntilPredicate {
|
val initialState = consumeItemsUntilPredicate {
|
||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://media/source")))
|
initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://media/source")))
|
||||||
advanceUntilIdle()
|
advanceUntilIdle()
|
||||||
assertThat(deleteCalls).isEmpty()
|
assertThat(deleteCalls).isEmpty()
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
@@ -924,11 +924,11 @@ class NotificationSettingsPresenterTest {
|
|||||||
}.last()
|
}.last()
|
||||||
assertThat(initial.showMessageSoundDialog).isFalse()
|
assertThat(initial.showMessageSoundDialog).isFalse()
|
||||||
|
|
||||||
initial.eventSink(NotificationSettingsEvents.ShowMessageSoundDialog)
|
initial.eventSink(NotificationSettingsEvent.ShowMessageSoundDialog)
|
||||||
val shown = consumeItemsUntilPredicate { it.showMessageSoundDialog }.last()
|
val shown = consumeItemsUntilPredicate { it.showMessageSoundDialog }.last()
|
||||||
assertThat(shown.showMessageSoundDialog).isTrue()
|
assertThat(shown.showMessageSoundDialog).isTrue()
|
||||||
|
|
||||||
shown.eventSink(NotificationSettingsEvents.DismissMessageSoundDialog)
|
shown.eventSink(NotificationSettingsEvent.DismissMessageSoundDialog)
|
||||||
val hidden = consumeItemsUntilPredicate { !it.showMessageSoundDialog }.last()
|
val hidden = consumeItemsUntilPredicate { !it.showMessageSoundDialog }.last()
|
||||||
assertThat(hidden.showMessageSoundDialog).isFalse()
|
assertThat(hidden.showMessageSoundDialog).isFalse()
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
@@ -950,10 +950,10 @@ class NotificationSettingsPresenterTest {
|
|||||||
val initial = consumeItemsUntilPredicate {
|
val initial = consumeItemsUntilPredicate {
|
||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
initial.eventSink(NotificationSettingsEvents.ShowMessageSoundDialog)
|
initial.eventSink(NotificationSettingsEvent.ShowMessageSoundDialog)
|
||||||
val shown = consumeItemsUntilPredicate { it.showMessageSoundDialog }.last()
|
val shown = consumeItemsUntilPredicate { it.showMessageSoundDialog }.last()
|
||||||
|
|
||||||
shown.eventSink(NotificationSettingsEvents.SelectMessageSoundPreset(NotificationSound.ElementDefault))
|
shown.eventSink(NotificationSettingsEvent.SelectMessageSoundPreset(NotificationSound.ElementDefault))
|
||||||
advanceUntilIdle()
|
advanceUntilIdle()
|
||||||
consumeItemsUntilPredicate {
|
consumeItemsUntilPredicate {
|
||||||
!it.showMessageSoundDialog && it.messageSound.sound == NotificationSound.ElementDefault
|
!it.showMessageSoundDialog && it.messageSound.sound == NotificationSound.ElementDefault
|
||||||
@@ -973,10 +973,10 @@ class NotificationSettingsPresenterTest {
|
|||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
assertThat(initial.pendingMessageSoundPickerLaunch).isEqualTo(0)
|
assertThat(initial.pendingMessageSoundPickerLaunch).isEqualTo(0)
|
||||||
initial.eventSink(NotificationSettingsEvents.ShowMessageSoundDialog)
|
initial.eventSink(NotificationSettingsEvent.ShowMessageSoundDialog)
|
||||||
val shown = consumeItemsUntilPredicate { it.showMessageSoundDialog }.last()
|
val shown = consumeItemsUntilPredicate { it.showMessageSoundDialog }.last()
|
||||||
|
|
||||||
shown.eventSink(NotificationSettingsEvents.LaunchMessageSoundPicker)
|
shown.eventSink(NotificationSettingsEvent.LaunchMessageSoundPicker)
|
||||||
val launched = consumeItemsUntilPredicate { it.pendingMessageSoundPickerLaunch == 1 }.last()
|
val launched = consumeItemsUntilPredicate { it.pendingMessageSoundPickerLaunch == 1 }.last()
|
||||||
assertThat(launched.showMessageSoundDialog).isFalse()
|
assertThat(launched.showMessageSoundDialog).isFalse()
|
||||||
assertThat(launched.pendingMessageSoundPickerLaunch).isEqualTo(1)
|
assertThat(launched.pendingMessageSoundPickerLaunch).isEqualTo(1)
|
||||||
@@ -993,11 +993,11 @@ class NotificationSettingsPresenterTest {
|
|||||||
}.last()
|
}.last()
|
||||||
assertThat(initial.showCallRingtoneDialog).isFalse()
|
assertThat(initial.showCallRingtoneDialog).isFalse()
|
||||||
|
|
||||||
initial.eventSink(NotificationSettingsEvents.ShowCallRingtoneDialog)
|
initial.eventSink(NotificationSettingsEvent.ShowCallRingtoneDialog)
|
||||||
val shown = consumeItemsUntilPredicate { it.showCallRingtoneDialog }.last()
|
val shown = consumeItemsUntilPredicate { it.showCallRingtoneDialog }.last()
|
||||||
assertThat(shown.showCallRingtoneDialog).isTrue()
|
assertThat(shown.showCallRingtoneDialog).isTrue()
|
||||||
|
|
||||||
shown.eventSink(NotificationSettingsEvents.DismissCallRingtoneDialog)
|
shown.eventSink(NotificationSettingsEvent.DismissCallRingtoneDialog)
|
||||||
val hidden = consumeItemsUntilPredicate { !it.showCallRingtoneDialog }.last()
|
val hidden = consumeItemsUntilPredicate { !it.showCallRingtoneDialog }.last()
|
||||||
assertThat(hidden.showCallRingtoneDialog).isFalse()
|
assertThat(hidden.showCallRingtoneDialog).isFalse()
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
@@ -1020,10 +1020,10 @@ class NotificationSettingsPresenterTest {
|
|||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid &&
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid &&
|
||||||
it.callRingtone.sound == NotificationSound.Silent
|
it.callRingtone.sound == NotificationSound.Silent
|
||||||
}.last()
|
}.last()
|
||||||
initial.eventSink(NotificationSettingsEvents.ShowCallRingtoneDialog)
|
initial.eventSink(NotificationSettingsEvent.ShowCallRingtoneDialog)
|
||||||
val shown = consumeItemsUntilPredicate { it.showCallRingtoneDialog }.last()
|
val shown = consumeItemsUntilPredicate { it.showCallRingtoneDialog }.last()
|
||||||
|
|
||||||
shown.eventSink(NotificationSettingsEvents.SelectCallRingtonePreset(NotificationSound.SystemDefault))
|
shown.eventSink(NotificationSettingsEvent.SelectCallRingtonePreset(NotificationSound.SystemDefault))
|
||||||
advanceUntilIdle()
|
advanceUntilIdle()
|
||||||
consumeItemsUntilPredicate {
|
consumeItemsUntilPredicate {
|
||||||
!it.showCallRingtoneDialog && it.callRingtone.sound == NotificationSound.SystemDefault
|
!it.showCallRingtoneDialog && it.callRingtone.sound == NotificationSound.SystemDefault
|
||||||
@@ -1043,10 +1043,10 @@ class NotificationSettingsPresenterTest {
|
|||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid
|
||||||
}.last()
|
}.last()
|
||||||
assertThat(initial.pendingCallRingtonePickerLaunch).isEqualTo(0)
|
assertThat(initial.pendingCallRingtonePickerLaunch).isEqualTo(0)
|
||||||
initial.eventSink(NotificationSettingsEvents.ShowCallRingtoneDialog)
|
initial.eventSink(NotificationSettingsEvent.ShowCallRingtoneDialog)
|
||||||
val shown = consumeItemsUntilPredicate { it.showCallRingtoneDialog }.last()
|
val shown = consumeItemsUntilPredicate { it.showCallRingtoneDialog }.last()
|
||||||
|
|
||||||
shown.eventSink(NotificationSettingsEvents.LaunchCallRingtonePicker)
|
shown.eventSink(NotificationSettingsEvent.LaunchCallRingtonePicker)
|
||||||
val launched = consumeItemsUntilPredicate { it.pendingCallRingtonePickerLaunch == 1 }.last()
|
val launched = consumeItemsUntilPredicate { it.pendingCallRingtonePickerLaunch == 1 }.last()
|
||||||
assertThat(launched.showCallRingtoneDialog).isFalse()
|
assertThat(launched.showCallRingtoneDialog).isFalse()
|
||||||
assertThat(launched.pendingCallRingtonePickerLaunch).isEqualTo(1)
|
assertThat(launched.pendingCallRingtonePickerLaunch).isEqualTo(1)
|
||||||
@@ -1078,7 +1078,7 @@ class NotificationSettingsPresenterTest {
|
|||||||
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid &&
|
it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid &&
|
||||||
it.callRingtone.sound == NotificationSound.Silent
|
it.callRingtone.sound == NotificationSound.Silent
|
||||||
}.last()
|
}.last()
|
||||||
initial.eventSink(NotificationSettingsEvents.SelectCallRingtonePreset(NotificationSound.SystemDefault))
|
initial.eventSink(NotificationSettingsEvent.SelectCallRingtonePreset(NotificationSound.SystemDefault))
|
||||||
advanceUntilIdle()
|
advanceUntilIdle()
|
||||||
val after = consumeItemsUntilPredicate {
|
val after = consumeItemsUntilPredicate {
|
||||||
it.callRingtone.sound == NotificationSound.SystemDefault
|
it.callRingtone.sound == NotificationSound.SystemDefault
|
||||||
|
|||||||
+36
-36
@@ -35,7 +35,7 @@ import org.robolectric.annotation.Config
|
|||||||
class NotificationSettingsViewTest : RobolectricTest() {
|
class NotificationSettingsViewTest : RobolectricTest() {
|
||||||
@Test
|
@Test
|
||||||
fun `clicking on back invokes the expected callback`() = runAndroidComposeUiTest {
|
fun `clicking on back invokes the expected callback`() = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
ensureCalledOnce {
|
ensureCalledOnce {
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aValidNotificationSettingsState(
|
state = aValidNotificationSettingsState(
|
||||||
@@ -45,13 +45,13 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
)
|
)
|
||||||
pressBack()
|
pressBack()
|
||||||
}
|
}
|
||||||
eventsRecorder.assertSingle(NotificationSettingsEvents.RefreshSystemNotificationsEnabled)
|
eventsRecorder.assertSingle(NotificationSettingsEvent.RefreshSystemNotificationsEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Config(qualifiers = "h1280dp")
|
@Config(qualifiers = "h1280dp")
|
||||||
@Test
|
@Test
|
||||||
fun `clicking on troubleshoot notification invokes the expected callback`() = runAndroidComposeUiTest {
|
fun `clicking on troubleshoot notification invokes the expected callback`() = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
ensureCalledOnce {
|
ensureCalledOnce {
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aValidNotificationSettingsState(
|
state = aValidNotificationSettingsState(
|
||||||
@@ -61,13 +61,13 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
)
|
)
|
||||||
clickOn(R.string.troubleshoot_notifications_entry_point_title)
|
clickOn(R.string.troubleshoot_notifications_entry_point_title)
|
||||||
}
|
}
|
||||||
eventsRecorder.assertSingle(NotificationSettingsEvents.RefreshSystemNotificationsEnabled)
|
eventsRecorder.assertSingle(NotificationSettingsEvent.RefreshSystemNotificationsEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Config(qualifiers = "h1024dp")
|
@Config(qualifiers = "h1024dp")
|
||||||
@Test
|
@Test
|
||||||
fun `clicking on group chats invokes the expected callback`() = runAndroidComposeUiTest {
|
fun `clicking on group chats invokes the expected callback`() = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
ensureCalledOnceWithParam(false) {
|
ensureCalledOnceWithParam(false) {
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aValidNotificationSettingsState(
|
state = aValidNotificationSettingsState(
|
||||||
@@ -77,13 +77,13 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
)
|
)
|
||||||
clickOn(R.string.screen_notification_settings_group_chats)
|
clickOn(R.string.screen_notification_settings_group_chats)
|
||||||
}
|
}
|
||||||
eventsRecorder.assertSingle(NotificationSettingsEvents.RefreshSystemNotificationsEnabled)
|
eventsRecorder.assertSingle(NotificationSettingsEvent.RefreshSystemNotificationsEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Config(qualifiers = "h1024dp")
|
@Config(qualifiers = "h1024dp")
|
||||||
@Test
|
@Test
|
||||||
fun `clicking on direct chats invokes the expected callback`() = runAndroidComposeUiTest {
|
fun `clicking on direct chats invokes the expected callback`() = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
ensureCalledOnceWithParam(true) {
|
ensureCalledOnceWithParam(true) {
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aValidNotificationSettingsState(
|
state = aValidNotificationSettingsState(
|
||||||
@@ -93,7 +93,7 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
)
|
)
|
||||||
clickOn(R.string.screen_notification_settings_direct_chats)
|
clickOn(R.string.screen_notification_settings_direct_chats)
|
||||||
}
|
}
|
||||||
eventsRecorder.assertSingle(NotificationSettingsEvents.RefreshSystemNotificationsEnabled)
|
eventsRecorder.assertSingle(NotificationSettingsEvent.RefreshSystemNotificationsEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Config(qualifiers = "h1024dp")
|
@Config(qualifiers = "h1024dp")
|
||||||
@@ -109,7 +109,7 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun testNotificationToggle(initialState: Boolean) = runAndroidComposeUiTest {
|
private fun testNotificationToggle(initialState: Boolean) = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aValidNotificationSettingsState(
|
state = aValidNotificationSettingsState(
|
||||||
appNotificationEnabled = initialState,
|
appNotificationEnabled = initialState,
|
||||||
@@ -119,8 +119,8 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
clickOn(R.string.screen_notification_settings_enable_notifications)
|
clickOn(R.string.screen_notification_settings_enable_notifications)
|
||||||
eventsRecorder.assertList(
|
eventsRecorder.assertList(
|
||||||
listOf(
|
listOf(
|
||||||
NotificationSettingsEvents.RefreshSystemNotificationsEnabled,
|
NotificationSettingsEvent.RefreshSystemNotificationsEnabled,
|
||||||
NotificationSettingsEvents.SetNotificationsEnabled(!initialState)
|
NotificationSettingsEvent.SetNotificationsEnabled(!initialState)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun testAtRoomToggle(initialState: Boolean) = runAndroidComposeUiTest {
|
private fun testAtRoomToggle(initialState: Boolean) = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aValidNotificationSettingsState(
|
state = aValidNotificationSettingsState(
|
||||||
atRoomNotificationsEnabled = initialState,
|
atRoomNotificationsEnabled = initialState,
|
||||||
@@ -148,8 +148,8 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
clickOn(R.string.screen_notification_settings_room_mention_label)
|
clickOn(R.string.screen_notification_settings_room_mention_label)
|
||||||
eventsRecorder.assertList(
|
eventsRecorder.assertList(
|
||||||
listOf(
|
listOf(
|
||||||
NotificationSettingsEvents.RefreshSystemNotificationsEnabled,
|
NotificationSettingsEvent.RefreshSystemNotificationsEnabled,
|
||||||
NotificationSettingsEvents.SetAtRoomNotificationsEnabled(!initialState)
|
NotificationSettingsEvent.SetAtRoomNotificationsEnabled(!initialState)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun testInvitationToggle(initialState: Boolean) = runAndroidComposeUiTest {
|
private fun testInvitationToggle(initialState: Boolean) = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aValidNotificationSettingsState(
|
state = aValidNotificationSettingsState(
|
||||||
inviteForMeNotificationsEnabled = initialState,
|
inviteForMeNotificationsEnabled = initialState,
|
||||||
@@ -177,8 +177,8 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
clickOn(R.string.screen_notification_settings_invite_for_me_label)
|
clickOn(R.string.screen_notification_settings_invite_for_me_label)
|
||||||
eventsRecorder.assertList(
|
eventsRecorder.assertList(
|
||||||
listOf(
|
listOf(
|
||||||
NotificationSettingsEvents.RefreshSystemNotificationsEnabled,
|
NotificationSettingsEvent.RefreshSystemNotificationsEnabled,
|
||||||
NotificationSettingsEvents.SetInviteForMeNotificationsEnabled(!initialState)
|
NotificationSettingsEvent.SetInviteForMeNotificationsEnabled(!initialState)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
@Config(qualifiers = "h1024dp")
|
@Config(qualifiers = "h1024dp")
|
||||||
@Test
|
@Test
|
||||||
fun `with an error configuration, clicking on continue emits the expected events`() = runAndroidComposeUiTest {
|
fun `with an error configuration, clicking on continue emits the expected events`() = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aValidNotificationSettingsState(
|
state = aValidNotificationSettingsState(
|
||||||
changeNotificationSettingAction = AsyncAction.Failure(AN_EXCEPTION),
|
changeNotificationSettingAction = AsyncAction.Failure(AN_EXCEPTION),
|
||||||
@@ -196,8 +196,8 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
clickOn(CommonStrings.action_ok)
|
clickOn(CommonStrings.action_ok)
|
||||||
eventsRecorder.assertList(
|
eventsRecorder.assertList(
|
||||||
listOf(
|
listOf(
|
||||||
NotificationSettingsEvents.RefreshSystemNotificationsEnabled,
|
NotificationSettingsEvent.RefreshSystemNotificationsEnabled,
|
||||||
NotificationSettingsEvents.ClearNotificationChangeError
|
NotificationSettingsEvent.ClearNotificationChangeError
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
@Config(qualifiers = "h1024dp")
|
@Config(qualifiers = "h1024dp")
|
||||||
@Test
|
@Test
|
||||||
fun `with invalid configuration, clicking on continue emits the expected events`() = runAndroidComposeUiTest {
|
fun `with invalid configuration, clicking on continue emits the expected events`() = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aInvalidNotificationSettingsState(
|
state = aInvalidNotificationSettingsState(
|
||||||
fixFailed = false,
|
fixFailed = false,
|
||||||
@@ -215,8 +215,8 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
clickOn(CommonStrings.action_continue)
|
clickOn(CommonStrings.action_continue)
|
||||||
eventsRecorder.assertList(
|
eventsRecorder.assertList(
|
||||||
listOf(
|
listOf(
|
||||||
NotificationSettingsEvents.RefreshSystemNotificationsEnabled,
|
NotificationSettingsEvent.RefreshSystemNotificationsEnabled,
|
||||||
NotificationSettingsEvents.FixConfigurationMismatch
|
NotificationSettingsEvent.FixConfigurationMismatch
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -224,7 +224,7 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
@Config(qualifiers = "h1024dp")
|
@Config(qualifiers = "h1024dp")
|
||||||
@Test
|
@Test
|
||||||
fun `with invalid configuration and error, clicking on OK emits the expected events`() = runAndroidComposeUiTest {
|
fun `with invalid configuration and error, clicking on OK emits the expected events`() = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aInvalidNotificationSettingsState(
|
state = aInvalidNotificationSettingsState(
|
||||||
fixFailed = true,
|
fixFailed = true,
|
||||||
@@ -234,8 +234,8 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
clickOn(CommonStrings.action_ok)
|
clickOn(CommonStrings.action_ok)
|
||||||
eventsRecorder.assertList(
|
eventsRecorder.assertList(
|
||||||
listOf(
|
listOf(
|
||||||
NotificationSettingsEvents.RefreshSystemNotificationsEnabled,
|
NotificationSettingsEvent.RefreshSystemNotificationsEnabled,
|
||||||
NotificationSettingsEvents.ClearConfigurationMismatchError
|
NotificationSettingsEvent.ClearConfigurationMismatchError
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -243,7 +243,7 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
@Config(qualifiers = "h1280dp")
|
@Config(qualifiers = "h1280dp")
|
||||||
@Test
|
@Test
|
||||||
fun `clicking on Push notification provider emits the expected event`() = runAndroidComposeUiTest {
|
fun `clicking on Push notification provider emits the expected event`() = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aValidNotificationSettingsState(
|
state = aValidNotificationSettingsState(
|
||||||
eventSink = eventsRecorder
|
eventSink = eventsRecorder
|
||||||
@@ -252,15 +252,15 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
clickOn(R.string.screen_advanced_settings_push_provider_android)
|
clickOn(R.string.screen_advanced_settings_push_provider_android)
|
||||||
eventsRecorder.assertList(
|
eventsRecorder.assertList(
|
||||||
listOf(
|
listOf(
|
||||||
NotificationSettingsEvents.RefreshSystemNotificationsEnabled,
|
NotificationSettingsEvent.RefreshSystemNotificationsEnabled,
|
||||||
NotificationSettingsEvents.ChangePushProvider,
|
NotificationSettingsEvent.ChangePushProvider,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `clicking on a push provider emits the expected event`() = runAndroidComposeUiTest {
|
fun `clicking on a push provider emits the expected event`() = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aValidNotificationSettingsState(
|
state = aValidNotificationSettingsState(
|
||||||
eventSink = eventsRecorder,
|
eventSink = eventsRecorder,
|
||||||
@@ -271,8 +271,8 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
onNodeWithText("P2").performClick()
|
onNodeWithText("P2").performClick()
|
||||||
eventsRecorder.assertList(
|
eventsRecorder.assertList(
|
||||||
listOf(
|
listOf(
|
||||||
NotificationSettingsEvents.RefreshSystemNotificationsEnabled,
|
NotificationSettingsEvent.RefreshSystemNotificationsEnabled,
|
||||||
NotificationSettingsEvents.SetPushProvider(1),
|
NotificationSettingsEvent.SetPushProvider(1),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -280,7 +280,7 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
@Config(qualifiers = "h1280dp")
|
@Config(qualifiers = "h1280dp")
|
||||||
@Test
|
@Test
|
||||||
fun `sounds preference category renders rows with current display names`() = runAndroidComposeUiTest {
|
fun `sounds preference category renders rows with current display names`() = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aValidNotificationSettingsState(
|
state = aValidNotificationSettingsState(
|
||||||
eventSink = eventsRecorder,
|
eventSink = eventsRecorder,
|
||||||
@@ -298,7 +298,7 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
@Config(qualifiers = "h1280dp")
|
@Config(qualifiers = "h1280dp")
|
||||||
@Test
|
@Test
|
||||||
fun `clicking the message sound row opens the preset dialog`() = runAndroidComposeUiTest {
|
fun `clicking the message sound row opens the preset dialog`() = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<NotificationSettingsEvents>()
|
val eventsRecorder = EventsRecorder<NotificationSettingsEvent>()
|
||||||
setNotificationSettingsView(
|
setNotificationSettingsView(
|
||||||
state = aValidNotificationSettingsState(eventSink = eventsRecorder),
|
state = aValidNotificationSettingsState(eventSink = eventsRecorder),
|
||||||
)
|
)
|
||||||
@@ -308,8 +308,8 @@ class NotificationSettingsViewTest : RobolectricTest() {
|
|||||||
onNodeWithText("Message sound").performClick()
|
onNodeWithText("Message sound").performClick()
|
||||||
eventsRecorder.assertList(
|
eventsRecorder.assertList(
|
||||||
listOf(
|
listOf(
|
||||||
NotificationSettingsEvents.RefreshSystemNotificationsEnabled,
|
NotificationSettingsEvent.RefreshSystemNotificationsEnabled,
|
||||||
NotificationSettingsEvents.ShowMessageSoundDialog,
|
NotificationSettingsEvent.ShowMessageSoundDialog,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user