@@ -44,19 +44,19 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
4444 private val loglevel by lazy { findPreference<ListPreference >(" loglevel" ) }
4545
4646 private fun readMode (value : String = mode.value) = when (value) {
47- " websocket-http" -> Pair (null , null )
48- " websocket-tls" -> Pair (null , " " )
49- " quic-tls" -> Pair (" quic" , null )
47+ " websocket-http" -> Pair (null , false )
48+ " websocket-tls" -> Pair (null , true )
49+ " quic-tls" -> Pair (" quic" , false )
5050 else -> {
5151 check(false )
52- Pair (null , null )
52+ Pair (null , false )
5353 }
5454 }
5555
5656 val options get() = PluginOptions ().apply {
5757 val (mode, tls) = readMode()
5858 putWithDefault(" mode" , mode)
59- putWithDefault( " tls" , tls)
59+ if (tls) this [ " tls" ] = null
6060 putWithDefault(" host" , host.text, " cloudfront.com" )
6161 putWithDefault(" path" , path.text, " /" )
6262 putWithDefault(" certRaw" , certRaw.text?.replace(" \n " , " " ), " " )
@@ -66,7 +66,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
6666 fun onInitializePluginOptions (options : PluginOptions ) {
6767 mode.value = when {
6868 options[" mode" ] ? : " websocket" == " quic" -> " quic-tls"
69- options[ " tls" ] != null -> " websocket-tls"
69+ " tls" in options -> " websocket-tls"
7070 else -> " websocket-http"
7171 }.also { onPreferenceChange(null , it) }
7272 host.text = options[" host" ] ? : " cloudfront.com"
@@ -83,7 +83,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
8383 override fun onPreferenceChange (preference : Preference ? , newValue : Any? ): Boolean {
8484 val (mode, tls) = readMode(newValue as String )
8585 path.isEnabled = mode == null
86- certRaw.isEnabled = mode != null || tls != null
86+ certRaw.isEnabled = mode != null || tls
8787 return true
8888 }
8989
0 commit comments