From 54eca7525eefc537a2bf4fefbb34e6fd0288cf93 Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 11 Mar 2020 16:24:49 +0100 Subject: [PATCH 01/14] Version ++ --- CHANGES.md | 24 ++++++++++++++++++++++++ vector/build.gradle | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 42f8d875cb..918cfd61de 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,27 @@ +Changes in RiotX 0.19.0 (2020-XX-XX) +=================================================== + +Features ✨: + - + +Improvements 🙌: + - + +Bugfix 🐛: + - + +Translations 🗣: + - + +SDK API changes ⚠️: + - + +Build 🧱: + - + +Other changes: + - + Changes in RiotX 0.18.0 (2020-03-11) =================================================== diff --git a/vector/build.gradle b/vector/build.gradle index 6d24a26838..2aae593271 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -15,7 +15,7 @@ androidExtensions { } ext.versionMajor = 0 -ext.versionMinor = 18 +ext.versionMinor = 19 ext.versionPatch = 0 static def getGitTimestamp() { From f53fc205e102accf0d269615f7dac913ae8a8a0b Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 11 Mar 2020 18:07:18 +0100 Subject: [PATCH 02/14] Fix Message transitions in encrypted rooms Fixes #518 --- .../internal/session/sync/RoomSyncHandler.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomSyncHandler.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomSyncHandler.kt index 5b7c39a3d9..c993dc1ea8 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomSyncHandler.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomSyncHandler.kt @@ -25,6 +25,7 @@ import im.vector.matrix.android.api.session.room.model.RoomMemberContent import im.vector.matrix.android.api.session.room.model.tag.RoomTagContent import im.vector.matrix.android.api.session.room.send.SendState import im.vector.matrix.android.internal.crypto.DefaultCryptoService +import im.vector.matrix.android.internal.crypto.algorithms.olm.OlmDecryptionResult import im.vector.matrix.android.internal.database.helper.addOrUpdate import im.vector.matrix.android.internal.database.helper.addTimelineEvent import im.vector.matrix.android.internal.database.mapper.ContentMapper @@ -260,6 +261,22 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle if (sendingEventEntity != null) { Timber.v("Remove local echo for tx:$it") roomEntity.sendingTimelineEvents.remove(sendingEventEntity) + if (event.isEncrypted()) { + // Maybe just a temp work around? + // Decrypt the remote echo right now, to avoid seeing it decrypt again + try { + val result = cryptoService.decryptEvent(event.copy(roomId = roomId), event.roomId ?: "") + event.mxDecryptionResult = OlmDecryptionResult( + payload = result.clearEvent, + senderKey = result.senderCurve25519Key, + keysClaimed = result.claimedEd25519Key?.let { mapOf("ed25519" to it) }, + forwardingCurve25519KeyChain = result.forwardingCurve25519KeyChain + ) + eventEntity.setDecryptionResult(result) + } catch (failure: Throwable) { + Timber.v("Failed to decrypt remote echo: ${failure.localizedMessage}") + } + } } else { Timber.v("Can't find corresponding local echo for tx:$it") } From 32fd4c1be96d6504781e74324c4cdedd7cd93e7b Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 11 Mar 2020 19:39:16 +0100 Subject: [PATCH 03/14] save decryption result at encryption --- .../session/room/send/EncryptEventWorker.kt | 19 ++++++++++++++++ .../session/room/send/LocalEchoUpdater.kt | 15 +++++++++++++ .../internal/session/sync/RoomSyncHandler.kt | 22 +++++++------------ 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/EncryptEventWorker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/EncryptEventWorker.kt index 72f5ee56b8..bac4b29d87 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/EncryptEventWorker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/EncryptEventWorker.kt @@ -23,7 +23,10 @@ import com.squareup.moshi.JsonClass import im.vector.matrix.android.api.failure.Failure import im.vector.matrix.android.api.session.crypto.CryptoService import im.vector.matrix.android.api.session.events.model.Event +import im.vector.matrix.android.api.session.events.model.toContent import im.vector.matrix.android.api.session.room.send.SendState +import im.vector.matrix.android.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM +import im.vector.matrix.android.internal.crypto.MXEventDecryptionResult import im.vector.matrix.android.internal.crypto.model.MXEncryptEventContentResult import im.vector.matrix.android.internal.util.awaitCallback import im.vector.matrix.android.internal.worker.SessionWorkerParams @@ -96,6 +99,22 @@ internal class EncryptEventWorker(context: Context, params: WorkerParameters) type = safeResult.eventType, content = safeResult.eventContent ) + // Better handling of local echo, to avoid decrypting transition on remote echo + // Should I only do it for text messages? + if (result.eventContent["algorithm"] == MXCRYPTO_ALGORITHM_MEGOLM) { + val decryptionLocalEcho = MXEventDecryptionResult( + clearEvent = Event( + type = localEvent.type, + content = localEvent.content, + roomId = localEvent.roomId + ).toContent(), + forwardingCurve25519KeyChain = emptyList(), + senderCurve25519Key = result.eventContent["sender_key"] as? String, + claimedEd25519Key = crypto.getMyDevice().fingerprint() + ) + localEchoUpdater.updateEncryptedEcho(localEvent.eventId, result.eventContent, decryptionLocalEcho) + } + val nextWorkerParams = SendEventWorker.Params(params.sessionId, encryptedEvent) return Result.success(WorkerParamsFactory.toData(nextWorkerParams)) } else { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoUpdater.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoUpdater.kt index 60d1a217a7..09d82c7b07 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoUpdater.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoUpdater.kt @@ -17,7 +17,11 @@ package im.vector.matrix.android.internal.session.room.send import com.zhuinden.monarchy.Monarchy +import im.vector.matrix.android.api.session.events.model.Content +import im.vector.matrix.android.api.session.events.model.EventType import im.vector.matrix.android.api.session.room.send.SendState +import im.vector.matrix.android.internal.crypto.MXEventDecryptionResult +import im.vector.matrix.android.internal.database.mapper.ContentMapper import im.vector.matrix.android.internal.database.model.EventEntity import im.vector.matrix.android.internal.database.query.where import timber.log.Timber @@ -38,4 +42,15 @@ internal class LocalEchoUpdater @Inject constructor(private val monarchy: Monarc } } } + + fun updateEncryptedEcho(eventId: String, encryptedContent: Content, mxEventDecryptionResult: MXEventDecryptionResult) { + monarchy.writeAsync { realm -> + val sendingEventEntity = EventEntity.where(realm, eventId).findFirst() + if (sendingEventEntity != null) { + sendingEventEntity.type = EventType.ENCRYPTED + sendingEventEntity.content = ContentMapper.map(encryptedContent) + sendingEventEntity.setDecryptionResult(mxEventDecryptionResult) + } + } + } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomSyncHandler.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomSyncHandler.kt index c993dc1ea8..70c1e39334 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomSyncHandler.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomSyncHandler.kt @@ -25,6 +25,7 @@ import im.vector.matrix.android.api.session.room.model.RoomMemberContent import im.vector.matrix.android.api.session.room.model.tag.RoomTagContent import im.vector.matrix.android.api.session.room.send.SendState import im.vector.matrix.android.internal.crypto.DefaultCryptoService +import im.vector.matrix.android.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM import im.vector.matrix.android.internal.crypto.algorithms.olm.OlmDecryptionResult import im.vector.matrix.android.internal.database.helper.addOrUpdate import im.vector.matrix.android.internal.database.helper.addTimelineEvent @@ -39,6 +40,7 @@ import im.vector.matrix.android.internal.database.query.findLastLiveChunkFromRoo import im.vector.matrix.android.internal.database.query.getOrCreate import im.vector.matrix.android.internal.database.query.getOrNull import im.vector.matrix.android.internal.database.query.where +import im.vector.matrix.android.internal.di.MoshiProvider import im.vector.matrix.android.internal.session.DefaultInitialSyncProgressService import im.vector.matrix.android.internal.session.mapWithProgress import im.vector.matrix.android.internal.session.room.RoomSummaryUpdater @@ -261,20 +263,12 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle if (sendingEventEntity != null) { Timber.v("Remove local echo for tx:$it") roomEntity.sendingTimelineEvents.remove(sendingEventEntity) - if (event.isEncrypted()) { - // Maybe just a temp work around? - // Decrypt the remote echo right now, to avoid seeing it decrypt again - try { - val result = cryptoService.decryptEvent(event.copy(roomId = roomId), event.roomId ?: "") - event.mxDecryptionResult = OlmDecryptionResult( - payload = result.clearEvent, - senderKey = result.senderCurve25519Key, - keysClaimed = result.claimedEd25519Key?.let { mapOf("ed25519" to it) }, - forwardingCurve25519KeyChain = result.forwardingCurve25519KeyChain - ) - eventEntity.setDecryptionResult(result) - } catch (failure: Throwable) { - Timber.v("Failed to decrypt remote echo: ${failure.localizedMessage}") + if (event.isEncrypted() && event.content?.get("algorithm") as? String == MXCRYPTO_ALGORITHM_MEGOLM) { + // updated with echo decryption, to avoid seeing it decrypt again + val adapter = MoshiProvider.providesMoshi().adapter(OlmDecryptionResult::class.java) + sendingEventEntity.root?.decryptionResultJson?.let { json -> + eventEntity.decryptionResultJson = json + event.mxDecryptionResult = adapter.fromJson(json) } } } else { From 7c1428e097eaeeca5b8b190c404a1bed624966a5 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 12 Mar 2020 10:05:55 +0100 Subject: [PATCH 04/14] preserver relations as non encrypted --- .../android/internal/session/room/send/EncryptEventWorker.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/EncryptEventWorker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/EncryptEventWorker.kt index bac4b29d87..e4424f1cb3 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/EncryptEventWorker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/EncryptEventWorker.kt @@ -112,7 +112,7 @@ internal class EncryptEventWorker(context: Context, params: WorkerParameters) senderCurve25519Key = result.eventContent["sender_key"] as? String, claimedEd25519Key = crypto.getMyDevice().fingerprint() ) - localEchoUpdater.updateEncryptedEcho(localEvent.eventId, result.eventContent, decryptionLocalEcho) + localEchoUpdater.updateEncryptedEcho(localEvent.eventId, safeResult.eventContent, decryptionLocalEcho) } val nextWorkerParams = SendEventWorker.Params(params.sessionId, encryptedEvent) From 5cb7e455b1eb4a4da1724812d423e1d798a2feb5 Mon Sep 17 00:00:00 2001 From: onurays Date: Fri, 13 Mar 2020 14:00:46 +0300 Subject: [PATCH 05/14] Implementation of /join command. --- CHANGES.md | 2 +- .../home/room/detail/RoomDetailFragment.kt | 7 +++++++ .../home/room/detail/RoomDetailViewEvents.kt | 1 + .../home/room/detail/RoomDetailViewModel.kt | 20 +++++++++++++++++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 918cfd61de..04825e2ac7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,7 +5,7 @@ Features ✨: - Improvements 🙌: - - + - /join command implemented Bugfix 🐛: - diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt index ad4e9694db..9916fa522b 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt @@ -297,11 +297,18 @@ class RoomDetailFragment @Inject constructor( is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it) is RoomDetailViewEvents.FileTooBigError -> displayFileTooBigError(it) is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it) + is RoomDetailViewEvents.JoinedToAnotherRoom -> handleJoinedToAnotherRoom(it) is RoomDetailViewEvents.SendMessageResult -> renderSendMessageResult(it) }.exhaustive } } + private fun handleJoinedToAnotherRoom(action: RoomDetailViewEvents.JoinedToAnotherRoom) { + updateComposerText("") + lockSendButton = false + navigator.openRoom(vectorBaseActivity, action.roomId) + } + override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) if (savedInstanceState == null) { diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewEvents.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewEvents.kt index fcbe7f37c0..df0ead3b38 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewEvents.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewEvents.kt @@ -50,6 +50,7 @@ sealed class RoomDetailViewEvents : VectorViewEvents { abstract class SendMessageResult : RoomDetailViewEvents() object MessageSent : SendMessageResult() + data class JoinedToAnotherRoom(val roomId: String) : SendMessageResult() class SlashCommandError(val command: Command) : SendMessageResult() class SlashCommandUnknown(val command: String) : SendMessageResult() data class SlashCommandHandled(@StringRes val messageRes: Int? = null) : SendMessageResult() diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt index 4ab9125c4f..aa04b80202 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt @@ -379,8 +379,8 @@ class RoomDetailViewModel @AssistedInject constructor( _viewEvents.post(RoomDetailViewEvents.SlashCommandNotImplemented) } is ParsedCommand.JoinRoom -> { - // TODO - _viewEvents.post(RoomDetailViewEvents.SlashCommandNotImplemented) + handleJoinToAnotherRoomSlashCommand(slashCommandResult) + popDraft() } is ParsedCommand.PartRoom -> { // TODO @@ -512,6 +512,22 @@ class RoomDetailViewModel @AssistedInject constructor( room.deleteDraft(NoOpMatrixCallback()) } + private fun handleJoinToAnotherRoomSlashCommand(command: ParsedCommand.JoinRoom) { + session.joinRoom(command.roomAlias, command.reason, object : MatrixCallback { + override fun onSuccess(data: Unit) { + session.getRoomSummary(command.roomAlias) + ?.roomId + ?.let { + _viewEvents.post(RoomDetailViewEvents.JoinedToAnotherRoom(it)) + } + } + + override fun onFailure(failure: Throwable) { + _viewEvents.post(RoomDetailViewEvents.SlashCommandResultError(failure)) + } + }) + } + private fun legacyRiotQuoteText(quotedText: String?, myText: String): String { val messageParagraphs = quotedText?.split("\n\n".toRegex())?.dropLastWhile { it.isEmpty() }?.toTypedArray() return buildString { From 85a987ca8d6a9b2fdedffcb14ca579a2eef31c7a Mon Sep 17 00:00:00 2001 From: onurays Date: Fri, 13 Mar 2020 14:02:42 +0300 Subject: [PATCH 06/14] Fix typo. --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 04825e2ac7..bc25198b36 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,7 +5,7 @@ Features ✨: - Improvements 🙌: - - /join command implemented + - Implementation of /join command Bugfix 🐛: - From e3246a1f2c7ccdd7607d4c5d0fa0fdf261d8f2b4 Mon Sep 17 00:00:00 2001 From: onurays Date: Fri, 13 Mar 2020 18:41:04 +0300 Subject: [PATCH 07/14] Rename JoinedToAnotherRoom to JoinRoomCommandSucces. --- .../home/room/detail/RoomDetailFragment.kt | 16 ++++++++-------- .../home/room/detail/RoomDetailViewEvents.kt | 2 +- .../home/room/detail/RoomDetailViewModel.kt | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt index 9916fa522b..e67c27bd49 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt @@ -292,18 +292,18 @@ class RoomDetailFragment @Inject constructor( is RoomDetailViewEvents.Failure -> showErrorInSnackbar(it.throwable) is RoomDetailViewEvents.OnNewTimelineEvents -> scrollOnNewMessageCallback.addNewTimelineEventIds(it.eventIds) is RoomDetailViewEvents.ActionSuccess -> displayRoomDetailActionSuccess(it) - is RoomDetailViewEvents.ActionFailure -> displayRoomDetailActionFailure(it) - is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message, Snackbar.LENGTH_LONG) - is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it) - is RoomDetailViewEvents.FileTooBigError -> displayFileTooBigError(it) - is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it) - is RoomDetailViewEvents.JoinedToAnotherRoom -> handleJoinedToAnotherRoom(it) - is RoomDetailViewEvents.SendMessageResult -> renderSendMessageResult(it) + is RoomDetailViewEvents.ActionFailure -> displayRoomDetailActionFailure(it) + is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message, Snackbar.LENGTH_LONG) + is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it) + is RoomDetailViewEvents.FileTooBigError -> displayFileTooBigError(it) + is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it) + is RoomDetailViewEvents.JoinRoomCommandSucces -> handleJoinedToAnotherRoom(it) + is RoomDetailViewEvents.SendMessageResult -> renderSendMessageResult(it) }.exhaustive } } - private fun handleJoinedToAnotherRoom(action: RoomDetailViewEvents.JoinedToAnotherRoom) { + private fun handleJoinedToAnotherRoom(action: RoomDetailViewEvents.JoinRoomCommandSucces) { updateComposerText("") lockSendButton = false navigator.openRoom(vectorBaseActivity, action.roomId) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewEvents.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewEvents.kt index df0ead3b38..20657a1e42 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewEvents.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewEvents.kt @@ -50,7 +50,7 @@ sealed class RoomDetailViewEvents : VectorViewEvents { abstract class SendMessageResult : RoomDetailViewEvents() object MessageSent : SendMessageResult() - data class JoinedToAnotherRoom(val roomId: String) : SendMessageResult() + data class JoinRoomCommandSucces(val roomId: String) : SendMessageResult() class SlashCommandError(val command: Command) : SendMessageResult() class SlashCommandUnknown(val command: String) : SendMessageResult() data class SlashCommandHandled(@StringRes val messageRes: Int? = null) : SendMessageResult() diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt index aa04b80202..4991a9ca01 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt @@ -518,7 +518,7 @@ class RoomDetailViewModel @AssistedInject constructor( session.getRoomSummary(command.roomAlias) ?.roomId ?.let { - _viewEvents.post(RoomDetailViewEvents.JoinedToAnotherRoom(it)) + _viewEvents.post(RoomDetailViewEvents.JoinRoomCommandSucces(it)) } } From 3c9c2e61d7b750f2bd0e880b8db9f42bc63f699b Mon Sep 17 00:00:00 2001 From: Valere Date: Fri, 13 Mar 2020 17:19:00 +0100 Subject: [PATCH 08/14] missing change log entry --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 918cfd61de..71a2bd4616 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,7 @@ Improvements 🙌: - Bugfix 🐛: - - + - Message transitions in encrypted rooms are jarring #518 Translations 🗣: - From eb74523905e9bf6bb045abf0c152963640d09506 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 16 Mar 2020 15:30:41 +0100 Subject: [PATCH 09/14] Fix / typo --- .../home/room/detail/RoomDetailFragment.kt | 16 ++++++++-------- .../home/room/detail/RoomDetailViewEvents.kt | 2 +- .../home/room/detail/RoomDetailViewModel.kt | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt index e67c27bd49..f83adaf8a7 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt @@ -292,18 +292,18 @@ class RoomDetailFragment @Inject constructor( is RoomDetailViewEvents.Failure -> showErrorInSnackbar(it.throwable) is RoomDetailViewEvents.OnNewTimelineEvents -> scrollOnNewMessageCallback.addNewTimelineEventIds(it.eventIds) is RoomDetailViewEvents.ActionSuccess -> displayRoomDetailActionSuccess(it) - is RoomDetailViewEvents.ActionFailure -> displayRoomDetailActionFailure(it) - is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message, Snackbar.LENGTH_LONG) - is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it) - is RoomDetailViewEvents.FileTooBigError -> displayFileTooBigError(it) - is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it) - is RoomDetailViewEvents.JoinRoomCommandSucces -> handleJoinedToAnotherRoom(it) - is RoomDetailViewEvents.SendMessageResult -> renderSendMessageResult(it) + is RoomDetailViewEvents.ActionFailure -> displayRoomDetailActionFailure(it) + is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message, Snackbar.LENGTH_LONG) + is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it) + is RoomDetailViewEvents.FileTooBigError -> displayFileTooBigError(it) + is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it) + is RoomDetailViewEvents.JoinRoomCommandSuccess -> handleJoinedToAnotherRoom(it) + is RoomDetailViewEvents.SendMessageResult -> renderSendMessageResult(it) }.exhaustive } } - private fun handleJoinedToAnotherRoom(action: RoomDetailViewEvents.JoinRoomCommandSucces) { + private fun handleJoinedToAnotherRoom(action: RoomDetailViewEvents.JoinRoomCommandSuccess) { updateComposerText("") lockSendButton = false navigator.openRoom(vectorBaseActivity, action.roomId) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewEvents.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewEvents.kt index 20657a1e42..b24c2ea23e 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewEvents.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewEvents.kt @@ -50,7 +50,7 @@ sealed class RoomDetailViewEvents : VectorViewEvents { abstract class SendMessageResult : RoomDetailViewEvents() object MessageSent : SendMessageResult() - data class JoinRoomCommandSucces(val roomId: String) : SendMessageResult() + data class JoinRoomCommandSuccess(val roomId: String) : SendMessageResult() class SlashCommandError(val command: Command) : SendMessageResult() class SlashCommandUnknown(val command: String) : SendMessageResult() data class SlashCommandHandled(@StringRes val messageRes: Int? = null) : SendMessageResult() diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt index 4991a9ca01..f7a6c09022 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt @@ -518,7 +518,7 @@ class RoomDetailViewModel @AssistedInject constructor( session.getRoomSummary(command.roomAlias) ?.roomId ?.let { - _viewEvents.post(RoomDetailViewEvents.JoinRoomCommandSucces(it)) + _viewEvents.post(RoomDetailViewEvents.JoinRoomCommandSuccess(it)) } } From 067a22883c627141004953c3858f4aac85606588 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 16 Mar 2020 16:00:22 +0100 Subject: [PATCH 10/14] WorkAround / crash android 10 gif from keyboard fixes #1136 --- CHANGES.md | 4 +++- .../features/attachments/AttachmentsHelper.kt | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d26237fd13..157f528747 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,9 @@ Improvements 🙌: - Implementation of /join command Bugfix 🐛: - - Message transitions in encrypted rooms are jarring #518 + - Message transitions in encrypted rooms are jarring #518 + - Images that failed to send are waiting to be sent forever #1145 + - Fix / Crashed when trying to send a gif from the Gboard #1136 Translations 🗣: - diff --git a/vector/src/main/java/im/vector/riotx/features/attachments/AttachmentsHelper.kt b/vector/src/main/java/im/vector/riotx/features/attachments/AttachmentsHelper.kt index ba1197b787..c576ebe1b9 100644 --- a/vector/src/main/java/im/vector/riotx/features/attachments/AttachmentsHelper.kt +++ b/vector/src/main/java/im/vector/riotx/features/attachments/AttachmentsHelper.kt @@ -177,19 +177,28 @@ class AttachmentsHelper private constructor(private val context: Context, fun handleShareIntent(intent: Intent): Boolean { val type = intent.resolveType(context) ?: return false if (type.startsWith("image")) { - imagePicker.submit(IntentUtils.getPickerIntentForSharing(intent)) + imagePicker.submit(safeShareIntent(intent)) } else if (type.startsWith("video")) { - videoPicker.submit(IntentUtils.getPickerIntentForSharing(intent)) + videoPicker.submit(safeShareIntent(intent)) } else if (type.startsWith("audio")) { - videoPicker.submit(IntentUtils.getPickerIntentForSharing(intent)) + videoPicker.submit(safeShareIntent(intent)) } else if (type.startsWith("application") || type.startsWith("file") || type.startsWith("*")) { - filePicker.submit(IntentUtils.getPickerIntentForSharing(intent)) + filePicker.submit(safeShareIntent(intent)) } else { return false } return true } + private fun safeShareIntent(intent: Intent): Intent { + // Work around for getPickerIntentForSharing doing NPE in android 10 + return try { + IntentUtils.getPickerIntentForSharing(intent) + } catch (failure: Throwable) { + intent + } + } + private fun getPickerManagerForRequestCode(requestCode: Int): PickerManager? { return when (requestCode) { PICK_IMAGE_DEVICE -> imagePicker From 8827b4b5ef19960d4526128b0b5654be952536f2 Mon Sep 17 00:00:00 2001 From: Valere Date: Fri, 13 Mar 2020 15:48:00 +0100 Subject: [PATCH 11/14] Fix / correctly update local echo failed state + endure Workmanager queues are reset after a clear cache --- .../android/internal/session/DefaultSession.kt | 1 + .../session/content/UploadContentWorker.kt | 10 ++++++++++ .../send/MultipleEventSendingDispatcherWorker.kt | 15 ++++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt index 84b76345c8..25dc939196 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt @@ -193,6 +193,7 @@ internal class DefaultSession @Inject constructor( stopAnyBackgroundSync() liveEntityObservers.forEach { it.cancelProcess() } cacheService.get().clearCache(callback) + workManagerProvider.cancelAllWorks() } @Subscribe(threadMode = ThreadMode.MAIN) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt index 1dde25fd78..1c88f87804 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt @@ -77,6 +77,16 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter return Result.success(inputData) } + // Just defensive code to ensure that we never have an uncaught exception that could break the queue + return try { + internalDoWork(params) + } catch (failure: Throwable) { + Timber.e(failure) + handleFailure(params, failure) + } + } + + private suspend fun internalDoWork(params: Params): Result { val sessionComponent = getSessionComponent(params.sessionId) ?: return Result.success() sessionComponent.inject(this) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/MultipleEventSendingDispatcherWorker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/MultipleEventSendingDispatcherWorker.kt index 03db817dd6..8c31dd1682 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/MultipleEventSendingDispatcherWorker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/MultipleEventSendingDispatcherWorker.kt @@ -23,6 +23,7 @@ import androidx.work.OneTimeWorkRequest import androidx.work.WorkerParameters import com.squareup.moshi.JsonClass import im.vector.matrix.android.api.session.events.model.Event +import im.vector.matrix.android.api.session.room.send.SendState import im.vector.matrix.android.internal.di.WorkManagerProvider import im.vector.matrix.android.internal.session.room.timeline.TimelineSendEventWorkCommon import im.vector.matrix.android.internal.worker.SessionWorkerParams @@ -49,6 +50,7 @@ internal class MultipleEventSendingDispatcherWorker(context: Context, params: Wo @Inject lateinit var workManagerProvider: WorkManagerProvider @Inject lateinit var timelineSendEventWorkCommon: TimelineSendEventWorkCommon + @Inject lateinit var localEchoUpdater: LocalEchoUpdater override suspend fun doWork(): Result { Timber.v("Start dispatch sending multiple event work") @@ -57,14 +59,17 @@ internal class MultipleEventSendingDispatcherWorker(context: Context, params: Wo Timber.e("Work cancelled due to input error from parent") } - if (params.lastFailureMessage != null) { - // Transmit the error - return Result.success(inputData) - } - val sessionComponent = getSessionComponent(params.sessionId) ?: return Result.success() sessionComponent.inject(this) + if (params.lastFailureMessage != null) { + params.events.forEach { event -> + event.eventId?.let { localEchoUpdater.updateSendState(it, SendState.UNDELIVERED) } + } + // Transmit the error if needed? + return Result.success(inputData) + } + // Create a work for every event params.events.forEach { event -> if (params.isEncrypted) { From b37600f536c8c3d076e5eaca37f570d8a42ec8da Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 17 Mar 2020 10:43:48 +0100 Subject: [PATCH 12/14] QuickFix / key banner not clickable --- CHANGES.md | 1 + .../java/im/vector/riotx/core/ui/views/KeysBackupBanner.kt | 1 + .../settings/KeysBackupSettingsRecyclerViewController.kt | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 157f528747..c2f7011c41 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Bugfix 🐛: - Message transitions in encrypted rooms are jarring #518 - Images that failed to send are waiting to be sent forever #1145 - Fix / Crashed when trying to send a gif from the Gboard #1136 + - Fix / Cannot click on key backup banner when new keys are available Translations 🗣: - diff --git a/vector/src/main/java/im/vector/riotx/core/ui/views/KeysBackupBanner.kt b/vector/src/main/java/im/vector/riotx/core/ui/views/KeysBackupBanner.kt index 7ce394b954..8d314f9e58 100755 --- a/vector/src/main/java/im/vector/riotx/core/ui/views/KeysBackupBanner.kt +++ b/vector/src/main/java/im/vector/riotx/core/ui/views/KeysBackupBanner.kt @@ -123,6 +123,7 @@ class KeysBackupBanner @JvmOverloads constructor( is State.Setup -> { delegate?.setupKeysBackup() } + is State.Update, is State.Recover -> { delegate?.recoverKeysBackup() } diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/settings/KeysBackupSettingsRecyclerViewController.kt b/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/settings/KeysBackupSettingsRecyclerViewController.kt index 4f2d806ce3..1fec404f7d 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/settings/KeysBackupSettingsRecyclerViewController.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/settings/KeysBackupSettingsRecyclerViewController.kt @@ -31,10 +31,12 @@ import im.vector.riotx.core.epoxy.loadingItem import im.vector.riotx.core.resources.StringProvider import im.vector.riotx.core.ui.list.GenericItem import im.vector.riotx.core.ui.list.genericItem +import im.vector.riotx.features.settings.VectorPreferences import java.util.UUID import javax.inject.Inject class KeysBackupSettingsRecyclerViewController @Inject constructor(private val stringProvider: StringProvider, + private val vectorPreferences: VectorPreferences, private val session: Session) : TypedEpoxyController() { var listener: Listener? = null @@ -149,7 +151,9 @@ class KeysBackupSettingsRecyclerViewController @Inject constructor(private val s description(keyVersionResult?.algorithm ?: "") } - buildKeysBackupTrust(data.keysBackupVersionTrust) + if (vectorPreferences.developerMode()) { + buildKeysBackupTrust(data.keysBackupVersionTrust) + } } // Footer From a9ed55e6a239796b163bd0ec598f44c8a91bb381 Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 17 Mar 2020 10:50:34 +0100 Subject: [PATCH 13/14] Fixes #757 --- vector/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 6c56211e57..f0c3bdc23d 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -1461,7 +1461,7 @@ Why choose Riot.im? Never lose encrypted messages Use Key Backup - New encrypted messages keys + New secure message keys Manage in Key Backup Backing up keys… From 78d90c8f0423a434b0b4ec87593b3eb2a29eafa8 Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 17 Mar 2020 11:46:42 +0100 Subject: [PATCH 14/14] prepare release 0.18.1 --- CHANGES.md | 16 +--------------- vector/build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c2f7011c41..08b9c01efc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,9 +1,6 @@ -Changes in RiotX 0.19.0 (2020-XX-XX) +Changes in RiotX 0.18.1 (2020-03-17) =================================================== -Features ✨: - - - Improvements 🙌: - Implementation of /join command @@ -13,17 +10,6 @@ Bugfix 🐛: - Fix / Crashed when trying to send a gif from the Gboard #1136 - Fix / Cannot click on key backup banner when new keys are available -Translations 🗣: - - - -SDK API changes ⚠️: - - - -Build 🧱: - - - -Other changes: - - Changes in RiotX 0.18.0 (2020-03-11) =================================================== diff --git a/vector/build.gradle b/vector/build.gradle index 2aae593271..2a5a8b3b34 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -15,8 +15,8 @@ androidExtensions { } ext.versionMajor = 0 -ext.versionMinor = 19 -ext.versionPatch = 0 +ext.versionMinor = 18 +ext.versionPatch = 1 static def getGitTimestamp() { def cmd = 'git show -s --format=%ct'