mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
change notification state options as outlined in v2
This commit is contained in:
parent
90e04d4358
commit
57c32502e5
@ -41,11 +41,11 @@ class RoomNotificationSettingsController @Inject constructor() : TypedEpoxyContr
|
||||
}
|
||||
|
||||
@StringRes
|
||||
private fun titleForNotificationState(notificationState: RoomNotificationState) = when(notificationState) {
|
||||
RoomNotificationState.ALL_MESSAGES_NOISY -> R.string.room_settings_all_messages_noisy
|
||||
RoomNotificationState.ALL_MESSAGES -> R.string.room_settings_all_messages
|
||||
RoomNotificationState.MENTIONS_ONLY -> R.string.room_settings_mention_only
|
||||
RoomNotificationState.MUTE -> R.string.room_settings_mute
|
||||
private fun titleForNotificationState(notificationState: RoomNotificationState): Int? = when(notificationState) {
|
||||
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
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun buildModels(data: RoomNotificationSettingsViewState?) {
|
||||
@ -61,7 +61,7 @@ class RoomNotificationSettingsController @Inject constructor() : TypedEpoxyContr
|
||||
radioButtonItem {
|
||||
id(notificationState.name)
|
||||
titleRes(title)
|
||||
selected(data.notificationState() == notificationState)
|
||||
selected(data.notificationStateMapped() == notificationState)
|
||||
listener {
|
||||
host.callback?.didSelectRoomNotificationState(notificationState)
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ package im.vector.app.features.roomprofile.notifications
|
||||
|
||||
import com.airbnb.mvrx.Async
|
||||
import com.airbnb.mvrx.MvRxState
|
||||
import com.airbnb.mvrx.Success
|
||||
import com.airbnb.mvrx.Uninitialized
|
||||
import im.vector.app.features.roomprofile.RoomProfileArgs
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||
@ -30,7 +31,6 @@ data class RoomNotificationSettingsViewState(
|
||||
val roomEncrypted: Boolean = false,
|
||||
val notificationState: Async<RoomNotificationState> = Uninitialized,
|
||||
) : MvRxState {
|
||||
|
||||
constructor(args: RoomProfileArgs) : this(roomId = args.roomId)
|
||||
}
|
||||
|
||||
@ -39,10 +39,26 @@ data class AvatarData (
|
||||
val avatarUrl: String
|
||||
)
|
||||
|
||||
/**
|
||||
* Used to map this old room notification settings to the new options in v2.
|
||||
*/
|
||||
val RoomNotificationSettingsViewState.notificationStateMapped: Async<RoomNotificationState>
|
||||
get() {
|
||||
if ((roomEncrypted && 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
|
||||
*/
|
||||
return Success(RoomNotificationState.ALL_MESSAGES_NOISY)
|
||||
}
|
||||
return notificationState
|
||||
}
|
||||
/**
|
||||
* Used to enumerate the new settings in notification settings v2. Notifications without sound and mentions in encrypted rooms not supported.
|
||||
*/
|
||||
val RoomNotificationSettingsViewState.notificationOptions: List<RoomNotificationState>
|
||||
get() {
|
||||
return if (roomEncrypted) {
|
||||
listOf(RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.ALL_MESSAGES, RoomNotificationState.MUTE)
|
||||
listOf(RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MUTE)
|
||||
} else
|
||||
RoomNotificationState.values().asList()
|
||||
listOf(RoomNotificationState.ALL_MESSAGES_NOISY, RoomNotificationState.MENTIONS_ONLY, RoomNotificationState.MUTE)
|
||||
}
|
||||
|
@ -1037,6 +1037,8 @@
|
||||
<string name="room_settings_all_messages">All messages</string>
|
||||
<string name="room_settings_mention_only">Mentions only</string>
|
||||
<string name="room_settings_mute">Mute</string>
|
||||
<string name="room_settings_mention_and_keyword_only">Mentions & Keywords only</string>
|
||||
<string name="room_settings_none">None</string>
|
||||
<string name="room_settings_favourite">Favourite</string>
|
||||
<string name="room_settings_de_prioritize">De-prioritize</string>
|
||||
<string name="room_settings_direct_chat">Direct Chat</string>
|
||||
|
Loading…
Reference in New Issue
Block a user