From fd74e3dfb1f5471cb458891c394b206ea77cb4b9 Mon Sep 17 00:00:00 2001 From: ganfra Date: Mon, 19 Aug 2019 14:08:15 +0200 Subject: [PATCH] Read receipts: clean code after review --- CHANGES.md | 2 +- .../internal/database/query/FilterContent.kt | 2 +- .../room/timeline/TimelineHiddenReadReceipts.kt | 17 +++++++++++++++-- .../res/layout/item_display_read_receipt.xml | 11 +++++------ .../res/layout/item_simple_reaction_info.xml | 6 +++--- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3f83d97765..682c176b98 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,7 +2,7 @@ Changes in RiotX 0.4.0 (2019-XX-XX) =================================================== Features: - - Display read receipts in timeline + - Display read receipts in timeline (#81) Improvements: - diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/FilterContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/FilterContent.kt index 9e6261c6b7..92608a1f42 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/FilterContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/FilterContent.kt @@ -18,6 +18,6 @@ package im.vector.matrix.android.internal.database.query internal object FilterContent { - internal const val EDIT_TYPE = "{*\"m.relates_to\"*\"rel_type\":*\"m.replace\"*}" + internal const val EDIT_TYPE = """{*"m.relates_to"*"rel_type":*"m.replace"*}""" } \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineHiddenReadReceipts.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineHiddenReadReceipts.kt index e42bf23017..5658210302 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineHiddenReadReceipts.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineHiddenReadReceipts.kt @@ -31,6 +31,11 @@ import io.realm.Realm import io.realm.RealmQuery import io.realm.RealmResults +/** + * This class is responsible for handling the read receipts for hidden events (check [TimelineSettings] to see filtering). + * When an hidden event has read receipts, we want to transfer these read receipts on the first older displayed event. + * It has to be used in [DefaultTimeline] and we should call the [start] and [dispose] methods to properly handle realm subscription. + */ internal class TimelineHiddenReadReceipts constructor(private val readReceiptsSummaryMapper: ReadReceiptsSummaryMapper, private val roomId: String, private val settings: TimelineSettings) { @@ -95,7 +100,9 @@ internal class TimelineHiddenReadReceipts constructor(private val readReceiptsSu } } - + /** + * Start the realm query subscription. Has to be called on an HandlerThread + */ fun start(realm: Realm, liveEvents: RealmResults, delegate: Delegate) { this.liveEvents = liveEvents this.delegate = delegate @@ -109,10 +116,16 @@ internal class TimelineHiddenReadReceipts constructor(private val readReceiptsSu .also { it.addChangeListener(hiddenReadReceiptsListener) } } + /** + * Dispose the realm query subscription. Has to be called on an HandlerThread + */ fun dispose() { - this.hiddenReadReceipts?.removeAllChangeListeners() + this.hiddenReadReceipts.removeAllChangeListeners() } + /** + * Return the current corrected [ReadReceipt] list for an event, or null + */ fun correctedReadReceipts(eventId: String?): List? { return correctedReadReceiptsByEvent[eventId] } diff --git a/vector/src/main/res/layout/item_display_read_receipt.xml b/vector/src/main/res/layout/item_display_read_receipt.xml index cf3c9a2662..9b4072ab76 100644 --- a/vector/src/main/res/layout/item_display_read_receipt.xml +++ b/vector/src/main/res/layout/item_display_read_receipt.xml @@ -3,11 +3,10 @@ @@ -35,9 +35,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:lines="1" - android:textColor="?android:textColorSecondary" + android:textColor="?riotx_text_secondary" android:textSize="12sp" tools:text="10:44" /> - \ No newline at end of file diff --git a/vector/src/main/res/layout/item_simple_reaction_info.xml b/vector/src/main/res/layout/item_simple_reaction_info.xml index 0458b17126..06f94fc8cf 100644 --- a/vector/src/main/res/layout/item_simple_reaction_info.xml +++ b/vector/src/main/res/layout/item_simple_reaction_info.xml @@ -2,11 +2,10 @@