Disable usfExpose when disabling usfBackground
This commit is contained in:
parent
e9b67bd9c4
commit
6c0e20c68e
@ -177,25 +177,32 @@ class SettingsActivity : BaseActivity() {
|
||||
val switchExpose = findPreference<SwitchPreference>("usf_expose")!!
|
||||
val switchSafWrite = findPreference<SwitchPreference>("usf_saf_write")!!
|
||||
|
||||
fun updateView(usfOpen: Boolean? = null, usfBackground: Boolean? = null, usfExpose: Boolean? = null) {
|
||||
val usfBackground = usfBackground ?: switchBackground.isChecked
|
||||
switchKeepOpen.isEnabled = usfBackground
|
||||
switchExpose.isEnabled = usfBackground
|
||||
switchSafWrite.isEnabled = usfOpen ?: switchExternalOpen.isChecked || (usfBackground && usfExpose ?: switchExpose.isChecked)
|
||||
fun onUsfBackgroundChanged(usfBackground: Boolean) {
|
||||
fun updateSwitchPreference(switch: SwitchPreference) = with (switch) {
|
||||
isChecked = isChecked && usfBackground
|
||||
isEnabled = usfBackground
|
||||
onPreferenceChangeListener?.onPreferenceChange(switch, isChecked)
|
||||
}
|
||||
updateSwitchPreference(switchKeepOpen)
|
||||
updateSwitchPreference(switchExpose)
|
||||
}
|
||||
onUsfBackgroundChanged(switchBackground.isChecked)
|
||||
|
||||
fun updateSafWrite(usfOpen: Boolean? = null, usfExpose: Boolean? = null) {
|
||||
switchSafWrite.isEnabled = usfOpen ?: switchExternalOpen.isChecked || usfExpose ?: switchExpose.isChecked
|
||||
}
|
||||
updateSafWrite()
|
||||
|
||||
updateView()
|
||||
switchBackground.setOnPreferenceChangeListener { _, checked ->
|
||||
updateView(usfBackground = checked as Boolean)
|
||||
switchKeepOpen.isChecked = switchKeepOpen.isChecked && checked
|
||||
onUsfBackgroundChanged(checked as Boolean)
|
||||
true
|
||||
}
|
||||
switchExternalOpen.setOnPreferenceChangeListener { _, checked ->
|
||||
updateView(usfOpen = checked as Boolean)
|
||||
updateSafWrite(usfOpen = checked as Boolean)
|
||||
true
|
||||
}
|
||||
switchExpose.setOnPreferenceChangeListener { _, checked ->
|
||||
updateView(usfExpose = checked as Boolean)
|
||||
updateSafWrite(usfExpose = checked as Boolean)
|
||||
VolumeProvider.notifyRootsChanged(requireContext())
|
||||
true
|
||||
}
|
||||
|
@ -258,9 +258,8 @@ class SelectPathFragment: Fragment() {
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show()
|
||||
} else {
|
||||
binding.editVolumeName.setText(path)
|
||||
inputViewModel.showEditText = true
|
||||
updateUi(path)
|
||||
binding.editVolumeName.setText(path)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user