Developer quick setting to show hidden events
https://github.com/SchildiChat/SchildiChat-android/issues/117 Change-Id: I4d7a015f5634f555dca7dcef54653b038ce96e5d
This commit is contained in:
parent
086d9c08ff
commit
226428e0ba
|
@ -1028,6 +1028,15 @@ class TimelineFragment @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun reloadTimeline(rebuildTimeline: Boolean = false, invalidateEpoxy: Boolean = true) {
|
||||
if (rebuildTimeline) {
|
||||
timelineViewModel.timeline.restartWithEventId(latestCurrentlyVisibleItem()?.eventId ?: timelineViewModel.timeline.getTargetEventId())
|
||||
}
|
||||
if (invalidateEpoxy) {
|
||||
timelineEventController.invalidateFullTimeline()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupJumpToReadMarkerView() {
|
||||
views.jumpToReadMarkerView.debouncedClicks {
|
||||
onJumpToReadMarkerClicked()
|
||||
|
@ -1165,6 +1174,9 @@ class TimelineFragment @Inject constructor(
|
|||
else -> R.id.dev_bubble_style_both
|
||||
}
|
||||
menu.findItem(selectedBubbleStyle).isChecked = true
|
||||
|
||||
// Hidden events
|
||||
menu.findItem(R.id.dev_hidden_events).isChecked = vectorPreferences.shouldShowHiddenEvents()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
@ -1213,6 +1225,13 @@ class TimelineFragment @Inject constructor(
|
|||
handleSetBubbleStyle(BubbleThemeUtils.BUBBLE_STYLE_ELEMENT)
|
||||
true
|
||||
}
|
||||
R.id.dev_hidden_events -> {
|
||||
val shouldShow = !item.isChecked
|
||||
vectorPreferences.setShouldShowHiddenEvents(shouldShow)
|
||||
item.isChecked = shouldShow
|
||||
reloadTimeline()
|
||||
true
|
||||
}
|
||||
R.id.menu_timeline_thread_list -> {
|
||||
navigateToThreadList()
|
||||
true
|
||||
|
@ -2339,37 +2358,40 @@ class TimelineFragment @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onReadMarkerVisible() {
|
||||
var mostRecentDisplayedEvent: TimelineEvent? = timelineViewModel.mostRecentDisplayedEvent()
|
||||
val lm = views.timelineRecyclerView.layoutManager as? LinearLayoutManager
|
||||
val room = session.roomService().getRoom(timelineArgs.roomId)
|
||||
rmDimber.i { "Most recent check: ${mostRecentDisplayedEvent == null} ${lm?.findFirstVisibleItemPosition()}..${lm?.findLastVisibleItemPosition()}" }
|
||||
if (mostRecentDisplayedEvent == null && lm != null && room != null) {
|
||||
for (i in lm.findFirstVisibleItemPosition()..lm.findLastVisibleItemPosition()) {
|
||||
val model = timelineEventController.adapter.getModelAtPosition(i)
|
||||
rmDimber.i { "Most recent check: ${model.javaClass} / ${(model as? ItemWithEvents)?.isVisible()}" }
|
||||
if (model is ItemWithEvents) {
|
||||
if (!model.isVisible()) {
|
||||
continue
|
||||
}
|
||||
rmDimber.i { "Most recent displayed model: ${model.getEventIds().firstOrNull()} - ${model.getEventIds().lastOrNull()}" }
|
||||
model.getEventIds().reversed().forEach { eventId ->
|
||||
if (mostRecentDisplayedEvent != null) {
|
||||
return@forEach
|
||||
}
|
||||
val event = room.getTimelineEvent(eventId)
|
||||
if (event != null) {
|
||||
rmDimber.i { "Most recent displayed event: $eventId" }
|
||||
mostRecentDisplayedEvent = event
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
val mostRecentDisplayedEvent: TimelineEvent? = timelineViewModel.mostRecentDisplayedEvent() ?: latestCurrentlyVisibleItem(rmDimber)
|
||||
timelineViewModel.handle(RoomDetailAction.EnterTrackingUnreadMessagesState(mostRecentDisplayedEvent))
|
||||
}
|
||||
|
||||
private fun latestCurrentlyVisibleItem(dimber: Dimber? = null): TimelineEvent? {
|
||||
var mostRecentDisplayedEvent: TimelineEvent? = null
|
||||
val lm = views.timelineRecyclerView.layoutManager as? LinearLayoutManager ?: return null
|
||||
val room = session.roomService().getRoom(timelineArgs.roomId) ?: return null
|
||||
dimber?.i { "Most recent check: ${mostRecentDisplayedEvent == null} ${lm.findFirstVisibleItemPosition()}..${lm.findLastVisibleItemPosition()}" }
|
||||
for (i in lm.findFirstVisibleItemPosition()..lm.findLastVisibleItemPosition()) {
|
||||
val model = timelineEventController.adapter.getModelAtPosition(i)
|
||||
dimber?.i { "Most recent check: ${model.javaClass} / ${(model as? ItemWithEvents)?.isVisible()}" }
|
||||
if (model is ItemWithEvents) {
|
||||
if (!model.isVisible()) {
|
||||
continue
|
||||
}
|
||||
if (mostRecentDisplayedEvent != null) {
|
||||
break
|
||||
dimber?.i { "Most recent displayed model: ${model.getEventIds().firstOrNull()} - ${model.getEventIds().lastOrNull()}" }
|
||||
model.getEventIds().reversed().forEach { eventId ->
|
||||
if (mostRecentDisplayedEvent != null) {
|
||||
return@forEach
|
||||
}
|
||||
val event = room.getTimelineEvent(eventId)
|
||||
if (event != null) {
|
||||
dimber?.i { "Most recent displayed event: $eventId" }
|
||||
mostRecentDisplayedEvent = event
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mostRecentDisplayedEvent != null) {
|
||||
break
|
||||
}
|
||||
}
|
||||
timelineViewModel.handle(RoomDetailAction.EnterTrackingUnreadMessagesState(mostRecentDisplayedEvent))
|
||||
return mostRecentDisplayedEvent
|
||||
}
|
||||
|
||||
override fun onPreviewUrlClicked(url: String) {
|
||||
|
|
|
@ -784,6 +784,7 @@ class TimelineViewModel @AssistedInject constructor(
|
|||
R.id.show_room_info -> true // SC
|
||||
R.id.show_participants -> true // SC
|
||||
R.id.dev_bubble_style, // SC
|
||||
R.id.dev_hidden_events, // SC
|
||||
R.id.dev_tools -> vectorPreferences.developerMode()
|
||||
else -> false
|
||||
}
|
||||
|
|
|
@ -377,7 +377,7 @@ class TimelineEventController @Inject constructor(
|
|||
submitSnapshot(snapshot)
|
||||
}
|
||||
|
||||
private fun invalidateFullTimeline() {
|
||||
fun invalidateFullTimeline() {
|
||||
backgroundHandler.post {
|
||||
inSubmitList = true
|
||||
// Invalidate all timeline events to rebuild the whole Room/DM layout
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package im.vector.app.features.settings
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.media.RingtoneManager
|
||||
|
@ -372,6 +373,12 @@ class VectorPreferences @Inject constructor(
|
|||
return developerMode() && defaultPrefs.getBoolean(SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY, false)
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
fun setShouldShowHiddenEvents(shouldShow: Boolean) {
|
||||
// Commit, so we can be sure on timeline reload we will get the new value
|
||||
defaultPrefs.edit().putBoolean(SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY, shouldShow).commit()
|
||||
}
|
||||
|
||||
fun swipeToReplyIsEnabled(): Boolean {
|
||||
return defaultPrefs.getBoolean(SETTINGS_LABS_ENABLE_SWIPE_TO_REPLY, true)
|
||||
}
|
||||
|
|
|
@ -110,6 +110,14 @@
|
|||
</menu>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/dev_hidden_events"
|
||||
android:title="@string/dev_tools_menu_hidden_events"
|
||||
android:visible="false"
|
||||
app:showAsAction="never"
|
||||
android:checkable="true"
|
||||
android:checked="false" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_thread_timeline_view_in_room"
|
||||
android:icon="@drawable/ic_thread_view_in_room_menu_item"
|
||||
|
|
|
@ -198,4 +198,6 @@
|
|||
<string name="freeform_react_with">React with \"%1$s\"</string>
|
||||
<string name="freeform_reaction_summary">Free-form reaction</string>
|
||||
|
||||
<string name="dev_tools_menu_hidden_events">Hidden events</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue