From b982841ed523890eee3ac1a55d6761579fceb361 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Thu, 17 Mar 2022 09:46:09 +0100 Subject: [PATCH] Add read event tracking debugging Change-Id: If9cc30f32af7bcadda9df6b04ad89ae248166da8 --- .../java/de/spiritcroc/matrixsdk/util/DbgUtil.kt | 4 +++- .../home/room/detail/RoomDetailViewEvents.kt | 3 +++ .../home/room/detail/TimelineFragment.kt | 7 +++++++ .../home/room/detail/TimelineViewModel.kt | 6 ++++++ .../VectorSettingsScDebuggingFragment.kt | 1 + vector/src/main/res/layout/fragment_timeline.xml | 16 +++++++++++++++- vector/src/main/res/values/strings_sc.xml | 1 + 7 files changed, 36 insertions(+), 2 deletions(-) diff --git a/matrix-sdk-android/src/main/java/de/spiritcroc/matrixsdk/util/DbgUtil.kt b/matrix-sdk-android/src/main/java/de/spiritcroc/matrixsdk/util/DbgUtil.kt index 2277329ebc..8f62b18900 100644 --- a/matrix-sdk-android/src/main/java/de/spiritcroc/matrixsdk/util/DbgUtil.kt +++ b/matrix-sdk-android/src/main/java/de/spiritcroc/matrixsdk/util/DbgUtil.kt @@ -7,6 +7,7 @@ import timber.log.Timber object DbgUtil { const val DBG_READ_MARKER = "DBG_READ_MARKER" + const val DBG_SHOW_READ_TRACKING = "DBG_SHOW_READ_TRACKING" const val DBG_TIMELINE_CHUNKS = "DBG_TIMELINE_CHUNKS" const val DBG_SHOW_DISPLAY_INDEX = "DBG_SHOW_DISPLAY_INDEX" @@ -14,8 +15,9 @@ object DbgUtil { private val ALL_PREFS = arrayOf( DBG_READ_MARKER, + DBG_SHOW_READ_TRACKING, DBG_TIMELINE_CHUNKS, - DBG_SHOW_DISPLAY_INDEX + DBG_SHOW_DISPLAY_INDEX, ) fun load(context: Context) { 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 d08a27324c..3b274bce91 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 @@ -20,6 +20,7 @@ import android.net.Uri import android.view.View import im.vector.app.core.platform.VectorViewEvents import im.vector.app.features.call.webrtc.WebRtcCall +import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent import org.matrix.android.sdk.api.session.widgets.model.Widget import org.matrix.android.sdk.api.util.MatrixItem import org.matrix.android.sdk.internal.crypto.model.event.WithHeldCode @@ -82,4 +83,6 @@ sealed class RoomDetailViewEvents : VectorViewEvents { data class StartChatEffect(val type: ChatEffect) : RoomDetailViewEvents() object StopChatEffects : RoomDetailViewEvents() object RoomReplacementStarted : RoomDetailViewEvents() + + data class ScDbgReadTracking(val event: TimelineEvent?) : RoomDetailViewEvents() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt index 5fa8a16812..77a6c6805d 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt @@ -395,6 +395,8 @@ class TimelineFragment @Inject constructor( setupRemoveJitsiWidgetView() setupVoiceMessageView() + views.scRoomDebugView.isVisible = DbgUtil.isDbgEnabled(DbgUtil.DBG_SHOW_READ_TRACKING) + views.includeRoomToolbar.roomToolbarContentView.debouncedClicks { navigator.openRoomProfile(requireActivity(), timelineArgs.roomId) } @@ -494,6 +496,7 @@ class TimelineFragment @Inject constructor( RoomDetailViewEvents.StopChatEffects -> handleStopChatEffects() is RoomDetailViewEvents.DisplayAndAcceptCall -> acceptIncomingCall(it) RoomDetailViewEvents.RoomReplacementStarted -> handleRoomReplacement() + is RoomDetailViewEvents.ScDbgReadTracking -> handleScDbgReadTracking(it) }.exhaustive } @@ -606,6 +609,10 @@ class TimelineFragment @Inject constructor( views.viewKonfetti.isInvisible = true } + private fun handleScDbgReadTracking(action: RoomDetailViewEvents.ScDbgReadTracking) { + views.scRoomDebugView.text = "Read: ${action.event?.eventId}/${action.event?.displayIndex}" + } + override fun onImageReady(uri: Uri?) { uri ?: return timelineViewModel.handle( diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt index 57e5d24399..a8e929e674 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt @@ -158,6 +158,12 @@ class TimelineViewModel @AssistedInject constructor( private var trackUnreadMessages = AtomicBoolean(false) private var mostRecentDisplayedEvent: TimelineEvent? = null + set(value) { + field = value + if (DbgUtil.isDbgEnabled(DbgUtil.DBG_SHOW_READ_TRACKING)) { + _viewEvents.post(RoomDetailViewEvents.ScDbgReadTracking(mostRecentDisplayedEvent)) + } + } private var prepareToEncrypt: Async = Uninitialized diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsScDebuggingFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsScDebuggingFragment.kt index 0aed4db83b..b9de9cda19 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsScDebuggingFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsScDebuggingFragment.kt @@ -19,6 +19,7 @@ class VectorSettingsScDebuggingFragment @Inject constructor( DbgPref(DbgUtil.DBG_TIMELINE_CHUNKS, R.string.settings_sc_dbg_timeline_chunks), DbgPref(DbgUtil.DBG_SHOW_DISPLAY_INDEX, R.string.settings_sc_dbg_show_display_index), DbgPref(DbgUtil.DBG_READ_MARKER, R.string.settings_sc_dbg_read_marker), + DbgPref(DbgUtil.DBG_SHOW_READ_TRACKING, R.string.settings_sc_dbg_show_read_tracking), ) override fun bindPref() { diff --git a/vector/src/main/res/layout/fragment_timeline.xml b/vector/src/main/res/layout/fragment_timeline.xml index d0984ca928..7b706044cc 100644 --- a/vector/src/main/res/layout/fragment_timeline.xml +++ b/vector/src/main/res/layout/fragment_timeline.xml @@ -52,6 +52,20 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/appBarLayout" /> + + + app:layout_constraintTop_toBottomOf="@id/scRoomDebugView" /> Debug read markers Debug timeline consistency Show displayIndex in timeline + Show read tracking