More hidden events developer quick settings

Change-Id: Ic5f716ec7bac1e292284a3706ac7b252b367b03f
This commit is contained in:
SpiritCroc 2022-06-08 14:59:51 +02:00
parent d3c6356a3f
commit d093b17da0
6 changed files with 85 additions and 12 deletions

View File

@ -60,3 +60,10 @@ object ArrayOptionsMenuHelper {
return false return false
} }
} }
fun MenuItem.toggleExec(withNewVal: (Boolean) -> Boolean) {
val shouldCheck = !isChecked
if (withNewVal(shouldCheck)) {
isChecked = shouldCheck
}
}

View File

@ -74,6 +74,7 @@ import com.vanniktech.emoji.EmojiPopup
import de.spiritcroc.matrixsdk.util.DbgUtil import de.spiritcroc.matrixsdk.util.DbgUtil
import de.spiritcroc.matrixsdk.util.Dimber import de.spiritcroc.matrixsdk.util.Dimber
import de.spiritcroc.menu.ArrayOptionsMenuHelper import de.spiritcroc.menu.ArrayOptionsMenuHelper
import de.spiritcroc.menu.toggleExec
import de.spiritcroc.recyclerview.StickyHeaderItemDecoration import de.spiritcroc.recyclerview.StickyHeaderItemDecoration
import de.spiritcroc.recyclerview.widget.BetterLinearLayoutManager import de.spiritcroc.recyclerview.widget.BetterLinearLayoutManager
import de.spiritcroc.recyclerview.widget.LinearLayoutManager import de.spiritcroc.recyclerview.widget.LinearLayoutManager
@ -1180,6 +1181,9 @@ class TimelineFragment @Inject constructor(
// Hidden events // Hidden events
menu.findItem(R.id.dev_hidden_events).isChecked = vectorPreferences.shouldShowHiddenEvents() menu.findItem(R.id.dev_hidden_events).isChecked = vectorPreferences.shouldShowHiddenEvents()
menu.findItem(R.id.dev_membership_changes).isChecked = vectorPreferences.showJoinLeaveMessages()
menu.findItem(R.id.dev_display_name_changes).isChecked = vectorPreferences.showAvatarDisplayNameChangeMessages()
menu.findItem(R.id.dev_redacted).isChecked = vectorPreferences.showRedactedMessages()
// Bubble style // Bubble style
ArrayOptionsMenuHelper.createSubmenu( ArrayOptionsMenuHelper.createSubmenu(
@ -1273,10 +1277,35 @@ class TimelineFragment @Inject constructor(
true true
} }
R.id.dev_hidden_events -> { R.id.dev_hidden_events -> {
val shouldShow = !item.isChecked item.toggleExec { shouldShow ->
vectorPreferences.setShouldShowHiddenEvents(shouldShow) vectorPreferences.setShouldShowHiddenEvents(shouldShow)
item.isChecked = shouldShow reloadTimeline()
reloadTimeline() true
}
true
}
R.id.dev_membership_changes -> {
item.toggleExec { shouldShow ->
vectorPreferences.setShowJoinLeaveMessages(shouldShow)
reloadTimeline()
true
}
true
}
R.id.dev_display_name_changes -> {
item.toggleExec { shouldShow ->
vectorPreferences.setShowAvatarDisplayNameChangeMessages(shouldShow)
reloadTimeline()
true
}
true
}
R.id.dev_redacted -> {
item.toggleExec { shouldShow ->
vectorPreferences.setShowRedactedMessages(shouldShow)
reloadTimeline()
true
}
true true
} }
R.id.menu_timeline_thread_list -> { R.id.menu_timeline_thread_list -> {

View File

@ -784,9 +784,12 @@ class TimelineViewModel @AssistedInject constructor(
R.id.menu_timeline_thread_list -> vectorPreferences.areThreadMessagesEnabled() R.id.menu_timeline_thread_list -> vectorPreferences.areThreadMessagesEnabled()
R.id.show_room_info -> true // SC R.id.show_room_info -> true // SC
R.id.show_participants -> true // SC R.id.show_participants -> true // SC
R.id.dev_bubble_style, // SC // SC dev start
R.id.dev_hidden_events, // SC R.id.dev_bubble_style,
R.id.dev_theming, // SC R.id.dev_hidden_events,
R.id.dev_event_visibilities,
R.id.dev_theming,
// SC dev end
R.id.dev_tools -> vectorPreferences.developerMode() R.id.dev_tools -> vectorPreferences.developerMode()
else -> false else -> false
} }

View File

@ -375,10 +375,8 @@ class VectorPreferences @Inject constructor(
return developerMode() && defaultPrefs.getBoolean(SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY, false) return developerMode() && defaultPrefs.getBoolean(SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY, false)
} }
@SuppressLint("ApplySharedPref")
fun setShouldShowHiddenEvents(shouldShow: Boolean) { fun setShouldShowHiddenEvents(shouldShow: Boolean) {
// Commit, so we can be sure on timeline reload we will get the new value defaultPrefs.edit(commit = true) { putBoolean(SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY, shouldShow) }
defaultPrefs.edit().putBoolean(SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY, shouldShow).commit()
} }
fun swipeToReplyIsEnabled(): Boolean { fun swipeToReplyIsEnabled(): Boolean {
@ -461,6 +459,10 @@ class VectorPreferences @Inject constructor(
return defaultPrefs.getBoolean(SETTINGS_SHOW_JOIN_LEAVE_MESSAGES_KEY, true) return defaultPrefs.getBoolean(SETTINGS_SHOW_JOIN_LEAVE_MESSAGES_KEY, true)
} }
fun setShowJoinLeaveMessages(shouldShow: Boolean) {
defaultPrefs.edit(commit = true) { putBoolean(SETTINGS_SHOW_JOIN_LEAVE_MESSAGES_KEY, shouldShow) }
}
/** /**
* Tells if the avatar and display name events should be shown in the messages list. * Tells if the avatar and display name events should be shown in the messages list.
* *
@ -470,6 +472,10 @@ class VectorPreferences @Inject constructor(
return defaultPrefs.getBoolean(SETTINGS_SHOW_AVATAR_DISPLAY_NAME_CHANGES_MESSAGES_KEY, true) return defaultPrefs.getBoolean(SETTINGS_SHOW_AVATAR_DISPLAY_NAME_CHANGES_MESSAGES_KEY, true)
} }
fun setShowAvatarDisplayNameChangeMessages(shouldShow: Boolean) {
defaultPrefs.edit(commit = true) { putBoolean(SETTINGS_SHOW_AVATAR_DISPLAY_NAME_CHANGES_MESSAGES_KEY, shouldShow) }
}
/** /**
* Tells the native camera to take a photo or record a video. * Tells the native camera to take a photo or record a video.
* *
@ -790,6 +796,10 @@ class VectorPreferences @Inject constructor(
return defaultPrefs.getBoolean(SETTINGS_SHOW_REDACTED_KEY, false) return defaultPrefs.getBoolean(SETTINGS_SHOW_REDACTED_KEY, false)
} }
fun setShowRedactedMessages(shouldShow: Boolean) {
return defaultPrefs.edit(commit = true) { putBoolean(SETTINGS_SHOW_REDACTED_KEY, shouldShow) }
}
/** /**
* Tells if the help on room list should be shown. * Tells if the help on room list should be shown.
* *

View File

@ -145,8 +145,28 @@
android:title="@string/dev_tools_menu_hidden_events" android:title="@string/dev_tools_menu_hidden_events"
android:visible="false" android:visible="false"
app:showAsAction="never" app:showAsAction="never"
android:checkable="true" android:checkable="true" />
android:checked="false" />
<item
android:id="@+id/dev_event_visibilities"
android:title="@string/dev_tools_menu_event_visibilities"
android:visible="false"
tools:visible="true"
app:showAsAction="never">
<menu>
<group android:checkableBehavior="all">
<item
android:id="@+id/dev_membership_changes"
android:title="@string/dev_tools_menu_membership_changes" />
<item
android:id="@+id/dev_display_name_changes"
android:title="@string/dev_tools_menu_display_name_changes" />
<item
android:id="@+id/dev_redacted"
android:title="@string/dev_tools_menu_redacted" />
</group>
</menu>
</item>
<item <item
android:id="@+id/menu_thread_timeline_view_in_room" android:id="@+id/menu_thread_timeline_view_in_room"

View File

@ -200,5 +200,9 @@
<string name="freeform_reaction_summary">Free-form reaction</string> <string name="freeform_reaction_summary">Free-form reaction</string>
<string name="dev_tools_menu_hidden_events">Hidden events</string> <string name="dev_tools_menu_hidden_events">Hidden events</string>
<string name="dev_tools_menu_event_visibilities">Event visibilities</string>
<string name="dev_tools_menu_membership_changes">Membership changes</string>
<string name="dev_tools_menu_display_name_changes">Account events</string>
<string name="dev_tools_menu_redacted">Deleted messages</string>
</resources> </resources>