Fix serializing tls
This commit is contained in:
parent
c11662b78c
commit
b561ebcacb
1 changed files with 7 additions and 7 deletions
|
@ -44,19 +44,19 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
|
||||||
private val loglevel by lazy { findPreference<ListPreference>("loglevel") }
|
private val loglevel by lazy { findPreference<ListPreference>("loglevel") }
|
||||||
|
|
||||||
private fun readMode(value: String = mode.value) = when (value) {
|
private fun readMode(value: String = mode.value) = when (value) {
|
||||||
"websocket-http" -> Pair(null, null)
|
"websocket-http" -> Pair(null, false)
|
||||||
"websocket-tls" -> Pair(null, "")
|
"websocket-tls" -> Pair(null, true)
|
||||||
"quic-tls" -> Pair("quic", null)
|
"quic-tls" -> Pair("quic", false)
|
||||||
else -> {
|
else -> {
|
||||||
check(false)
|
check(false)
|
||||||
Pair(null, null)
|
Pair(null, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val options get() = PluginOptions().apply {
|
val options get() = PluginOptions().apply {
|
||||||
val (mode, tls) = readMode()
|
val (mode, tls) = readMode()
|
||||||
putWithDefault("mode", mode)
|
putWithDefault("mode", mode)
|
||||||
putWithDefault("tls", tls)
|
if (tls) this["tls"] = null
|
||||||
putWithDefault("host", host.text, "cloudfront.com")
|
putWithDefault("host", host.text, "cloudfront.com")
|
||||||
putWithDefault("path", path.text, "/")
|
putWithDefault("path", path.text, "/")
|
||||||
putWithDefault("certRaw", certRaw.text?.replace("\n", ""), "")
|
putWithDefault("certRaw", certRaw.text?.replace("\n", ""), "")
|
||||||
|
@ -66,7 +66,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
|
||||||
fun onInitializePluginOptions(options: PluginOptions) {
|
fun onInitializePluginOptions(options: PluginOptions) {
|
||||||
mode.value = when {
|
mode.value = when {
|
||||||
options["mode"] ?: "websocket" == "quic" -> "quic-tls"
|
options["mode"] ?: "websocket" == "quic" -> "quic-tls"
|
||||||
options["tls"] != null -> "websocket-tls"
|
"tls" in options -> "websocket-tls"
|
||||||
else -> "websocket-http"
|
else -> "websocket-http"
|
||||||
}.also { onPreferenceChange(null, it) }
|
}.also { onPreferenceChange(null, it) }
|
||||||
host.text = options["host"] ?: "cloudfront.com"
|
host.text = options["host"] ?: "cloudfront.com"
|
||||||
|
@ -83,7 +83,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
|
||||||
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean {
|
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean {
|
||||||
val (mode, tls) = readMode(newValue as String)
|
val (mode, tls) = readMode(newValue as String)
|
||||||
path.isEnabled = mode == null
|
path.isEnabled = mode == null
|
||||||
certRaw.isEnabled = mode != null || tls != null
|
certRaw.isEnabled = mode != null || tls
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue