From c0cf534845d55ca1572d95ee67f0a23ff17c3d84 Mon Sep 17 00:00:00 2001 From: Constantin Wartenburger Date: Sat, 10 Oct 2020 16:36:04 +0200 Subject: [PATCH 0001/1289] Added commands from element web --- .../im/vector/app/features/command/Command.kt | 7 +- .../app/features/command/CommandParser.kt | 79 ++++++++++++++++--- .../app/features/command/ParsedCommand.kt | 7 +- .../home/room/detail/RoomDetailFragment.kt | 1 + .../home/room/detail/RoomDetailViewEvents.kt | 12 +-- .../home/room/detail/RoomDetailViewModel.kt | 68 +++++++++++++--- vector/src/main/res/values/strings.xml | 5 ++ 7 files changed, 149 insertions(+), 30 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/command/Command.kt b/vector/src/main/java/im/vector/app/features/command/Command.kt index db429f9e58..c1b30b2744 100644 --- a/vector/src/main/java/im/vector/app/features/command/Command.kt +++ b/vector/src/main/java/im/vector/app/features/command/Command.kt @@ -28,8 +28,11 @@ enum class Command(val command: String, val parameters: String, @StringRes val d EMOTE("/me", "", R.string.command_description_emote), BAN_USER("/ban", " [reason]", R.string.command_description_ban_user), UNBAN_USER("/unban", " [reason]", R.string.command_description_unban_user), + IGNORE_USER("/ignore", " [reason]", R.string.command_description_ignore_user), + UNIGNORE_USER("/unignore", "", R.string.command_description_unignore_user), SET_USER_POWER_LEVEL("/op", " []", R.string.command_description_op_user), RESET_USER_POWER_LEVEL("/deop", "", R.string.command_description_deop_user), + ROOM_NAME("/roomname", " [reason]", R.string.command_description_room_name), INVITE("/invite", " [reason]", R.string.command_description_invite_user), JOIN_ROOM("/join", " [reason]", R.string.command_description_join_room), PART("/part", " [reason]", R.string.command_description_part_room), @@ -42,8 +45,10 @@ enum class Command(val command: String, val parameters: String, @StringRes val d CLEAR_SCALAR_TOKEN("/clear_scalar_token", "", R.string.command_description_clear_scalar_token), SPOILER("/spoiler", "", R.string.command_description_spoiler), POLL("/poll", "Question | Option 1 | Option 2 ...", R.string.command_description_poll), - SHRUG("/shrug", "", R.string.command_description_shrug), + SHRUG("/shrug", "[]", R.string.command_description_shrug), + LENNY("/lenny", "[]", R.string.command_description_lenny), PLAIN("/plain", "", R.string.command_description_plain), + WHOIS("/whois", "", R.string.command_description_whois), DISCARD_SESSION("/discardsession", "", R.string.command_description_discard_session); val length diff --git a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt index 94de6bf265..fd7d587c1c 100644 --- a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt +++ b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt @@ -102,7 +102,7 @@ object CommandParser { ParsedCommand.SendRainbowEmote(message) } - Command.JOIN_ROOM.command -> { + Command.JOIN_ROOM.command -> { if (messageParts.size >= 2) { val roomAlias = messageParts[1] @@ -120,7 +120,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.JOIN_ROOM) } } - Command.PART.command -> { + Command.PART.command -> { if (messageParts.size >= 2) { val roomAlias = messageParts[1] @@ -138,7 +138,16 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.PART) } } - Command.INVITE.command -> { + Command.ROOM_NAME.command -> { + val newRoomName = textMessage.substring(Command.ROOM_NAME.command.length).trim() + + if (newRoomName.isNotEmpty()) { + ParsedCommand.ChangeRoomName(newRoomName) + } else { + ParsedCommand.ErrorSyntax(Command.ROOM_NAME) + } + } + Command.INVITE.command -> { if (messageParts.size >= 2) { val userId = messageParts[1] @@ -183,7 +192,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.KICK_USER) } } - Command.BAN_USER.command -> { + Command.BAN_USER.command -> { if (messageParts.size >= 2) { val userId = messageParts[1] @@ -201,7 +210,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.BAN_USER) } } - Command.UNBAN_USER.command -> { + Command.UNBAN_USER.command -> { if (messageParts.size >= 2) { val userId = messageParts[1] @@ -219,7 +228,33 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.UNBAN_USER) } } - Command.SET_USER_POWER_LEVEL.command -> { + Command.IGNORE_USER.command -> { + if (messageParts.size == 2) { + val userId = messageParts[1] + + if (MatrixPatterns.isUserId(userId)) { + ParsedCommand.IgnoreUser(userId) + } else { + ParsedCommand.ErrorSyntax(Command.IGNORE_USER) + } + } else { + ParsedCommand.ErrorSyntax(Command.IGNORE_USER) + } + } + Command.UNIGNORE_USER.command -> { + if (messageParts.size == 2) { + val userId = messageParts[1] + + if (MatrixPatterns.isUserId(userId)) { + ParsedCommand.UnignoreUser(userId) + } else { + ParsedCommand.ErrorSyntax(Command.UNIGNORE_USER) + } + } else { + ParsedCommand.ErrorSyntax(Command.UNIGNORE_USER) + } + } + Command.SET_USER_POWER_LEVEL.command -> { if (messageParts.size == 3) { val userId = messageParts[1] if (MatrixPatterns.isUserId(userId)) { @@ -252,7 +287,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.SET_USER_POWER_LEVEL) } } - Command.MARKDOWN.command -> { + Command.MARKDOWN.command -> { if (messageParts.size == 2) { when { "on".equals(messageParts[1], true) -> ParsedCommand.SetMarkdown(true) @@ -263,23 +298,28 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.MARKDOWN) } } - Command.CLEAR_SCALAR_TOKEN.command -> { + Command.CLEAR_SCALAR_TOKEN.command -> { if (messageParts.size == 1) { ParsedCommand.ClearScalarToken } else { ParsedCommand.ErrorSyntax(Command.CLEAR_SCALAR_TOKEN) } } - Command.SPOILER.command -> { + Command.SPOILER.command -> { val message = textMessage.substring(Command.SPOILER.command.length).trim() ParsedCommand.SendSpoiler(message) } - Command.SHRUG.command -> { + Command.SHRUG.command -> { val message = textMessage.substring(Command.SHRUG.command.length).trim() ParsedCommand.SendShrug(message) } - Command.POLL.command -> { + Command.LENNY.command -> { + val message = textMessage.substring(Command.LENNY.command.length).trim() + + ParsedCommand.SendLenny(message) + } + Command.POLL.command -> { val rawCommand = textMessage.substring(Command.POLL.command.length).trim() val split = rawCommand.split("|").map { it.trim() } if (split.size > 2) { @@ -288,10 +328,23 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.POLL) } } - Command.DISCARD_SESSION.command -> { + Command.DISCARD_SESSION.command -> { ParsedCommand.DiscardSession } - else -> { + Command.WHOIS.command -> { + if (messageParts.size == 2) { + val userId = messageParts[1] + + if (MatrixPatterns.isUserId(userId)) { + ParsedCommand.ShowUser(userId) + } else { + ParsedCommand.ErrorSyntax(Command.WHOIS) + } + } else { + ParsedCommand.ErrorSyntax(Command.WHOIS) + } + } + else -> { // Unknown command ParsedCommand.ErrorUnknownSlashCommand(slashCommand) } diff --git a/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt b/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt index bdfa7779fb..54043f343a 100644 --- a/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt +++ b/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt @@ -41,7 +41,10 @@ sealed class ParsedCommand { class SendRainbowEmote(val message: CharSequence) : ParsedCommand() class BanUser(val userId: String, val reason: String?) : ParsedCommand() class UnbanUser(val userId: String, val reason: String?) : ParsedCommand() + class IgnoreUser(val userId: String) : ParsedCommand() + class UnignoreUser(val userId: String) : ParsedCommand() class SetUserPowerLevel(val userId: String, val powerLevel: Int?) : ParsedCommand() + class ChangeRoomName(val name: String) : ParsedCommand() class Invite(val userId: String, val reason: String?) : ParsedCommand() class Invite3Pid(val threePid: ThreePid) : ParsedCommand() class JoinRoom(val roomAlias: String, val reason: String?) : ParsedCommand() @@ -53,6 +56,8 @@ sealed class ParsedCommand { object ClearScalarToken : ParsedCommand() class SendSpoiler(val message: String) : ParsedCommand() class SendShrug(val message: CharSequence) : ParsedCommand() + class SendLenny(val message: CharSequence) : ParsedCommand() class SendPoll(val question: String, val options: List) : ParsedCommand() - object DiscardSession: ParsedCommand() + object DiscardSession : ParsedCommand() + class ShowUser(val userId: String) : ParsedCommand() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt index 51aeda2aab..a9c2307566 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt @@ -359,6 +359,7 @@ class RoomDetailFragment @Inject constructor( is RoomDetailViewEvents.SendMessageResult -> renderSendMessageResult(it) is RoomDetailViewEvents.ShowE2EErrorMessage -> displayE2eError(it.withHeldCode) RoomDetailViewEvents.DisplayPromptForIntegrationManager -> displayPromptForIntegrationManager() + is RoomDetailViewEvents.OpenRoomMemberProfile -> openRoomMemberProfile(it.userId) is RoomDetailViewEvents.OpenStickerPicker -> openStickerPicker(it) is RoomDetailViewEvents.DisplayEnableIntegrationsWarning -> displayDisabledIntegrationDialog() is RoomDetailViewEvents.OpenIntegrationManager -> openIntegrationManager() diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewEvents.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewEvents.kt index 29ed43f17d..b747075622 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewEvents.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewEvents.kt @@ -64,14 +64,16 @@ sealed class RoomDetailViewEvents : VectorViewEvents { abstract class SendMessageResult : RoomDetailViewEvents() - object DisplayPromptForIntegrationManager: RoomDetailViewEvents() + object DisplayPromptForIntegrationManager : RoomDetailViewEvents() - object DisplayEnableIntegrationsWarning: RoomDetailViewEvents() + object DisplayEnableIntegrationsWarning : RoomDetailViewEvents() - data class OpenStickerPicker(val widget: Widget): RoomDetailViewEvents() + data class OpenRoomMemberProfile(val userId: String) : RoomDetailViewEvents() - object OpenIntegrationManager: RoomDetailViewEvents() - object OpenActiveWidgetBottomSheet: RoomDetailViewEvents() + data class OpenStickerPicker(val widget: Widget) : RoomDetailViewEvents() + + object OpenIntegrationManager : RoomDetailViewEvents() + object OpenActiveWidgetBottomSheet : RoomDetailViewEvents() data class RequestNativeWidgetPermission(val widget: Widget, val domain: String, val grantedEvents: RoomDetailViewEvents) : RoomDetailViewEvents() diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt index 1b5e928843..2e7109b5e7 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt @@ -571,6 +571,10 @@ class RoomDetailViewModel @AssistedInject constructor( _viewEvents.post(RoomDetailViewEvents.MessageSent) popDraft() } + is ParsedCommand.ChangeRoomName -> { + handleChangeRoomNameSlashCommand(slashCommandResult) + popDraft() + } is ParsedCommand.Invite -> { handleInviteSlashCommand(slashCommandResult) popDraft() @@ -593,12 +597,20 @@ class RoomDetailViewModel @AssistedInject constructor( if (slashCommandResult.enable) R.string.markdown_has_been_enabled else R.string.markdown_has_been_disabled)) popDraft() } + is ParsedCommand.BanUser -> { + handleBanSlashCommand(slashCommandResult) + popDraft() + } is ParsedCommand.UnbanUser -> { handleUnbanSlashCommand(slashCommandResult) popDraft() } - is ParsedCommand.BanUser -> { - handleBanSlashCommand(slashCommandResult) + is ParsedCommand.IgnoreUser -> { + handleIgnoreSlashCommand(slashCommandResult) + popDraft() + } + is ParsedCommand.UnignoreUser -> { + handleUnignoreSlashCommand(slashCommandResult) popDraft() } is ParsedCommand.KickUser -> { @@ -641,14 +653,12 @@ class RoomDetailViewModel @AssistedInject constructor( popDraft() } is ParsedCommand.SendShrug -> { - val sequence = buildString { - append("¯\\_(ツ)_/¯") - if (slashCommandResult.message.isNotEmpty()) { - append(" ") - append(slashCommandResult.message) - } - } - room.sendTextMessage(sequence) + sendPrefixedMessage("¯\\_(ツ)_/¯", slashCommandResult.message) + _viewEvents.post(RoomDetailViewEvents.SlashCommandHandled()) + popDraft() + } + is ParsedCommand.SendLenny -> { + sendPrefixedMessage("( ͡° ͜ʖ ͡°)", slashCommandResult.message) _viewEvents.post(RoomDetailViewEvents.SlashCommandHandled()) popDraft() } @@ -665,6 +675,11 @@ class RoomDetailViewModel @AssistedInject constructor( handleChangeDisplayNameSlashCommand(slashCommandResult) popDraft() } + is ParsedCommand.ShowUser -> { + _viewEvents.post(RoomDetailViewEvents.SlashCommandHandled()) + handleWhoisSlashCommand(slashCommandResult) + popDraft() + } is ParsedCommand.DiscardSession -> { if (room.isEncrypted()) { session.cryptoService().discardOutboundSession(room.roomId) @@ -786,6 +801,12 @@ class RoomDetailViewModel @AssistedInject constructor( } } + private fun handleChangeRoomNameSlashCommand(changeRoomName: ParsedCommand.ChangeRoomName) { + launchSlashCommandFlow { + room.updateName(changeRoomName.name, it) + } + } + private fun handleInviteSlashCommand(invite: ParsedCommand.Invite) { launchSlashCommandFlow { room.invite(invite.userId, invite.reason, it) @@ -833,6 +854,33 @@ class RoomDetailViewModel @AssistedInject constructor( } } + private fun handleIgnoreSlashCommand(ignore: ParsedCommand.IgnoreUser) { + launchSlashCommandFlow { + session.ignoreUserIds(listOf(ignore.userId), it) + } + } + + private fun handleUnignoreSlashCommand(unignore: ParsedCommand.UnignoreUser) { + launchSlashCommandFlow { + session.unIgnoreUserIds(listOf(unignore.userId), it) + } + } + + private fun handleWhoisSlashCommand(whois: ParsedCommand.ShowUser) { + _viewEvents.post(RoomDetailViewEvents.OpenRoomMemberProfile(whois.userId)) + } + + private fun sendPrefixedMessage(prefix: String, message: CharSequence) { + val sequence = buildString { + append(prefix) + if (message.isNotEmpty()) { + append(" ") + append(message) + } + } + room.sendTextMessage(sequence) + } + private fun launchSlashCommandFlow(lambda: (MatrixCallback) -> Unit) { _viewEvents.post(RoomDetailViewEvents.SlashCommandHandled()) val matrixCallback = object : MatrixCallback { diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index c025054f98..f87b45cd05 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -1287,8 +1287,11 @@ Displays action Bans user with given id Unbans user with given id + Ignores a user, hiding their messages from you + Stops ignoring a user, showing their messages going forward Define the power level of a user Deops user with given id + Sets the room name Invites user with given id to current room Joins room with given alias Leave room @@ -1297,6 +1300,7 @@ Changes your display nickname On/Off markdown To fix Matrix Apps management + Displays information about a user Markdown has been enabled. Markdown has been disabled. @@ -2063,6 +2067,7 @@ Element may crash more often when an unexpected error occurs Prepends ¯\\_(ツ)_/¯ to a plain-text message + Prepends ( ͡° ͜ʖ ͡°) to a plain-text message "Enable encryption" "Once enabled, encryption cannot be disabled." From 13960561c00d6a44d8e44d7f8586be66075aeeb5 Mon Sep 17 00:00:00 2001 From: Constantin Wartenburger Date: Sat, 10 Oct 2020 18:34:31 +0200 Subject: [PATCH 0002/1289] Added /myroomnick command --- .../im/vector/app/features/command/Command.kt | 1 + .../app/features/command/CommandParser.kt | 23 +++++++++++++------ .../app/features/command/ParsedCommand.kt | 1 + .../home/room/detail/RoomDetailViewModel.kt | 15 ++++++++++++ vector/src/main/res/values/strings.xml | 1 + 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/command/Command.kt b/vector/src/main/java/im/vector/app/features/command/Command.kt index c1b30b2744..1db1639b1d 100644 --- a/vector/src/main/java/im/vector/app/features/command/Command.kt +++ b/vector/src/main/java/im/vector/app/features/command/Command.kt @@ -39,6 +39,7 @@ enum class Command(val command: String, val parameters: String, @StringRes val d TOPIC("/topic", "", R.string.command_description_topic), KICK_USER("/kick", " [reason]", R.string.command_description_kick_user), CHANGE_DISPLAY_NAME("/nick", "", R.string.command_description_nick), + CHANGE_DISPLAY_NAME_FOR_ROOM("/myroomnick", "", R.string.command_description_room_nick), MARKDOWN("/markdown", "", R.string.command_description_markdown), RAINBOW("/rainbow", "", R.string.command_description_rainbow), RAINBOW_EMOTE("/rainbowme", "", R.string.command_description_rainbow_emote), diff --git a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt index fd7d587c1c..e09b6a842d 100644 --- a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt +++ b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt @@ -60,7 +60,7 @@ object CommandParser { } return when (val slashCommand = messageParts.first()) { - Command.PLAIN.command -> { + Command.PLAIN.command -> { val text = textMessage.substring(Command.PLAIN.command.length).trim() if (text.isNotEmpty()) { @@ -69,7 +69,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.PLAIN) } } - Command.CHANGE_DISPLAY_NAME.command -> { + Command.CHANGE_DISPLAY_NAME.command -> { val newDisplayName = textMessage.substring(Command.CHANGE_DISPLAY_NAME.command.length).trim() if (newDisplayName.isNotEmpty()) { @@ -78,7 +78,16 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.CHANGE_DISPLAY_NAME) } } - Command.TOPIC.command -> { + Command.CHANGE_DISPLAY_NAME_FOR_ROOM.command -> { + val newDisplayName = textMessage.substring(Command.CHANGE_DISPLAY_NAME_FOR_ROOM.command.length).trim() + + if (newDisplayName.isNotEmpty()) { + ParsedCommand.ChangeDisplayNameForRoom(newDisplayName) + } else { + ParsedCommand.ErrorSyntax(Command.CHANGE_DISPLAY_NAME_FOR_ROOM) + } + } + Command.TOPIC.command -> { val newTopic = textMessage.substring(Command.TOPIC.command.length).trim() if (newTopic.isNotEmpty()) { @@ -87,22 +96,22 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.TOPIC) } } - Command.EMOTE.command -> { + Command.EMOTE.command -> { val message = textMessage.subSequence(Command.EMOTE.command.length, textMessage.length).trim() ParsedCommand.SendEmote(message) } - Command.RAINBOW.command -> { + Command.RAINBOW.command -> { val message = textMessage.subSequence(Command.RAINBOW.command.length, textMessage.length).trim() ParsedCommand.SendRainbow(message) } - Command.RAINBOW_EMOTE.command -> { + Command.RAINBOW_EMOTE.command -> { val message = textMessage.subSequence(Command.RAINBOW_EMOTE.command.length, textMessage.length).trim() ParsedCommand.SendRainbowEmote(message) } - Command.JOIN_ROOM.command -> { + Command.JOIN_ROOM.command -> { if (messageParts.size >= 2) { val roomAlias = messageParts[1] diff --git a/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt b/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt index 54043f343a..60b4e1c3a2 100644 --- a/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt +++ b/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt @@ -52,6 +52,7 @@ sealed class ParsedCommand { class ChangeTopic(val topic: String) : ParsedCommand() class KickUser(val userId: String, val reason: String?) : ParsedCommand() class ChangeDisplayName(val displayName: String) : ParsedCommand() + class ChangeDisplayNameForRoom(val displayName: String) : ParsedCommand() class SetMarkdown(val enable: Boolean) : ParsedCommand() object ClearScalarToken : ParsedCommand() class SendSpoiler(val message: String) : ParsedCommand() diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt index 2e7109b5e7..10942f17bf 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt @@ -74,6 +74,7 @@ import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState import org.matrix.android.sdk.api.session.room.members.roomMemberQueryParams import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent +import org.matrix.android.sdk.api.session.room.model.RoomMemberContent import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary import org.matrix.android.sdk.api.session.room.model.RoomSummary import org.matrix.android.sdk.api.session.room.model.message.MessageContent @@ -675,6 +676,10 @@ class RoomDetailViewModel @AssistedInject constructor( handleChangeDisplayNameSlashCommand(slashCommandResult) popDraft() } + is ParsedCommand.ChangeDisplayNameForRoom -> { + handleChangeDisplayNameForRoomSlashCommand(slashCommandResult) + popDraft() + } is ParsedCommand.ShowUser -> { _viewEvents.post(RoomDetailViewEvents.SlashCommandHandled()) handleWhoisSlashCommand(slashCommandResult) @@ -836,6 +841,16 @@ class RoomDetailViewModel @AssistedInject constructor( } } + private fun handleChangeDisplayNameForRoomSlashCommand(changeDisplayName: ParsedCommand.ChangeDisplayNameForRoom) { + val content = room.getStateEvent(EventType.STATE_ROOM_MEMBER, QueryStringValue.Equals(session.myUserId)) + ?.content?.toModel() + ?: RoomMemberContent(membership = Membership.JOIN) + + launchSlashCommandFlow { + room.sendStateEvent(EventType.STATE_ROOM_MEMBER, session.myUserId, content.copy(displayName = changeDisplayName.displayName).toContent(), it) + } + } + private fun handleKickSlashCommand(kick: ParsedCommand.KickUser) { launchSlashCommandFlow { room.kick(kick.userId, kick.reason, it) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index f87b45cd05..33c648d647 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -1298,6 +1298,7 @@ Set the room topic Kicks user with given id Changes your display nickname + Changes your display nickname On/Off markdown To fix Matrix Apps management Displays information about a user From 1a40b65b53677b79b3d6beb34335fdd9d3dab80a Mon Sep 17 00:00:00 2001 From: Constantin Wartenburger Date: Sun, 11 Oct 2020 18:56:13 +0200 Subject: [PATCH 0003/1289] Added /myroomavatar command (without upload) --- .../im/vector/app/features/command/Command.kt | 3 +- .../app/features/command/CommandParser.kt | 51 ++++++++++++------- .../app/features/command/ParsedCommand.kt | 1 + .../home/room/detail/RoomDetailViewModel.kt | 18 +++++-- vector/src/main/res/values/strings.xml | 3 +- 5 files changed, 52 insertions(+), 24 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/command/Command.kt b/vector/src/main/java/im/vector/app/features/command/Command.kt index 1db1639b1d..fd0623dc05 100644 --- a/vector/src/main/java/im/vector/app/features/command/Command.kt +++ b/vector/src/main/java/im/vector/app/features/command/Command.kt @@ -39,7 +39,8 @@ enum class Command(val command: String, val parameters: String, @StringRes val d TOPIC("/topic", "", R.string.command_description_topic), KICK_USER("/kick", " [reason]", R.string.command_description_kick_user), CHANGE_DISPLAY_NAME("/nick", "", R.string.command_description_nick), - CHANGE_DISPLAY_NAME_FOR_ROOM("/myroomnick", "", R.string.command_description_room_nick), + CHANGE_DISPLAY_NAME_FOR_ROOM("/myroomnick", "", R.string.command_description_nick_for_room), + CHANGE_AVATAR_FOR_ROOM("/myroomavatar", "", R.string.command_description_avatar_for_room), MARKDOWN("/markdown", "", R.string.command_description_markdown), RAINBOW("/rainbow", "", R.string.command_description_rainbow), RAINBOW_EMOTE("/rainbowme", "", R.string.command_description_rainbow_emote), diff --git a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt index e09b6a842d..d5fb9a41b6 100644 --- a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt +++ b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt @@ -87,6 +87,19 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.CHANGE_DISPLAY_NAME_FOR_ROOM) } } + Command.CHANGE_AVATAR_FOR_ROOM.command -> { + if (messageParts.size == 2) { + val url = messageParts[1] + + if (url.isNotEmpty()) { + ParsedCommand.ChangeAvatarForRoom(url) + } else { + ParsedCommand.ErrorSyntax(Command.CHANGE_AVATAR_FOR_ROOM) + } + } else { + ParsedCommand.ErrorSyntax(Command.CHANGE_AVATAR_FOR_ROOM) + } + } Command.TOPIC.command -> { val newTopic = textMessage.substring(Command.TOPIC.command.length).trim() @@ -129,7 +142,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.JOIN_ROOM) } } - Command.PART.command -> { + Command.PART.command -> { if (messageParts.size >= 2) { val roomAlias = messageParts[1] @@ -147,7 +160,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.PART) } } - Command.ROOM_NAME.command -> { + Command.ROOM_NAME.command -> { val newRoomName = textMessage.substring(Command.ROOM_NAME.command.length).trim() if (newRoomName.isNotEmpty()) { @@ -156,7 +169,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.ROOM_NAME) } } - Command.INVITE.command -> { + Command.INVITE.command -> { if (messageParts.size >= 2) { val userId = messageParts[1] @@ -183,7 +196,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.INVITE) } } - Command.KICK_USER.command -> { + Command.KICK_USER.command -> { if (messageParts.size >= 2) { val userId = messageParts[1] @@ -201,7 +214,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.KICK_USER) } } - Command.BAN_USER.command -> { + Command.BAN_USER.command -> { if (messageParts.size >= 2) { val userId = messageParts[1] @@ -219,7 +232,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.BAN_USER) } } - Command.UNBAN_USER.command -> { + Command.UNBAN_USER.command -> { if (messageParts.size >= 2) { val userId = messageParts[1] @@ -237,7 +250,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.UNBAN_USER) } } - Command.IGNORE_USER.command -> { + Command.IGNORE_USER.command -> { if (messageParts.size == 2) { val userId = messageParts[1] @@ -250,7 +263,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.IGNORE_USER) } } - Command.UNIGNORE_USER.command -> { + Command.UNIGNORE_USER.command -> { if (messageParts.size == 2) { val userId = messageParts[1] @@ -263,7 +276,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.UNIGNORE_USER) } } - Command.SET_USER_POWER_LEVEL.command -> { + Command.SET_USER_POWER_LEVEL.command -> { if (messageParts.size == 3) { val userId = messageParts[1] if (MatrixPatterns.isUserId(userId)) { @@ -283,7 +296,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.SET_USER_POWER_LEVEL) } } - Command.RESET_USER_POWER_LEVEL.command -> { + Command.RESET_USER_POWER_LEVEL.command -> { if (messageParts.size == 2) { val userId = messageParts[1] @@ -296,7 +309,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.SET_USER_POWER_LEVEL) } } - Command.MARKDOWN.command -> { + Command.MARKDOWN.command -> { if (messageParts.size == 2) { when { "on".equals(messageParts[1], true) -> ParsedCommand.SetMarkdown(true) @@ -307,28 +320,28 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.MARKDOWN) } } - Command.CLEAR_SCALAR_TOKEN.command -> { + Command.CLEAR_SCALAR_TOKEN.command -> { if (messageParts.size == 1) { ParsedCommand.ClearScalarToken } else { ParsedCommand.ErrorSyntax(Command.CLEAR_SCALAR_TOKEN) } } - Command.SPOILER.command -> { + Command.SPOILER.command -> { val message = textMessage.substring(Command.SPOILER.command.length).trim() ParsedCommand.SendSpoiler(message) } - Command.SHRUG.command -> { + Command.SHRUG.command -> { val message = textMessage.substring(Command.SHRUG.command.length).trim() ParsedCommand.SendShrug(message) } - Command.LENNY.command -> { + Command.LENNY.command -> { val message = textMessage.substring(Command.LENNY.command.length).trim() ParsedCommand.SendLenny(message) } - Command.POLL.command -> { + Command.POLL.command -> { val rawCommand = textMessage.substring(Command.POLL.command.length).trim() val split = rawCommand.split("|").map { it.trim() } if (split.size > 2) { @@ -337,10 +350,10 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.POLL) } } - Command.DISCARD_SESSION.command -> { + Command.DISCARD_SESSION.command -> { ParsedCommand.DiscardSession } - Command.WHOIS.command -> { + Command.WHOIS.command -> { if (messageParts.size == 2) { val userId = messageParts[1] @@ -353,7 +366,7 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.WHOIS) } } - else -> { + else -> { // Unknown command ParsedCommand.ErrorUnknownSlashCommand(slashCommand) } diff --git a/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt b/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt index 60b4e1c3a2..f0dcbc9663 100644 --- a/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt +++ b/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt @@ -53,6 +53,7 @@ sealed class ParsedCommand { class KickUser(val userId: String, val reason: String?) : ParsedCommand() class ChangeDisplayName(val displayName: String) : ParsedCommand() class ChangeDisplayNameForRoom(val displayName: String) : ParsedCommand() + class ChangeAvatarForRoom(val url: String) : ParsedCommand() class SetMarkdown(val enable: Boolean) : ParsedCommand() object ClearScalarToken : ParsedCommand() class SendSpoiler(val message: String) : ParsedCommand() diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt index 10942f17bf..e84eb5520c 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt @@ -680,6 +680,10 @@ class RoomDetailViewModel @AssistedInject constructor( handleChangeDisplayNameForRoomSlashCommand(slashCommandResult) popDraft() } + is ParsedCommand.ChangeAvatarForRoom -> { + handleChangeAvatarForRoomSlashCommand(slashCommandResult) + popDraft() + } is ParsedCommand.ShowUser -> { _viewEvents.post(RoomDetailViewEvents.SlashCommandHandled()) handleWhoisSlashCommand(slashCommandResult) @@ -841,13 +845,21 @@ class RoomDetailViewModel @AssistedInject constructor( } } - private fun handleChangeDisplayNameForRoomSlashCommand(changeDisplayName: ParsedCommand.ChangeDisplayNameForRoom) { - val content = room.getStateEvent(EventType.STATE_ROOM_MEMBER, QueryStringValue.Equals(session.myUserId)) + private fun getLastMemberEvent(): RoomMemberContent { + return room.getStateEvent(EventType.STATE_ROOM_MEMBER, QueryStringValue.Equals(session.myUserId)) ?.content?.toModel() ?: RoomMemberContent(membership = Membership.JOIN) + } + private fun handleChangeDisplayNameForRoomSlashCommand(changeDisplayName: ParsedCommand.ChangeDisplayNameForRoom) { launchSlashCommandFlow { - room.sendStateEvent(EventType.STATE_ROOM_MEMBER, session.myUserId, content.copy(displayName = changeDisplayName.displayName).toContent(), it) + room.sendStateEvent(EventType.STATE_ROOM_MEMBER, session.myUserId, getLastMemberEvent().copy(displayName = changeDisplayName.displayName).toContent(), it) + } + } + + private fun handleChangeAvatarForRoomSlashCommand(changeAvatar: ParsedCommand.ChangeAvatarForRoom) { + launchSlashCommandFlow { + room.sendStateEvent(EventType.STATE_ROOM_MEMBER, session.myUserId, getLastMemberEvent().copy(avatarUrl = changeAvatar.url).toContent(), it) } } diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 33c648d647..823d567f20 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -1298,7 +1298,8 @@ Set the room topic Kicks user with given id Changes your display nickname - Changes your display nickname + Changes your display nickname in the current room only + Changes your avatar in this current room only On/Off markdown To fix Matrix Apps management Displays information about a user From 24c67660c12d8ac402e50dee16a2c2f6ea94dae1 Mon Sep 17 00:00:00 2001 From: Constantin Wartenburger Date: Mon, 12 Oct 2020 17:43:07 +0200 Subject: [PATCH 0004/1289] Added /roomavatar command (not upload) --- .../im/vector/app/features/command/Command.kt | 3 ++- .../vector/app/features/command/CommandParser.kt | 15 ++++++++++++++- .../vector/app/features/command/ParsedCommand.kt | 1 + .../home/room/detail/RoomDetailViewModel.kt | 11 +++++++++++ vector/src/main/res/values/strings.xml | 1 + 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/command/Command.kt b/vector/src/main/java/im/vector/app/features/command/Command.kt index fd0623dc05..b74b608e32 100644 --- a/vector/src/main/java/im/vector/app/features/command/Command.kt +++ b/vector/src/main/java/im/vector/app/features/command/Command.kt @@ -32,7 +32,7 @@ enum class Command(val command: String, val parameters: String, @StringRes val d UNIGNORE_USER("/unignore", "", R.string.command_description_unignore_user), SET_USER_POWER_LEVEL("/op", " []", R.string.command_description_op_user), RESET_USER_POWER_LEVEL("/deop", "", R.string.command_description_deop_user), - ROOM_NAME("/roomname", " [reason]", R.string.command_description_room_name), + ROOM_NAME("/roomname", "", R.string.command_description_room_name), INVITE("/invite", " [reason]", R.string.command_description_invite_user), JOIN_ROOM("/join", " [reason]", R.string.command_description_join_room), PART("/part", " [reason]", R.string.command_description_part_room), @@ -40,6 +40,7 @@ enum class Command(val command: String, val parameters: String, @StringRes val d KICK_USER("/kick", " [reason]", R.string.command_description_kick_user), CHANGE_DISPLAY_NAME("/nick", "", R.string.command_description_nick), CHANGE_DISPLAY_NAME_FOR_ROOM("/myroomnick", "", R.string.command_description_nick_for_room), + ROOM_AVATAR("/roomavatar", "", R.string.command_description_room_avatar), CHANGE_AVATAR_FOR_ROOM("/myroomavatar", "", R.string.command_description_avatar_for_room), MARKDOWN("/markdown", "", R.string.command_description_markdown), RAINBOW("/rainbow", "", R.string.command_description_rainbow), diff --git a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt index d5fb9a41b6..41961c209a 100644 --- a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt +++ b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt @@ -87,11 +87,24 @@ object CommandParser { ParsedCommand.ErrorSyntax(Command.CHANGE_DISPLAY_NAME_FOR_ROOM) } } + Command.ROOM_AVATAR.command -> { + if (messageParts.size == 2) { + val url = messageParts[1] + + if (url.isNotEmpty() && url.startsWith("mxc://")) { + ParsedCommand.ChangeRoomAvatar(url) + } else { + ParsedCommand.ErrorSyntax(Command.ROOM_AVATAR) + } + } else { + ParsedCommand.ErrorSyntax(Command.ROOM_AVATAR) + } + } Command.CHANGE_AVATAR_FOR_ROOM.command -> { if (messageParts.size == 2) { val url = messageParts[1] - if (url.isNotEmpty()) { + if (url.isNotEmpty() && url.startsWith("mxc://")) { ParsedCommand.ChangeAvatarForRoom(url) } else { ParsedCommand.ErrorSyntax(Command.CHANGE_AVATAR_FOR_ROOM) diff --git a/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt b/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt index f0dcbc9663..16f2eaac29 100644 --- a/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt +++ b/vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt @@ -53,6 +53,7 @@ sealed class ParsedCommand { class KickUser(val userId: String, val reason: String?) : ParsedCommand() class ChangeDisplayName(val displayName: String) : ParsedCommand() class ChangeDisplayNameForRoom(val displayName: String) : ParsedCommand() + class ChangeRoomAvatar(val url: String) : ParsedCommand() class ChangeAvatarForRoom(val url: String) : ParsedCommand() class SetMarkdown(val enable: Boolean) : ParsedCommand() object ClearScalarToken : ParsedCommand() diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt index e84eb5520c..737cdf61b0 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt @@ -74,6 +74,7 @@ import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState import org.matrix.android.sdk.api.session.room.members.roomMemberQueryParams import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent +import org.matrix.android.sdk.api.session.room.model.RoomAvatarContent import org.matrix.android.sdk.api.session.room.model.RoomMemberContent import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary import org.matrix.android.sdk.api.session.room.model.RoomSummary @@ -680,6 +681,10 @@ class RoomDetailViewModel @AssistedInject constructor( handleChangeDisplayNameForRoomSlashCommand(slashCommandResult) popDraft() } + is ParsedCommand.ChangeRoomAvatar -> { + handleChangeRoomAvatarSlashCommand(slashCommandResult) + popDraft() + } is ParsedCommand.ChangeAvatarForRoom -> { handleChangeAvatarForRoomSlashCommand(slashCommandResult) popDraft() @@ -857,6 +862,12 @@ class RoomDetailViewModel @AssistedInject constructor( } } + private fun handleChangeRoomAvatarSlashCommand(changeAvatar: ParsedCommand.ChangeRoomAvatar) { + launchSlashCommandFlow { + room.sendStateEvent(EventType.STATE_ROOM_AVATAR, null, RoomAvatarContent(changeAvatar.url).toContent(), it) + } + } + private fun handleChangeAvatarForRoomSlashCommand(changeAvatar: ParsedCommand.ChangeAvatarForRoom) { launchSlashCommandFlow { room.sendStateEvent(EventType.STATE_ROOM_MEMBER, session.myUserId, getLastMemberEvent().copy(avatarUrl = changeAvatar.url).toContent(), it) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 823d567f20..909ef01b4c 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -1299,6 +1299,7 @@ Kicks user with given id Changes your display nickname Changes your display nickname in the current room only + Changes the avatar of the current room Changes your avatar in this current room only On/Off markdown To fix Matrix Apps management From 5b6727408b5498aa553f7781ecb63d2b2863066b Mon Sep 17 00:00:00 2001 From: Constantin Wartenburger Date: Tue, 13 Oct 2020 15:10:57 +0200 Subject: [PATCH 0005/1289] Fix wrong parameter name --- .../src/main/java/im/vector/app/features/command/Command.kt | 2 +- .../main/java/im/vector/app/features/command/CommandParser.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/command/Command.kt b/vector/src/main/java/im/vector/app/features/command/Command.kt index b74b608e32..81bbf8177d 100644 --- a/vector/src/main/java/im/vector/app/features/command/Command.kt +++ b/vector/src/main/java/im/vector/app/features/command/Command.kt @@ -32,7 +32,7 @@ enum class Command(val command: String, val parameters: String, @StringRes val d UNIGNORE_USER("/unignore", "", R.string.command_description_unignore_user), SET_USER_POWER_LEVEL("/op", " []", R.string.command_description_op_user), RESET_USER_POWER_LEVEL("/deop", "", R.string.command_description_deop_user), - ROOM_NAME("/roomname", "", R.string.command_description_room_name), + ROOM_NAME("/roomname", "", R.string.command_description_room_name), INVITE("/invite", " [reason]", R.string.command_description_invite_user), JOIN_ROOM("/join", " [reason]", R.string.command_description_join_room), PART("/part", " [reason]", R.string.command_description_part_room), diff --git a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt index 41961c209a..29eba00490 100644 --- a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt +++ b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt @@ -91,7 +91,7 @@ object CommandParser { if (messageParts.size == 2) { val url = messageParts[1] - if (url.isNotEmpty() && url.startsWith("mxc://")) { + if (url.startsWith("mxc://")) { ParsedCommand.ChangeRoomAvatar(url) } else { ParsedCommand.ErrorSyntax(Command.ROOM_AVATAR) @@ -104,7 +104,7 @@ object CommandParser { if (messageParts.size == 2) { val url = messageParts[1] - if (url.isNotEmpty() && url.startsWith("mxc://")) { + if (url.startsWith("mxc://")) { ParsedCommand.ChangeAvatarForRoom(url) } else { ParsedCommand.ErrorSyntax(Command.CHANGE_AVATAR_FOR_ROOM) From 5be7b1b7280c053ea8712c4c5bbe66a06d26d9f6 Mon Sep 17 00:00:00 2001 From: dkanada Date: Sat, 9 Jan 2021 23:23:17 +0900 Subject: [PATCH 0006/1289] store cache for WidgetWebView between loads --- .../im/vector/app/features/widgets/webview/WidgetWebView.kt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/widgets/webview/WidgetWebView.kt b/vector/src/main/java/im/vector/app/features/widgets/webview/WidgetWebView.kt index 446bc1663f..dc59f2694f 100644 --- a/vector/src/main/java/im/vector/app/features/widgets/webview/WidgetWebView.kt +++ b/vector/src/main/java/im/vector/app/features/widgets/webview/WidgetWebView.kt @@ -36,10 +36,6 @@ fun WebView.setupForWidget(webViewEventListener: WebViewEventListener) { // clear caches clearHistory() clearFormData() - clearCache(true) - - // does not cache the data - settings.cacheMode = WebSettings.LOAD_NO_CACHE // Enable Javascript settings.javaScriptEnabled = true @@ -77,8 +73,6 @@ fun WebView.clearAfterWidget() { webChromeClient = null webViewClient = null clearHistory() - // NOTE: clears RAM cache, if you pass true, it will also clear the disk cache. - clearCache(true) // Loading a blank page is optional, but will ensure that the WebView isn't doing anything when you destroy it. loadUrl("about:blank") removeAllViews() From b411e8f0093e3de47108d95c1b3227421ae40b1a Mon Sep 17 00:00:00 2001 From: dkanada Date: Tue, 12 Jan 2021 11:42:45 +0900 Subject: [PATCH 0007/1289] update changelog --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 1315d006e0..5e8ae6ab77 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Features ✨: Improvements 🙌: - Add System theme option and set as default (#904, #2387) + - Use WebView cache for widgets to avoid excessive data use (#2648) - Warn user when they are leaving a not public room (#1460) Bugfix 🐛: From bc6eb565a3b14c94f4f93d13ccf3c346b67463ac Mon Sep 17 00:00:00 2001 From: dkanada Date: Tue, 12 Jan 2021 23:19:33 +0900 Subject: [PATCH 0008/1289] remove unused import --- .../java/im/vector/app/features/widgets/webview/WidgetWebView.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/widgets/webview/WidgetWebView.kt b/vector/src/main/java/im/vector/app/features/widgets/webview/WidgetWebView.kt index dc59f2694f..b1908d87de 100644 --- a/vector/src/main/java/im/vector/app/features/widgets/webview/WidgetWebView.kt +++ b/vector/src/main/java/im/vector/app/features/widgets/webview/WidgetWebView.kt @@ -21,7 +21,6 @@ import android.view.ViewGroup import android.webkit.CookieManager import android.webkit.PermissionRequest import android.webkit.WebChromeClient -import android.webkit.WebSettings import android.webkit.WebView import im.vector.app.R import im.vector.app.features.themes.ThemeUtils From e888f2b15a42c2563450cd102740153b0fd67acf Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 29 Jun 2021 11:09:18 +0200 Subject: [PATCH 0009/1289] Call controls: move choose sound device out of overflow menu --- .../features/call/CallControlsBottomSheet.kt | 66 ----------------- .../app/features/call/CallControlsView.kt | 12 +-- .../call/CallSoundDeviceChooserBottomSheet.kt | 74 +++++++++++++++++++ .../app/features/call/VectorCallActivity.kt | 9 ++- .../features/call/audio/CallAudioManager.kt | 13 ++-- .../res/drawable/ic_call_audio_settings.xml | 15 ++++ .../res/drawable/ic_call_speaker_active.xml | 11 --- .../res/drawable/ic_call_speaker_default.xml | 7 -- .../drawable/ic_sound_device_headphone.xml | 9 +++ .../res/drawable/ic_sound_device_phone.xml | 9 +++ .../res/drawable/ic_sound_device_speaker.xml | 15 ++++ .../res/layout/bottom_sheet_call_controls.xml | 10 --- ...bottom_sheet_call_sound_device_chooser.xml | 60 +++++++++++++++ .../res/layout/bottom_sheet_generic_list.xml | 2 +- .../main/res/layout/view_call_controls.xml | 49 ++++++------ 15 files changed, 233 insertions(+), 128 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/call/CallSoundDeviceChooserBottomSheet.kt create mode 100644 vector/src/main/res/drawable/ic_call_audio_settings.xml delete mode 100644 vector/src/main/res/drawable/ic_call_speaker_active.xml delete mode 100644 vector/src/main/res/drawable/ic_call_speaker_default.xml create mode 100644 vector/src/main/res/drawable/ic_sound_device_headphone.xml create mode 100644 vector/src/main/res/drawable/ic_sound_device_phone.xml create mode 100644 vector/src/main/res/drawable/ic_sound_device_speaker.xml create mode 100644 vector/src/main/res/layout/bottom_sheet_call_sound_device_chooser.xml diff --git a/vector/src/main/java/im/vector/app/features/call/CallControlsBottomSheet.kt b/vector/src/main/java/im/vector/app/features/call/CallControlsBottomSheet.kt index f23b26883a..a3e3a5d71d 100644 --- a/vector/src/main/java/im/vector/app/features/call/CallControlsBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/call/CallControlsBottomSheet.kt @@ -45,10 +45,6 @@ class CallControlsBottomSheet : VectorBaseBottomSheetDialogFragment { - showSoundDeviceChooser(it.available, it.current) - } - else -> { - } - } - } - } - - private fun showSoundDeviceChooser(available: Set, current: CallAudioManager.Device) { - val soundDevices = available.map { - when (it) { - CallAudioManager.Device.WIRELESS_HEADSET -> span { - text = getString(R.string.sound_device_wireless_headset) - textStyle = if (current == it) "bold" else "normal" - } - CallAudioManager.Device.PHONE -> span { - text = getString(R.string.sound_device_phone) - textStyle = if (current == it) "bold" else "normal" - } - CallAudioManager.Device.SPEAKER -> span { - text = getString(R.string.sound_device_speaker) - textStyle = if (current == it) "bold" else "normal" - } - CallAudioManager.Device.HEADSET -> span { - text = getString(R.string.sound_device_headset) - textStyle = if (current == it) "bold" else "normal" - } - } - } - MaterialAlertDialogBuilder(requireContext()) - .setItems(soundDevices.toTypedArray()) { d, n -> - d.cancel() - when (soundDevices[n].toString()) { - // TODO Make an adapter and handle multiple Bluetooth headsets. Also do not use translations. - getString(R.string.sound_device_phone) -> { - callViewModel.handle(VectorCallViewActions.ChangeAudioDevice(CallAudioManager.Device.PHONE)) - } - getString(R.string.sound_device_speaker) -> { - callViewModel.handle(VectorCallViewActions.ChangeAudioDevice(CallAudioManager.Device.SPEAKER)) - } - getString(R.string.sound_device_headset) -> { - callViewModel.handle(VectorCallViewActions.ChangeAudioDevice(CallAudioManager.Device.HEADSET)) - } - getString(R.string.sound_device_wireless_headset) -> { - callViewModel.handle(VectorCallViewActions.ChangeAudioDevice(CallAudioManager.Device.WIRELESS_HEADSET)) - } - } - } - .setNegativeButton(R.string.cancel, null) - .show() } private fun renderState(state: VectorCallViewState) { - views.callControlsSoundDevice.title = getString(R.string.call_select_sound_device) - views.callControlsSoundDevice.subTitle = when (state.device) { - CallAudioManager.Device.PHONE -> getString(R.string.sound_device_phone) - CallAudioManager.Device.SPEAKER -> getString(R.string.sound_device_speaker) - CallAudioManager.Device.HEADSET -> getString(R.string.sound_device_headset) - CallAudioManager.Device.WIRELESS_HEADSET -> getString(R.string.sound_device_wireless_headset) - } - views.callControlsSwitchCamera.isVisible = state.isVideoCall && state.canSwitchCamera views.callControlsSwitchCamera.subTitle = getString(if (state.isFrontCamera) R.string.call_camera_front else R.string.call_camera_back) diff --git a/vector/src/main/java/im/vector/app/features/call/CallControlsView.kt b/vector/src/main/java/im/vector/app/features/call/CallControlsView.kt index 1a54551072..2f771b3a8d 100644 --- a/vector/src/main/java/im/vector/app/features/call/CallControlsView.kt +++ b/vector/src/main/java/im/vector/app/features/call/CallControlsView.kt @@ -36,16 +36,19 @@ class CallControlsView @JvmOverloads constructor( init { inflate(context, R.layout.view_call_controls, this) views = ViewCallControlsBinding.bind(this) - + views.audioSettingsIcon.setOnClickListener { didTapAudioSettings() } views.ringingControlAccept.setOnClickListener { acceptIncomingCall() } views.ringingControlDecline.setOnClickListener { declineIncomingCall() } views.endCallIcon.setOnClickListener { endOngoingCall() } views.muteIcon.setOnClickListener { toggleMute() } views.videoToggleIcon.setOnClickListener { toggleVideo() } - views.openChatIcon.setOnClickListener { returnToChat() } views.moreIcon.setOnClickListener { moreControlOption() } } + private fun didTapAudioSettings() { + interactionListener?.didTapAudioSettings() + } + private fun acceptIncomingCall() { interactionListener?.didAcceptIncomingCall() } @@ -66,9 +69,6 @@ class CallControlsView @JvmOverloads constructor( interactionListener?.didTapToggleVideo() } - private fun returnToChat() { - interactionListener?.returnToChat() - } private fun moreControlOption() { interactionListener?.didTapMore() @@ -127,12 +127,12 @@ class CallControlsView @JvmOverloads constructor( } interface InteractionListener { + fun didTapAudioSettings() fun didAcceptIncomingCall() fun didDeclineIncomingCall() fun didEndCall() fun didTapToggleMute() fun didTapToggleVideo() - fun returnToChat() fun didTapMore() } } diff --git a/vector/src/main/java/im/vector/app/features/call/CallSoundDeviceChooserBottomSheet.kt b/vector/src/main/java/im/vector/app/features/call/CallSoundDeviceChooserBottomSheet.kt new file mode 100644 index 0000000000..a011952549 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/call/CallSoundDeviceChooserBottomSheet.kt @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.call + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.airbnb.mvrx.activityViewModel +import im.vector.app.R +import im.vector.app.core.epoxy.bottomsheet.bottomSheetActionItem +import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment +import im.vector.app.databinding.BottomSheetGenericListBinding +import im.vector.app.features.call.audio.CallAudioManager +import im.vector.app.features.home.room.list.actions.RoomListQuickActionsBottomSheet + +class CallSoundDeviceChooserBottomSheet : VectorBaseBottomSheetDialogFragment() { + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetGenericListBinding { + return BottomSheetGenericListBinding.inflate(inflater, container, false) + } + + private val callViewModel: VectorCallViewModel by activityViewModel() + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + callViewModel.observeViewEvents { + when (it) { + is VectorCallViewEvents.ShowSoundDeviceChooser -> { + render(it.available, it.current) + } + else -> { + } + } + } + callViewModel.handle(VectorCallViewActions.SwitchSoundDevice) + } + + private fun render(available: Set, current: CallAudioManager.Device) { + views.bottomSheetRecyclerView.withModels { + available.forEach { device -> + bottomSheetActionItem { + id(device.ordinal) + textRes(device.titleRes) + iconRes(device.drawableRes) + selected(current == device) + listener { + callViewModel.handle(VectorCallViewActions.ChangeAudioDevice(device)) + dismiss() + } + } + } + } + } + + companion object { + fun newInstance(): RoomListQuickActionsBottomSheet { + return RoomListQuickActionsBottomSheet() + } + } +} diff --git a/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt b/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt index 21939bd42b..b933e1e69d 100644 --- a/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt +++ b/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt @@ -26,6 +26,7 @@ import android.os.Bundle import android.os.Parcelable import android.view.View import android.view.WindowManager +import androidx.core.content.ContentProviderCompat.requireContext import androidx.core.content.ContextCompat import androidx.core.content.getSystemService import androidx.core.view.isInvisible @@ -43,6 +44,7 @@ import im.vector.app.core.utils.PERMISSIONS_FOR_VIDEO_IP_CALL import im.vector.app.core.utils.allGranted import im.vector.app.core.utils.checkPermissions import im.vector.app.databinding.ActivityCallBinding +import im.vector.app.features.call.audio.CallAudioManager import im.vector.app.features.call.dialpad.CallDialPadBottomSheet import im.vector.app.features.call.dialpad.DialPadFragment import im.vector.app.features.call.utils.EglUtils @@ -53,6 +55,7 @@ import im.vector.app.features.home.room.detail.RoomDetailActivity import im.vector.app.features.home.room.detail.RoomDetailArgs import io.reactivex.android.schedulers.AndroidSchedulers import kotlinx.parcelize.Parcelize +import me.gujun.android.span.span import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.session.call.CallState import org.matrix.android.sdk.api.session.call.MxPeerConnectionState @@ -404,6 +407,10 @@ class VectorCallActivity : VectorBaseActivity(), CallContro } } + override fun didTapAudioSettings() { + CallSoundDeviceChooserBottomSheet().show(supportFragmentManager, "SoundDeviceChooser") + } + override fun didAcceptIncomingCall() { callViewModel.handle(VectorCallViewActions.AcceptCall) } @@ -424,7 +431,7 @@ class VectorCallActivity : VectorBaseActivity(), CallContro callViewModel.handle(VectorCallViewActions.ToggleVideo) } - override fun returnToChat() { + private fun returnToChat() { val args = RoomDetailArgs(callArgs.signalingRoomId) val intent = RoomDetailActivity.newIntent(this, args).apply { flags = FLAG_ACTIVITY_CLEAR_TOP diff --git a/vector/src/main/java/im/vector/app/features/call/audio/CallAudioManager.kt b/vector/src/main/java/im/vector/app/features/call/audio/CallAudioManager.kt index 36a11b5923..7797cec929 100644 --- a/vector/src/main/java/im/vector/app/features/call/audio/CallAudioManager.kt +++ b/vector/src/main/java/im/vector/app/features/call/audio/CallAudioManager.kt @@ -19,7 +19,10 @@ package im.vector.app.features.call.audio import android.content.Context import android.media.AudioManager import android.os.Build +import androidx.annotation.DrawableRes +import androidx.annotation.StringRes import androidx.core.content.getSystemService +import im.vector.app.R import org.matrix.android.sdk.api.extensions.orFalse import timber.log.Timber import java.util.HashSet @@ -31,11 +34,11 @@ class CallAudioManager(private val context: Context, val configChange: (() -> Un private var audioDeviceDetector: AudioDeviceDetector? = null private var audioDeviceRouter: AudioDeviceRouter? = null - enum class Device { - PHONE, - SPEAKER, - HEADSET, - WIRELESS_HEADSET + enum class Device(@StringRes val titleRes: Int, @DrawableRes val drawableRes: Int) { + PHONE(R.string.sound_device_phone,R.drawable.ic_sound_device_phone), + SPEAKER(R.string.sound_device_speaker,R.drawable.ic_sound_device_speaker), + HEADSET(R.string.sound_device_headset,R.drawable.ic_sound_device_headphone), + WIRELESS_HEADSET(R.string.sound_device_wireless_headset,R.drawable.ic_sound_device_headphone) } enum class Mode { diff --git a/vector/src/main/res/drawable/ic_call_audio_settings.xml b/vector/src/main/res/drawable/ic_call_audio_settings.xml new file mode 100644 index 0000000000..8a47d27d9a --- /dev/null +++ b/vector/src/main/res/drawable/ic_call_audio_settings.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/vector/src/main/res/drawable/ic_call_speaker_active.xml b/vector/src/main/res/drawable/ic_call_speaker_active.xml deleted file mode 100644 index 97035b1915..0000000000 --- a/vector/src/main/res/drawable/ic_call_speaker_active.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - diff --git a/vector/src/main/res/drawable/ic_call_speaker_default.xml b/vector/src/main/res/drawable/ic_call_speaker_default.xml deleted file mode 100644 index 2fc06a5795..0000000000 --- a/vector/src/main/res/drawable/ic_call_speaker_default.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/vector/src/main/res/drawable/ic_sound_device_headphone.xml b/vector/src/main/res/drawable/ic_sound_device_headphone.xml new file mode 100644 index 0000000000..4648465356 --- /dev/null +++ b/vector/src/main/res/drawable/ic_sound_device_headphone.xml @@ -0,0 +1,9 @@ + + + diff --git a/vector/src/main/res/drawable/ic_sound_device_phone.xml b/vector/src/main/res/drawable/ic_sound_device_phone.xml new file mode 100644 index 0000000000..fd825c77f0 --- /dev/null +++ b/vector/src/main/res/drawable/ic_sound_device_phone.xml @@ -0,0 +1,9 @@ + + + diff --git a/vector/src/main/res/drawable/ic_sound_device_speaker.xml b/vector/src/main/res/drawable/ic_sound_device_speaker.xml new file mode 100644 index 0000000000..eb786d3fe1 --- /dev/null +++ b/vector/src/main/res/drawable/ic_sound_device_speaker.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/vector/src/main/res/layout/bottom_sheet_call_controls.xml b/vector/src/main/res/layout/bottom_sheet_call_controls.xml index bb4a91ea72..e751ac412a 100644 --- a/vector/src/main/res/layout/bottom_sheet_call_controls.xml +++ b/vector/src/main/res/layout/bottom_sheet_call_controls.xml @@ -7,16 +7,6 @@ android:background="?colorSurface" android:orientation="vertical"> - - + + + + + + + + + + + + + diff --git a/vector/src/main/res/layout/bottom_sheet_generic_list.xml b/vector/src/main/res/layout/bottom_sheet_generic_list.xml index 87a2cb54fc..144e291bb9 100644 --- a/vector/src/main/res/layout/bottom_sheet_generic_list.xml +++ b/vector/src/main/res/layout/bottom_sheet_generic_list.xml @@ -1,5 +1,5 @@ - + + + - - + /> From 7c033b4090228b624eb7dbea357949b807d7f1ac Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 30 Jun 2021 18:08:44 +0200 Subject: [PATCH 0010/1289] Call UI: add toolbar --- .../app/features/call/VectorCallActivity.kt | 50 +++++++++-------- .../res/drawable/ic_call_back_to_chat.xml | 10 ++++ vector/src/main/res/layout/activity_call.xml | 56 +++++++++---------- .../main/res/layout/view_call_controls.xml | 18 +++--- vector/src/main/res/menu/vector_call.xml | 11 ++++ vector/src/main/res/values/strings.xml | 2 + 6 files changed, 83 insertions(+), 64 deletions(-) create mode 100644 vector/src/main/res/drawable/ic_call_back_to_chat.xml create mode 100644 vector/src/main/res/menu/vector_call.xml diff --git a/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt b/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt index b933e1e69d..602a68ea74 100644 --- a/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt +++ b/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt @@ -24,9 +24,9 @@ import android.graphics.Color import android.os.Build import android.os.Bundle import android.os.Parcelable +import android.view.MenuItem import android.view.View import android.view.WindowManager -import androidx.core.content.ContentProviderCompat.requireContext import androidx.core.content.ContextCompat import androidx.core.content.getSystemService import androidx.core.view.isInvisible @@ -38,13 +38,13 @@ import com.airbnb.mvrx.withState import com.google.android.material.dialog.MaterialAlertDialogBuilder import im.vector.app.R import im.vector.app.core.di.ScreenComponent +import im.vector.app.core.extensions.setTextOrHide import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.utils.PERMISSIONS_FOR_AUDIO_IP_CALL import im.vector.app.core.utils.PERMISSIONS_FOR_VIDEO_IP_CALL import im.vector.app.core.utils.allGranted import im.vector.app.core.utils.checkPermissions import im.vector.app.databinding.ActivityCallBinding -import im.vector.app.features.call.audio.CallAudioManager import im.vector.app.features.call.dialpad.CallDialPadBottomSheet import im.vector.app.features.call.dialpad.DialPadFragment import im.vector.app.features.call.utils.EglUtils @@ -55,7 +55,6 @@ import im.vector.app.features.home.room.detail.RoomDetailActivity import im.vector.app.features.home.room.detail.RoomDetailArgs import io.reactivex.android.schedulers.AndroidSchedulers import kotlinx.parcelize.Parcelize -import me.gujun.android.span.span import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.session.call.CallState import org.matrix.android.sdk.api.session.call.MxPeerConnectionState @@ -127,6 +126,7 @@ class VectorCallActivity : VectorBaseActivity(), CallContro if (savedInstanceState != null) { (supportFragmentManager.findFragmentByTag(FRAGMENT_DIAL_PAD_TAG) as? CallDialPadBottomSheet)?.callback = dialPadCallback } + setSupportActionBar(views.callToolbar) configureCallViews() callViewModel.subscribe(this) { @@ -152,6 +152,16 @@ class VectorCallActivity : VectorBaseActivity(), CallContro } } + override fun getMenuRes() = R.menu.vector_call + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + if (item.itemId == R.id.menu_call_open_chat) { + returnToChat() + return true + } + return super.onOptionsItemSelected(item) + } + override fun onDestroy() { callManager.getCallById(callArgs.callId)?.detachRenderers(listOf(views.pipRenderer, views.fullscreenRenderer)) if (surfaceRenderersAreInitialized) { @@ -171,35 +181,27 @@ class VectorCallActivity : VectorBaseActivity(), CallContro views.callControlsView.updateForState(state) val callState = state.callState.invoke() - views.callConnectingProgress.isVisible = false views.callActionText.setOnClickListener(null) views.callActionText.isVisible = false views.smallIsHeldIcon.isVisible = false when (callState) { is CallState.Idle, is CallState.CreateOffer, + is CallState.LocalRinging, is CallState.Dialing -> { views.callVideoGroup.isInvisible = true views.callInfoGroup.isVisible = true - views.callStatusText.setText(R.string.call_ring) + views.callToolbar.setSubtitle(R.string.call_ring) configureCallInfo(state) } - - is CallState.LocalRinging -> { - views.callVideoGroup.isInvisible = true - views.callInfoGroup.isVisible = true - views.callStatusText.text = null - configureCallInfo(state) - } - is CallState.Answering -> { views.callVideoGroup.isInvisible = true views.callInfoGroup.isVisible = true - views.callStatusText.setText(R.string.call_connecting) - views.callConnectingProgress.isVisible = true + views.callToolbar.setSubtitle(R.string.call_connecting) configureCallInfo(state) } is CallState.Connected -> { + views.callToolbar.subtitle = state.formattedDuration if (callState.iceConnectionState == MxPeerConnectionState.CONNECTED) { if (state.isLocalOnHold || state.isRemoteOnHold) { views.smallIsHeldIcon.isVisible = true @@ -210,11 +212,11 @@ class VectorCallActivity : VectorBaseActivity(), CallContro views.callActionText.setText(R.string.call_resume_action) views.callActionText.isVisible = true views.callActionText.setOnClickListener { callViewModel.handle(VectorCallViewActions.ToggleHoldResume) } - views.callStatusText.setText(R.string.call_held_by_you) + views.callToolbar.setSubtitle(R.string.call_held_by_you) } else { views.callActionText.isInvisible = true state.callInfo?.opponentUserItem?.let { - views.callStatusText.text = getString(R.string.call_held_by_user, it.getBestName()) + views.callToolbar.subtitle = getString(R.string.call_held_by_user, it.getBestName()) } } } else if (state.transferee !is VectorCallViewState.TransfereeState.NoTransferee) { @@ -226,10 +228,8 @@ class VectorCallActivity : VectorBaseActivity(), CallContro views.callActionText.text = getString(R.string.call_transfer_transfer_to_title, transfereeName) views.callActionText.isVisible = true views.callActionText.setOnClickListener { callViewModel.handle(VectorCallViewActions.TransferCall) } - views.callStatusText.text = state.formattedDuration configureCallInfo(state) } else { - views.callStatusText.text = state.formattedDuration configureCallInfo(state) if (callArgs.isVideoCall) { views.callVideoGroup.isVisible = true @@ -245,8 +245,7 @@ class VectorCallActivity : VectorBaseActivity(), CallContro views.callVideoGroup.isInvisible = true views.callInfoGroup.isVisible = true configureCallInfo(state) - views.callStatusText.setText(R.string.call_connecting) - views.callConnectingProgress.isVisible = true + views.callToolbar.setSubtitle(R.string.call_connecting) } } is CallState.Terminated -> { @@ -262,9 +261,14 @@ class VectorCallActivity : VectorBaseActivity(), CallContro val colorFilter = ContextCompat.getColor(this, R.color.bg_call_screen_blur) avatarRenderer.renderBlur(it, views.bgCallView, sampling = 20, rounded = false, colorFilter = colorFilter, addPlaceholder = false) if (state.transferee is VectorCallViewState.TransfereeState.NoTransferee) { - views.participantNameText.text = it.getBestName() + views.participantNameText.setTextOrHide(null) + views.callToolbar.title = if (state.isVideoCall) { + getString(R.string.video_call_with_participant, it.getBestName()) + } else { + getString(R.string.audio_call_with_participant, it.getBestName()) + } } else { - views.participantNameText.text = getString(R.string.call_transfer_consulting_with, it.getBestName()) + views.participantNameText.setTextOrHide(getString(R.string.call_transfer_consulting_with, it.getBestName())) } if (blurAvatar) { avatarRenderer.renderBlur(it, views.otherMemberAvatar, sampling = 2, rounded = true, colorFilter = colorFilter, addPlaceholder = true) diff --git a/vector/src/main/res/drawable/ic_call_back_to_chat.xml b/vector/src/main/res/drawable/ic_call_back_to_chat.xml new file mode 100644 index 0000000000..b1c532f17d --- /dev/null +++ b/vector/src/main/res/drawable/ic_call_back_to_chat.xml @@ -0,0 +1,10 @@ + + + diff --git a/vector/src/main/res/layout/activity_call.xml b/vector/src/main/res/layout/activity_call.xml index 0df28cf16a..94794799c4 100644 --- a/vector/src/main/res/layout/activity_call.xml +++ b/vector/src/main/res/layout/activity_call.xml @@ -22,9 +22,11 @@ + + - -