Add back "default" notification option

Closes https://github.com/SchildiChat/SchildiChat-android/issues/100

Change-Id: I0ef5580f41bd90a0f5b5c350ee2a51ca12f70e40
This commit is contained in:
SpiritCroc 2021-12-26 11:39:02 +01:00
parent 9b7b364a25
commit f95e285780
4 changed files with 16 additions and 6 deletions

View file

@ -106,6 +106,7 @@ class RoomListQuickActionsEpoxyController @Inject constructor(
@StringRes
private fun titleForNotificationState(notificationState: RoomNotificationState): Int? = when (notificationState) {
RoomNotificationState.ALL_MESSAGES -> R.string.room_settings_default // SC addition to allow this again
RoomNotificationState.ALL_MESSAGES_NOISY -> R.string.room_settings_all_messages
RoomNotificationState.MENTIONS_ONLY -> R.string.room_settings_mention_and_keyword_only
RoomNotificationState.MUTE -> R.string.room_settings_none
@ -114,8 +115,12 @@ class RoomListQuickActionsEpoxyController @Inject constructor(
@DrawableRes
private fun iconForNotificationState(notificationState: RoomNotificationState): Int? = when (notificationState) {
RoomNotificationState.ALL_MESSAGES_NOISY -> R.drawable.ic_room_actions_notifications_all_noisy
RoomNotificationState.ALL_MESSAGES -> R.drawable.ic_room_actions_notifications_all
// Yeah, ALL_MESSAGES and ALL_MESSAGES_NOISY is confusing, blame upstream.
// RoomNotificationState.ALL_MESSAGES_NOISY = explicit push rule to notify for all
// RoomNotificationState.ALL_MESSAGES = no explicit push rule, follow default
// To follow desktops icons, we also need to exchange both icons...
RoomNotificationState.ALL_MESSAGES -> R.drawable.ic_room_actions_notifications_all_noisy // default
RoomNotificationState.ALL_MESSAGES_NOISY -> R.drawable.ic_room_actions_notifications_all // actually all
RoomNotificationState.MENTIONS_ONLY -> R.drawable.ic_room_actions_notifications_mentions
RoomNotificationState.MUTE -> R.drawable.ic_room_actions_notifications_mutes
else -> null

View file

@ -64,6 +64,7 @@ class RoomNotificationSettingsController @Inject constructor() : TypedEpoxyContr
@StringRes
private fun titleForNotificationState(notificationState: RoomNotificationState): Int? = when (notificationState) {
RoomNotificationState.ALL_MESSAGES -> R.string.room_settings_default // SC addition to add this back
RoomNotificationState.ALL_MESSAGES_NOISY -> R.string.room_settings_all_messages
RoomNotificationState.MENTIONS_ONLY -> R.string.room_settings_mention_and_keyword_only
RoomNotificationState.MUTE -> R.string.room_settings_none

View file

@ -40,8 +40,8 @@ data class RoomNotificationSettingsViewState(
*/
val RoomNotificationSettingsViewState.notificationStateMapped: Async<RoomNotificationState>
get() {
if ((roomSummary()?.isEncrypted == true && notificationState() == RoomNotificationState.MENTIONS_ONLY) ||
notificationState() == RoomNotificationState.ALL_MESSAGES) {
if ((roomSummary()?.isEncrypted == true && notificationState() == RoomNotificationState.MENTIONS_ONLY) /*||
notificationState() == RoomNotificationState.ALL_MESSAGES*/) {
/** if in an encrypted room, mentions notifications are not supported so show "All Messages" as selected.
* Also in the new settings there is no notion of notifications without sound so it maps to noisy also
*/
@ -56,8 +56,10 @@ val RoomNotificationSettingsViewState.notificationStateMapped: Async<RoomNotific
val RoomNotificationSettingsViewState.notificationOptions: List<RoomNotificationState>
get() {
return if (roomSummary()?.isEncrypted == true) {
listOf(RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MUTE)
// SC note: ALL_MESSAGES = default
listOf(RoomNotificationState.ALL_MESSAGES, RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MUTE)
} else {
listOf(RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MENTIONS_ONLY, RoomNotificationState.MUTE)
// SC note: ALL_MESSAGES = default
listOf(RoomNotificationState.ALL_MESSAGES, RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MENTIONS_ONLY, RoomNotificationState.MUTE)
}
}

View file

@ -154,4 +154,6 @@
<string name="settings_enable_space_pager">Swipe chat list to switch space</string>
<string name="settings_enable_space_pager_summary">Allow to switch between root spaces by swiping horizontally in the chat list</string>
<!-- Default notification rule -->
<string name="room_settings_default">Default</string>
</resources>