mirror of https://git.sr.ht/~oppen/ariane
tls prefs wip
This commit is contained in:
parent
63081b2cf9
commit
6c7f6d4b19
|
@ -41,19 +41,32 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean {
|
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean {
|
||||||
|
if(preference is SwitchPreferenceCompat && newValue is Boolean && newValue == true) {
|
||||||
preference?.key?.let{ key ->
|
preference.key?.let { key ->
|
||||||
if(key.startsWith("tls_")){
|
if (key.startsWith("tls_")) {
|
||||||
protocols.forEach {protocol ->
|
protocols.forEach { protocol ->
|
||||||
val tlsSwitchKey = "tls_${protocol.toLowerCase(Locale.getDefault())}"
|
val tlsSwitchKey = "tls_${protocol.toLowerCase(Locale.getDefault())}"
|
||||||
if(tlsSwitchKey != key){
|
if (tlsSwitchKey != key) {
|
||||||
val otherTLSSwitch = preferenceScreen.findPreference<SwitchPreferenceCompat>(tlsSwitchKey)
|
val otherTLSSwitch =
|
||||||
otherTLSSwitch?.isChecked = false
|
preferenceScreen.findPreference<SwitchPreferenceCompat>(tlsSwitchKey)
|
||||||
|
otherTLSSwitch?.isChecked = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTLSProtocol(preference.title.toString())
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setTLSProtocol(protocol: String){
|
||||||
|
preferenceManager.sharedPreferences.edit().putString(
|
||||||
|
"tls_protocol",
|
||||||
|
protocol
|
||||||
|
).apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue