From 33337bd77292c7dec2cf4365bf14a7b51f9dc3fe Mon Sep 17 00:00:00 2001 From: Toby Murray Date: Fri, 30 Apr 2021 00:47:57 -0400 Subject: [PATCH 1/5] Allow cleartext to some LAN domains This functionality exists in the desktop client, so hoping to mirror that as much as Android allows This addresses a number of the use cases touched on in #1793. Enabling clear text to various official and standard LAN-only domains means it's easier to develop the Android application, as a Matrix server can be deployed locally without much fuss anywhere on the developer's LAN. This can reduce the reliance on a DNS or SSL certificates when neither are really relevant to the functionality of the client/server. In particular, managing SSL certs without a public domain is a pain in the butt. At the same time, this does not significantly diminish the security of Element Android, as at the current time these domains are either explicitly not valid TLDs or conventionally not TLDs (so would be an unexpected change if they were to become so). In the event e.g. `.home` becomes a TLD, it would be appropriate to remove it from this list. --- CHANGES.md | 1 + vector/src/main/res/xml/network_security_config.xml | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 74b008bfc4f..112c0c0d612 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -38,6 +38,7 @@ git branch -u origin/main main # And optionally git remote prune origin ``` + - Allow cleartext (non-SSL) connections to Matrix servers on LAN hosts (#3166) Changes in Element 1.1.6 (2021-04-16) =================================================== diff --git a/vector/src/main/res/xml/network_security_config.xml b/vector/src/main/res/xml/network_security_config.xml index 4bf79f16ba3..b9f3d039863 100644 --- a/vector/src/main/res/xml/network_security_config.xml +++ b/vector/src/main/res/xml/network_security_config.xml @@ -13,6 +13,16 @@ 10.0.2.2 onion + + + + home.arpa + local + test + + home + lan + localdomain From 61800765128972ad61e7ebacc0687b7beeb33274 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 30 Apr 2021 10:48:48 +0200 Subject: [PATCH 2/5] Delete and react to stickers (#3250) --- CHANGES.md | 1 + .../vector/app/core/extensions/TimelineEvent.kt | 6 ++++-- .../timeline/action/MessageActionsViewModel.kt | 15 +++++++-------- .../helper/MessageInformationDataFactory.kt | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 74b008bfc4f..fc73cf5f485 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Features ✨: Improvements 🙌: - Add ability to install APK from directly from Element (#2381) + - Delete and react to stickers (#3250) Bugfix 🐛: - Message states cosmetic changes (#3007) diff --git a/vector/src/main/java/im/vector/app/core/extensions/TimelineEvent.kt b/vector/src/main/java/im/vector/app/core/extensions/TimelineEvent.kt index 63e35c1c0f5..48e3a488edd 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/TimelineEvent.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/TimelineEvent.kt @@ -21,6 +21,8 @@ import org.matrix.android.sdk.api.session.room.send.SendState import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent fun TimelineEvent.canReact(): Boolean { - // Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment - return root.getClearType() == EventType.MESSAGE && root.sendState == SendState.SYNCED && !root.isRedacted() + // Only event of type EventType.MESSAGE or EventType.STICKER are supported for the moment + return root.getClearType() in listOf(EventType.MESSAGE, EventType.STICKER) + && root.sendState == SendState.SYNCED + && !root.isRedacted() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt index a3f647871b1..98df69d3fbc 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt @@ -394,7 +394,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted } private fun canReply(event: TimelineEvent, messageContent: MessageContent?, actionPermissions: ActionPermissions): Boolean { - // Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment + // Only event of type EventType.MESSAGE are supported for the moment if (event.root.getClearType() != EventType.MESSAGE) return false if (!actionPermissions.canSendMessage) return false return when (messageContent?.msgType) { @@ -410,7 +410,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted } private fun canQuote(event: TimelineEvent, messageContent: MessageContent?, actionPermissions: ActionPermissions): Boolean { - // Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment + // Only event of type EventType.MESSAGE are supported for the moment if (event.root.getClearType() != EventType.MESSAGE) return false if (!actionPermissions.canSendMessage) return false return when (messageContent?.msgType) { @@ -425,8 +425,8 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted } private fun canRedact(event: TimelineEvent, actionPermissions: ActionPermissions): Boolean { - // Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment - if (event.root.getClearType() != EventType.MESSAGE) return false + // Only event of type EventType.MESSAGE are supported for the moment + if (event.root.getClearType() !in listOf(EventType.MESSAGE, EventType.STICKER)) return false // Message sent by the current user can always be redacted if (event.root.senderId == session.myUserId) return true // Check permission for messages sent by other users @@ -440,14 +440,13 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted } private fun canViewReactions(event: TimelineEvent): Boolean { - // Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment - if (event.root.getClearType() != EventType.MESSAGE) return false - // TODO if user is admin or moderator + // Only event of type EventType.MESSAGE and EventType.STICKER are supported for the moment + if (event.root.getClearType() !in listOf(EventType.MESSAGE, EventType.STICKER)) return false return event.annotations?.reactionsSummary?.isNotEmpty() ?: false } private fun canEdit(event: TimelineEvent, myUserId: String, actionPermissions: ActionPermissions): Boolean { - // Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment + // Only event of type EventType.MESSAGE are supported for the moment if (event.root.getClearType() != EventType.MESSAGE) return false if (!actionPermissions.canSendMessage) return false // TODO if user is admin or moderator diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt index 14dd3112656..b1e438dff18 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt @@ -66,7 +66,7 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses addDaySeparator || event.senderInfo.avatarUrl != nextEvent?.senderInfo?.avatarUrl || event.senderInfo.disambiguatedDisplayName != nextEvent?.senderInfo?.disambiguatedDisplayName - || (nextEvent.root.getClearType() != EventType.MESSAGE && nextEvent.root.getClearType() != EventType.ENCRYPTED) + || nextEvent.root.getClearType() !in listOf(EventType.MESSAGE, EventType.STICKER, EventType.ENCRYPTED) || isNextMessageReceivedMoreThanOneHourAgo || isTileTypeMessage(nextEvent) From 589be8b15f1a379dffcde9a7f92c69d14cbb948e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 30 Apr 2021 11:56:45 +0200 Subject: [PATCH 3/5] Update vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt --- .../home/room/detail/timeline/action/MessageActionsViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt index 98df69d3fbc..b9c368ebdc6 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt @@ -425,7 +425,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted } private fun canRedact(event: TimelineEvent, actionPermissions: ActionPermissions): Boolean { - // Only event of type EventType.MESSAGE are supported for the moment + // Only event of type EventType.MESSAGE or EventType.STICKER are supported for the moment if (event.root.getClearType() !in listOf(EventType.MESSAGE, EventType.STICKER)) return false // Message sent by the current user can always be redacted if (event.root.senderId == session.myUserId) return true From 47aa787ecb91aab8e0729b44bee650360bb6262b Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Sat, 1 May 2021 09:29:31 +0200 Subject: [PATCH 4/5] Fix missing sender information after edits Fixes https://github.com/vector-im/element-android/issues/3184 --- CHANGES.md | 1 + .../android/sdk/api/session/room/timeline/TimelineEvent.kt | 5 +++++ .../detail/timeline/helper/MessageInformationDataFactory.kt | 2 ++ 3 files changed, 8 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 1c0b7284b0f..c40c66a0b25 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,6 +16,7 @@ Bugfix 🐛: - Fix issues on Android 11 (#3067) - Fix issue when opening encrypted files (#3186) - Fix wording issue (#3242) + - Fix missing sender information after edits (#3184) Translations 🗣: - diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt index 32f6b94cd8d..4a6462477dc 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt @@ -21,6 +21,7 @@ import org.matrix.android.sdk.api.session.events.model.Event import org.matrix.android.sdk.api.session.events.model.EventType import org.matrix.android.sdk.api.session.events.model.RelationType import org.matrix.android.sdk.api.session.events.model.getRelationContent +import org.matrix.android.sdk.api.session.events.model.isEdition import org.matrix.android.sdk.api.session.events.model.isReply import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.room.model.EventAnnotationsSummary @@ -151,6 +152,10 @@ fun TimelineEvent.isReply(): Boolean { return root.isReply() } +fun TimelineEvent.isEdition(): Boolean { + return root.isEdition() +} + fun TimelineEvent.getTextEditableContent(): String? { val lastContent = getLastMessageContent() return if (isReply()) { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt index b1e438dff18..124b196f72d 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt @@ -39,6 +39,7 @@ import org.matrix.android.sdk.api.session.room.send.SendState import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent import org.matrix.android.sdk.api.session.room.timeline.hasBeenEdited +import org.matrix.android.sdk.api.session.room.timeline.isEdition import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent import javax.inject.Inject @@ -69,6 +70,7 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses || nextEvent.root.getClearType() !in listOf(EventType.MESSAGE, EventType.STICKER, EventType.ENCRYPTED) || isNextMessageReceivedMoreThanOneHourAgo || isTileTypeMessage(nextEvent) + || nextEvent.isEdition() val time = dateFormatter.format(event.root.originServerTs, DateFormatKind.MESSAGE_SIMPLE) val e2eDecoration = getE2EDecoration(event) From e3204c32a1360ec1678de4359a43e748a235c69d Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Sat, 1 May 2021 11:35:39 +0200 Subject: [PATCH 5/5] Fix updating read marker automatically Co-authored-by: Benoit Marty --- CHANGES.md | 1 + .../vector/app/features/home/room/detail/RoomDetailViewModel.kt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index c40c66a0b25..027b9e84166 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,7 @@ Bugfix 🐛: - Fix issue when opening encrypted files (#3186) - Fix wording issue (#3242) - Fix missing sender information after edits (#3184) + - Fix read marker not updating automatically (#3267) Translations 🗣: - 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 d64acb9afb9..1dd13bf4810 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 @@ -550,7 +550,7 @@ class RoomDetailViewModel @AssistedInject constructor( private fun stopTrackingUnreadMessages() { if (trackUnreadMessages.getAndSet(false)) { mostRecentDisplayedEvent?.root?.eventId?.also { - viewModelScope.launch { + session.coroutineScope.launch { tryOrNull { room.setReadMarker(it) } } }