Add read event tracking debugging

Change-Id: If9cc30f32af7bcadda9df6b04ad89ae248166da8
This commit is contained in:
SpiritCroc 2022-03-17 09:46:09 +01:00
parent 57fee29645
commit b982841ed5
7 changed files with 36 additions and 2 deletions

View File

@ -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) {

View File

@ -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()
}

View File

@ -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(

View File

@ -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<Unit> = Uninitialized

View File

@ -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() {

View File

@ -52,6 +52,20 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/appBarLayout" />
<TextView
android:id="@+id/scRoomDebugView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.Vector.TextView.Caption"
android:layout_gravity="end|center_vertical"
android:fontFamily="monospace"
android:padding="2dp"
android:visibility="gone"
tools:text="SC-dbg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/syncStateView" />
<im.vector.app.features.call.conference.RemoveJitsiWidgetView
android:id="@+id/removeJitsiWidgetView"
android:layout_width="match_parent"
@ -59,7 +73,7 @@
android:background="?android:colorBackground"
android:minHeight="54dp"
android:visibility="visible"
app:layout_constraintTop_toBottomOf="@id/syncStateView" />
app:layout_constraintTop_toBottomOf="@id/scRoomDebugView" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/timelineRecyclerView"

View File

@ -177,4 +177,5 @@
<string name="settings_sc_dbg_read_marker">Debug read markers</string>
<string name="settings_sc_dbg_timeline_chunks">Debug timeline consistency</string>
<string name="settings_sc_dbg_show_display_index">Show displayIndex in timeline</string>
<string name="settings_sc_dbg_show_read_tracking">Show read tracking</string>
</resources>