mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-21 21:54:28 +03:00
Group SC debug prefs
Change-Id: I96ffa490c11f64da1648afe3ef545a911a350389
This commit is contained in:
parent
04c1811e50
commit
e02a3adcdf
3 changed files with 29 additions and 8 deletions
library/ui-strings/src/main/res/values
vector/src/main
java/im/vector/app/features/settings
res/xml
|
@ -158,6 +158,8 @@
|
||||||
<!-- SC debugging -->
|
<!-- SC debugging -->
|
||||||
<string name="settings_sc_debugging">Schildi-debugging</string>
|
<string name="settings_sc_debugging">Schildi-debugging</string>
|
||||||
<string name="settings_sc_debugging_summary">Enable additional logs or debugging features</string>
|
<string name="settings_sc_debugging_summary">Enable additional logs or debugging features</string>
|
||||||
|
<string name="settings_sc_debugging_category_logs">Additional logs</string>
|
||||||
|
<string name="settings_sc_debugging_category_visuals">Visual debugging info</string>
|
||||||
<string name="settings_sc_dbg_read_marker">Read marker debugging</string>
|
<string name="settings_sc_dbg_read_marker">Read marker debugging</string>
|
||||||
<string name="settings_sc_dbg_timeline_chunks">Timeline consistency debugging</string>
|
<string name="settings_sc_dbg_timeline_chunks">Timeline consistency debugging</string>
|
||||||
<string name="settings_sc_dbg_show_display_index">Show displayIndex in timeline</string>
|
<string name="settings_sc_dbg_show_display_index">Show displayIndex in timeline</string>
|
||||||
|
|
|
@ -2,6 +2,7 @@ package im.vector.app.features.settings
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
|
import androidx.preference.PreferenceGroup
|
||||||
import de.spiritcroc.matrixsdk.util.DbgUtil
|
import de.spiritcroc.matrixsdk.util.DbgUtil
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.preference.VectorSwitchPreference
|
import im.vector.app.core.preference.VectorSwitchPreference
|
||||||
|
@ -14,31 +15,44 @@ class VectorSettingsScDebuggingFragment @Inject constructor(
|
||||||
override var titleRes = R.string.settings_sc_debugging
|
override var titleRes = R.string.settings_sc_debugging
|
||||||
override val preferenceXmlRes = R.xml.vector_settings_sc_debugging
|
override val preferenceXmlRes = R.xml.vector_settings_sc_debugging
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val SC_DEBUGGING_CATEGORY_LOGS = "SC_DEBUGGING_CATEGORY_LOGS"
|
||||||
|
const val SC_DEBUGGING_CATEGORY_VISUALS = "SC_DEBUGGING_CATEGORY_VISUALS"
|
||||||
|
}
|
||||||
|
|
||||||
data class DbgPref(val key: String, @StringRes val stringRes: Int)
|
data class DbgPref(val key: String, @StringRes val stringRes: Int)
|
||||||
val dbgPrefs = arrayOf(
|
private val dbgLoggingPrefs = arrayOf(
|
||||||
DbgPref(DbgUtil.DBG_TIMELINE_CHUNKS, R.string.settings_sc_dbg_timeline_chunks),
|
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_READ_MARKER, R.string.settings_sc_dbg_read_marker),
|
||||||
DbgPref(DbgUtil.DBG_SHOW_READ_TRACKING, R.string.settings_sc_dbg_show_read_tracking),
|
|
||||||
DbgPref(DbgUtil.DBG_READ_RECEIPTS, R.string.settings_sc_dbg_read_receipts),
|
DbgPref(DbgUtil.DBG_READ_RECEIPTS, R.string.settings_sc_dbg_read_receipts),
|
||||||
DbgPref(DbgUtil.DBG_VIEW_PAGER, R.string.settings_sc_dbg_view_pager),
|
DbgPref(DbgUtil.DBG_VIEW_PAGER, R.string.settings_sc_dbg_view_pager),
|
||||||
|
)
|
||||||
|
private val dbgVisualsPrefs = arrayOf(
|
||||||
|
DbgPref(DbgUtil.DBG_SHOW_DISPLAY_INDEX, R.string.settings_sc_dbg_show_display_index),
|
||||||
|
DbgPref(DbgUtil.DBG_SHOW_READ_TRACKING, R.string.settings_sc_dbg_show_read_tracking),
|
||||||
DbgPref(DbgUtil.DBG_VIEW_PAGER_VISUALS, R.string.settings_sc_dbg_view_pager_visuals),
|
DbgPref(DbgUtil.DBG_VIEW_PAGER_VISUALS, R.string.settings_sc_dbg_view_pager_visuals),
|
||||||
)
|
)
|
||||||
|
val dbgPrefs = dbgLoggingPrefs + dbgVisualsPrefs
|
||||||
|
|
||||||
override fun bindPref() {
|
private fun addScDbgPrefs(prefs: Array<DbgPref>, group: PreferenceGroup) {
|
||||||
dbgPrefs.forEach { dbgPref ->
|
prefs.forEach { dbgPref ->
|
||||||
var pref: VectorSwitchPreference? = findPreference(dbgPref.key)
|
var pref: VectorSwitchPreference? = findPreference(dbgPref.key)
|
||||||
if (pref == null) {
|
if (pref == null) {
|
||||||
pref = VectorSwitchPreference(requireContext())
|
pref = VectorSwitchPreference(requireContext())
|
||||||
pref.key = dbgPref.key
|
pref.key = dbgPref.key
|
||||||
pref.title = getString(dbgPref.stringRes)
|
pref.title = getString(dbgPref.stringRes)
|
||||||
preferenceScreen.addPreference(pref)
|
group.addPreference(pref)
|
||||||
}
|
}
|
||||||
pref.isChecked = DbgUtil.isDbgEnabled(pref.key)
|
pref.isChecked = DbgUtil.isDbgEnabled(pref.key)
|
||||||
pref.onPreferenceChangeListener = preferenceChangeListener
|
pref.onPreferenceChangeListener = preferenceChangeListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun bindPref() {
|
||||||
|
findPreference<PreferenceGroup>(SC_DEBUGGING_CATEGORY_LOGS)?.let { addScDbgPrefs(dbgLoggingPrefs, it) }
|
||||||
|
findPreference<PreferenceGroup>(SC_DEBUGGING_CATEGORY_VISUALS)?.let { addScDbgPrefs(dbgVisualsPrefs, it) }
|
||||||
|
}
|
||||||
|
|
||||||
private val preferenceChangeListener = Preference.OnPreferenceChangeListener { preference, newValue ->
|
private val preferenceChangeListener = Preference.OnPreferenceChangeListener { preference, newValue ->
|
||||||
if (newValue is Boolean && dbgPrefs.any { preference.key == it.key }) {
|
if (newValue is Boolean && dbgPrefs.any { preference.key == it.key }) {
|
||||||
DbgUtil.onPreferenceChanged(requireContext(), preference.key as String, newValue)
|
DbgUtil.onPreferenceChanged(requireContext(), preference.key as String, newValue)
|
||||||
|
|
|
@ -3,7 +3,12 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorPreference
|
<im.vector.app.core.preference.VectorPreferenceCategory
|
||||||
android:summary="@string/settings_sc_debugging_summary" />
|
android:key="SC_DEBUGGING_CATEGORY_LOGS"
|
||||||
|
android:title="@string/settings_sc_debugging_category_logs" />
|
||||||
|
|
||||||
|
<im.vector.app.core.preference.VectorPreferenceCategory
|
||||||
|
android:key="SC_DEBUGGING_CATEGORY_VISUALS"
|
||||||
|
android:title="@string/settings_sc_debugging_category_visuals" />
|
||||||
|
|
||||||
</androidx.preference.PreferenceScreen>
|
</androidx.preference.PreferenceScreen>
|
||||||
|
|
Loading…
Add table
Reference in a new issue