Make loglevel configurable
This commit is contained in:
parent
afd51b4959
commit
6ceb5dab20
3 changed files with 20 additions and 0 deletions
|
@ -41,6 +41,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
|
|||
private val host by lazy { findPreference<EditTextPreference>("host") }
|
||||
private val path by lazy { findPreference<EditTextPreference>("path") }
|
||||
private val certRaw by lazy { findPreference<EditTextPreference>("certRaw") }
|
||||
private val loglevel by lazy { findPreference<ListPreference>("loglevel") }
|
||||
|
||||
private fun readMode(value: String = mode.value) = when (value) {
|
||||
"websocket-http" -> Pair(null, null)
|
||||
|
@ -59,6 +60,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
|
|||
putWithDefault("host", host.text, "cloudfront.com")
|
||||
putWithDefault("path", path.text, "/")
|
||||
putWithDefault("certRaw", certRaw.text.replace("\n", ""), "")
|
||||
putWithDefault("loglevel", loglevel.value, "warning")
|
||||
}
|
||||
|
||||
fun onInitializePluginOptions(options: PluginOptions) {
|
||||
|
@ -70,6 +72,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
|
|||
host.text = options["host"] ?: "cloudfront.com"
|
||||
path.text = options["path"] ?: "/"
|
||||
certRaw.text = options["certRaw"]
|
||||
loglevel.value = options["loglevel"] ?: "warning"
|
||||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
|
|
|
@ -5,4 +5,11 @@
|
|||
<item>websocket-tls</item>
|
||||
<item>quic-tls</item>
|
||||
</string-array>
|
||||
<string-array name="loglevels">
|
||||
<item>debug</item>
|
||||
<item>info</item>
|
||||
<item>warning</item>
|
||||
<item>error</item>
|
||||
<item>none</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
|
|
@ -22,4 +22,14 @@
|
|||
app:persistent="false"
|
||||
app:title="Certificate for TLS verification"
|
||||
app:useSimpleSummaryProvider="true"/>
|
||||
<PreferenceCategory
|
||||
app:title="Debug">
|
||||
<com.takisoft.preferencex.SimpleMenuPreference
|
||||
app:key="loglevel"
|
||||
app:persistent="false"
|
||||
app:entries="@array/loglevels"
|
||||
app:entryValues="@array/loglevels"
|
||||
app:title="Logcat level"
|
||||
app:useSimpleSummaryProvider="true"/>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
Loading…
Reference in a new issue