From 407b4bd3c7abb629c3843006efbe85618b009d83 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 13 Dec 2023 17:05:00 +0100 Subject: [PATCH 1/3] Fix script to work when SDK is located anywhere. --- tools/sdk/build_rust_sdk.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/sdk/build_rust_sdk.sh b/tools/sdk/build_rust_sdk.sh index 3d7dc17059..93c0150f87 100755 --- a/tools/sdk/build_rust_sdk.sh +++ b/tools/sdk/build_rust_sdk.sh @@ -8,6 +8,7 @@ read -p "Do you want to build the Rust SDK from local source (yes/no) default to buildLocal=${buildLocal:-yes} date=$(gdate +%Y%m%d%H%M%S) +elementPwd=`pwd` # Ask for the Rust SDK local source path # if folder rustSdk/ exists, use it as default @@ -28,7 +29,7 @@ else cd matrix-rust-sdk-$date git checkout ${rustSdkBranch} rustSdkPath=$(pwd) - cd ../element-x-android + cd ${elementPwd} fi @@ -46,6 +47,8 @@ fi read -p "Do you want to build the app after (yes/no) default to yes? " buildApp buildApp=${buildApp:-yes} +cd ${elementPwd} + # If folder ../matrix-rust-components-kotlin does not exist, clone the repo if [ ! -d "../matrix-rust-components-kotlin" ]; then printf "\nFolder ../matrix-rust-components-kotlin does not exist. Cloning the repository into ../matrix-rust-components-kotlin.\n\n" @@ -59,9 +62,9 @@ git checkout main git pull printf "\nBuilding the SDK for aarch64-linux-android...\n\n" -./scripts/build.sh -p ${rustSdkPath} -m sdk -t aarch64-linux-android -o ../element-x-android/libraries/rustsdk +./scripts/build.sh -p ${rustSdkPath} -m sdk -t aarch64-linux-android -o ${elementPwd}/libraries/rustsdk -cd ../element-x-android +cd ${elementPwd} mv ./libraries/rustsdk/sdk-android-debug.aar ./libraries/rustsdk/matrix-rust-sdk.aar mkdir -p ./libraries/rustsdk/sdks cp ./libraries/rustsdk/matrix-rust-sdk.aar ./libraries/rustsdk/sdks/matrix-rust-sdk-${date}.aar From 68334ba0931d406137020ad3877f2076cd8b2e1b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 13 Dec 2023 18:01:25 +0100 Subject: [PATCH 2/3] Fix API break regarding ReceiptType --- .../impl/timeline/TimelinePresenter.kt | 3 ++- .../matrix/api/timeline/MatrixTimeline.kt | 4 +-- .../matrix/api/timeline/ReceiptType.kt | 23 ++++++++++++++++ .../matrix/impl/timeline/ReceiptTypeMapper.kt | 26 +++++++++++++++++++ .../impl/timeline/RustMatrixTimeline.kt | 11 ++++++-- .../test/timeline/FakeMatrixTimeline.kt | 6 ++++- 6 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/ReceiptType.kt create mode 100644 libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/ReceiptTypeMapper.kt diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelinePresenter.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelinePresenter.kt index 9d000b18e0..5ed3a74c72 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelinePresenter.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelinePresenter.kt @@ -48,6 +48,7 @@ import io.element.android.libraries.matrix.api.encryption.EncryptionService import io.element.android.libraries.matrix.api.room.MatrixRoom import io.element.android.libraries.matrix.api.room.MessageEventType import io.element.android.libraries.matrix.api.room.roomMembers +import io.element.android.libraries.matrix.api.timeline.ReceiptType import io.element.android.libraries.matrix.api.timeline.item.event.TimelineItemEventOrigin import io.element.android.libraries.matrix.api.verification.SessionVerificationService import io.element.android.libraries.matrix.api.verification.SessionVerifiedStatus @@ -236,7 +237,7 @@ class TimelinePresenter @AssistedInject constructor( if (eventId != null && firstVisibleIndex <= lastReadReceiptIndex.value && eventId != lastReadReceiptId.value) { lastReadReceiptIndex.value = firstVisibleIndex lastReadReceiptId.value = eventId - timeline.sendReadReceipt(eventId) + timeline.sendReadReceipt(eventId = eventId, receiptType = ReceiptType.READ) } } diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/MatrixTimeline.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/MatrixTimeline.kt index 8dfa2e4819..45b209968e 100644 --- a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/MatrixTimeline.kt +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/MatrixTimeline.kt @@ -20,7 +20,7 @@ import io.element.android.libraries.matrix.api.core.EventId import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow -interface MatrixTimeline: AutoCloseable { +interface MatrixTimeline : AutoCloseable { data class PaginationState( val isBackPaginating: Boolean, @@ -36,5 +36,5 @@ interface MatrixTimeline: AutoCloseable { suspend fun paginateBackwards(requestSize: Int, untilNumberOfItems: Int): Result suspend fun fetchDetailsForEvent(eventId: EventId): Result - suspend fun sendReadReceipt(eventId: EventId): Result + suspend fun sendReadReceipt(eventId: EventId, receiptType: ReceiptType): Result } diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/ReceiptType.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/ReceiptType.kt new file mode 100644 index 0000000000..7f02285b7e --- /dev/null +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/ReceiptType.kt @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2023 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 io.element.android.libraries.matrix.api.timeline + +enum class ReceiptType { + READ, + READ_PRIVATE, + FULLY_READ; +} diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/ReceiptTypeMapper.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/ReceiptTypeMapper.kt new file mode 100644 index 0000000000..02722e43dc --- /dev/null +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/ReceiptTypeMapper.kt @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 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 io.element.android.libraries.matrix.impl.timeline + +import io.element.android.libraries.matrix.api.timeline.ReceiptType +import org.matrix.rustcomponents.sdk.ReceiptType as RustReceiptType + +internal fun ReceiptType.toRustReceiptType(): RustReceiptType = when (this) { + ReceiptType.READ -> RustReceiptType.READ + ReceiptType.READ_PRIVATE -> RustReceiptType.READ_PRIVATE + ReceiptType.FULLY_READ -> RustReceiptType.FULLY_READ +} diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustMatrixTimeline.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustMatrixTimeline.kt index 85f59f9e57..26379e0051 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustMatrixTimeline.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustMatrixTimeline.kt @@ -20,6 +20,7 @@ import io.element.android.libraries.matrix.api.core.EventId import io.element.android.libraries.matrix.api.room.MatrixRoom import io.element.android.libraries.matrix.api.timeline.MatrixTimeline import io.element.android.libraries.matrix.api.timeline.MatrixTimelineItem +import io.element.android.libraries.matrix.api.timeline.ReceiptType import io.element.android.libraries.matrix.api.timeline.TimelineException import io.element.android.libraries.matrix.api.timeline.item.virtual.VirtualTimelineItem import io.element.android.libraries.matrix.impl.timeline.item.event.EventMessageMapper @@ -217,9 +218,15 @@ class RustMatrixTimeline( return isInit.get() && paginationState.value.canBackPaginate } - override suspend fun sendReadReceipt(eventId: EventId) = withContext(dispatcher) { + override suspend fun sendReadReceipt( + eventId: EventId, + receiptType: ReceiptType, + ) = withContext(dispatcher) { runCatching { - innerTimeline.sendReadReceipt(eventId = eventId.value) + innerTimeline.sendReadReceipt( + receiptType = receiptType.toRustReceiptType(), + eventId = eventId.value, + ) } } diff --git a/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/timeline/FakeMatrixTimeline.kt b/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/timeline/FakeMatrixTimeline.kt index 21325d7a83..bb7fcc7f22 100644 --- a/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/timeline/FakeMatrixTimeline.kt +++ b/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/timeline/FakeMatrixTimeline.kt @@ -19,6 +19,7 @@ package io.element.android.libraries.matrix.test.timeline import io.element.android.libraries.matrix.api.core.EventId import io.element.android.libraries.matrix.api.timeline.MatrixTimeline import io.element.android.libraries.matrix.api.timeline.MatrixTimelineItem +import io.element.android.libraries.matrix.api.timeline.ReceiptType import io.element.android.tests.testutils.simulateLongTask import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.delay @@ -74,7 +75,10 @@ class FakeMatrixTimeline( Result.success(Unit) } - override suspend fun sendReadReceipt(eventId: EventId): Result = simulateLongTask { + override suspend fun sendReadReceipt( + eventId: EventId, + receiptType: ReceiptType, + ): Result = simulateLongTask { sendReadReceiptCount++ sendReadReceiptLatch?.complete(Unit) Result.success(Unit) From 56e01f07f96f801f3be6116b5eec3f14716dff70 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 14 Dec 2023 11:24:32 +0100 Subject: [PATCH 3/3] SDK 0.1.77 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ae001ac0c3..a0cc0fc010 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -149,7 +149,7 @@ jsoup = "org.jsoup:jsoup:1.17.1" appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" } molecule-runtime = "app.cash.molecule:molecule-runtime:1.3.1" timber = "com.jakewharton.timber:timber:5.0.1" -matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.76" +matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.77" matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" } matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" } sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }