/snow -> /snowfall and update wording (iso Element Web) (#3430)

This commit is contained in:
Benoit Marty 2021-05-31 10:53:04 +02:00
parent 575ebdc3e8
commit 90a16ebbaf
8 changed files with 15 additions and 14 deletions

View File

@ -35,5 +35,5 @@ object MessageType {
const val MSGTYPE_STICKER_LOCAL = "org.matrix.android.sdk.sticker" const val MSGTYPE_STICKER_LOCAL = "org.matrix.android.sdk.sticker"
const val MSGTYPE_CONFETTI = "nic.custom.confetti" const val MSGTYPE_CONFETTI = "nic.custom.confetti"
const val MSGTYPE_SNOW = "io.element.effect.snowfall" const val MSGTYPE_SNOWFALL = "io.element.effect.snowfall"
} }

View File

@ -0,0 +1 @@
/snow -> /snowfall and update wording (iso Element Web)

View File

@ -46,7 +46,7 @@ enum class Command(val command: String, val parameters: String, @StringRes val d
PLAIN("/plain", "<message>", R.string.command_description_plain, false), PLAIN("/plain", "<message>", R.string.command_description_plain, false),
DISCARD_SESSION("/discardsession", "", R.string.command_description_discard_session, false), DISCARD_SESSION("/discardsession", "", R.string.command_description_discard_session, false),
CONFETTI("/confetti", "<message>", R.string.command_confetti, false), CONFETTI("/confetti", "<message>", R.string.command_confetti, false),
SNOW("/snow", "<message>", R.string.command_snow, false), SNOWFALL("/snowfall", "<message>", R.string.command_snow, false),
CREATE_SPACE("/createspace", "<name> <invitee>*", R.string.command_description_create_space, true), CREATE_SPACE("/createspace", "<name> <invitee>*", R.string.command_description_create_space, true),
ADD_TO_SPACE("/addToSpace", "spaceId", R.string.command_description_create_space, true), ADD_TO_SPACE("/addToSpace", "spaceId", R.string.command_description_create_space, true),
JOIN_SPACE("/joinSpace", "spaceId", R.string.command_description_join_space, true), JOIN_SPACE("/joinSpace", "spaceId", R.string.command_description_join_space, true),

View File

@ -296,9 +296,9 @@ object CommandParser {
val message = textMessage.substring(Command.CONFETTI.command.length).trim() val message = textMessage.substring(Command.CONFETTI.command.length).trim()
ParsedCommand.SendChatEffect(ChatEffect.CONFETTI, message) ParsedCommand.SendChatEffect(ChatEffect.CONFETTI, message)
} }
Command.SNOW.command -> { Command.SNOWFALL.command -> {
val message = textMessage.substring(Command.SNOW.command.length).trim() val message = textMessage.substring(Command.SNOWFALL.command.length).trim()
ParsedCommand.SendChatEffect(ChatEffect.SNOW, message) ParsedCommand.SendChatEffect(ChatEffect.SNOWFALL, message)
} }
Command.CREATE_SPACE.command -> { Command.CREATE_SPACE.command -> {
val rawCommand = textMessage.substring(Command.CREATE_SPACE.command.length).trim() val rawCommand = textMessage.substring(Command.CREATE_SPACE.command.length).trim()

View File

@ -26,13 +26,13 @@ import javax.inject.Inject
enum class ChatEffect { enum class ChatEffect {
CONFETTI, CONFETTI,
SNOW SNOWFALL
} }
fun ChatEffect.toMessageType(): String { fun ChatEffect.toMessageType(): String {
return when (this) { return when (this) {
ChatEffect.CONFETTI -> MessageType.MSGTYPE_CONFETTI ChatEffect.CONFETTI -> MessageType.MSGTYPE_CONFETTI
ChatEffect.SNOW -> MessageType.MSGTYPE_SNOW ChatEffect.SNOWFALL -> MessageType.MSGTYPE_SNOWFALL
} }
} }
@ -112,14 +112,14 @@ class ChatEffectManager @Inject constructor() {
private fun findEffect(content: MessageContent, event: TimelineEvent): ChatEffect? { private fun findEffect(content: MessageContent, event: TimelineEvent): ChatEffect? {
return when (content.msgType) { return when (content.msgType) {
MessageType.MSGTYPE_CONFETTI -> ChatEffect.CONFETTI MessageType.MSGTYPE_CONFETTI -> ChatEffect.CONFETTI
MessageType.MSGTYPE_SNOW -> ChatEffect.SNOW MessageType.MSGTYPE_SNOWFALL -> ChatEffect.SNOWFALL
MessageType.MSGTYPE_EMOTE, MessageType.MSGTYPE_EMOTE,
MessageType.MSGTYPE_TEXT -> { MessageType.MSGTYPE_TEXT -> {
event.root.getClearContent().toModel<MessageContent>()?.body event.root.getClearContent().toModel<MessageContent>()?.body
?.let { text -> ?.let { text ->
when { when {
EMOJIS_FOR_CONFETTI.any { text.contains(it) } -> ChatEffect.CONFETTI EMOJIS_FOR_CONFETTI.any { text.contains(it) } -> ChatEffect.CONFETTI
EMOJIS_FOR_SNOW.any { text.contains(it) } -> ChatEffect.SNOW EMOJIS_FOR_SNOWFALL.any { text.contains(it) } -> ChatEffect.SNOWFALL
else -> null else -> null
} }
} }
@ -133,7 +133,7 @@ class ChatEffectManager @Inject constructor() {
"🎉", "🎉",
"🎊" "🎊"
) )
private val EMOJIS_FOR_SNOW = listOf( private val EMOJIS_FOR_SNOWFALL = listOf(
"⛄️", "⛄️",
"☃️", "☃️",
"❄️" "❄️"

View File

@ -438,7 +438,7 @@ class RoomDetailFragment @Inject constructor(
.setPosition(-50f, views.viewKonfetti.width + 50f, -50f, -50f) .setPosition(-50f, views.viewKonfetti.width + 50f, -50f, -50f)
.streamFor(150, 3000L) .streamFor(150, 3000L)
} }
ChatEffect.SNOW -> { ChatEffect.SNOWFALL -> {
views.viewSnowFall.isVisible = true views.viewSnowFall.isVisible = true
views.viewSnowFall.restartFalling() views.viewSnowFall.restartFalling()
} }

View File

@ -893,7 +893,7 @@ class RoomDetailViewModel @AssistedInject constructor(
if (sendChatEffect.message.isBlank()) { if (sendChatEffect.message.isBlank()) {
val defaultMessage = stringProvider.getString(when (sendChatEffect.chatEffect) { val defaultMessage = stringProvider.getString(when (sendChatEffect.chatEffect) {
ChatEffect.CONFETTI -> R.string.default_message_emote_confetti ChatEffect.CONFETTI -> R.string.default_message_emote_confetti
ChatEffect.SNOW -> R.string.default_message_emote_snow ChatEffect.SNOWFALL -> R.string.default_message_emote_snow
}) })
room.sendTextMessage(defaultMessage, MessageType.MSGTYPE_EMOTE) room.sendTextMessage(defaultMessage, MessageType.MSGTYPE_EMOTE)
} else { } else {

View File

@ -3010,11 +3010,11 @@
</plurals> </plurals>
<string name="command_confetti">Sends the given message with confetti</string> <string name="command_confetti">Sends the given message with confetti</string>
<string name="command_snow">Sends the given message with snow</string> <string name="command_snow">Sends the given message with snowfall</string>
<!-- Note to translators: please use the same emoji 🎉 in your translation --> <!-- Note to translators: please use the same emoji 🎉 in your translation -->
<string name="default_message_emote_confetti">sends confetti 🎉</string> <string name="default_message_emote_confetti">sends confetti 🎉</string>
<!-- Note to translators: please use the same emoji ❄️ in your translation --> <!-- Note to translators: please use the same emoji ❄️ in your translation -->
<string name="default_message_emote_snow">sends snow ❄️</string> <string name="default_message_emote_snow">sends snowfall ❄️</string>
<string name="unencrypted">Unencrypted</string> <string name="unencrypted">Unencrypted</string>
<string name="encrypted_unverified">Encrypted by an unverified device</string> <string name="encrypted_unverified">Encrypted by an unverified device</string>