forked from hardcoresushi/DroidFS
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 switchExpose = findPreference<SwitchPreference>("usf_expose")!!
|
||||||
val switchSafWrite = findPreference<SwitchPreference>("usf_saf_write")!!
|
val switchSafWrite = findPreference<SwitchPreference>("usf_saf_write")!!
|
||||||
|
|
||||||
fun updateView(usfOpen: Boolean? = null, usfBackground: Boolean? = null, usfExpose: Boolean? = null) {
|
fun onUsfBackgroundChanged(usfBackground: Boolean) {
|
||||||
val usfBackground = usfBackground ?: switchBackground.isChecked
|
fun updateSwitchPreference(switch: SwitchPreference) = with (switch) {
|
||||||
switchKeepOpen.isEnabled = usfBackground
|
isChecked = isChecked && usfBackground
|
||||||
switchExpose.isEnabled = usfBackground
|
isEnabled = usfBackground
|
||||||
switchSafWrite.isEnabled = usfOpen ?: switchExternalOpen.isChecked || (usfBackground && usfExpose ?: switchExpose.isChecked)
|
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 ->
|
switchBackground.setOnPreferenceChangeListener { _, checked ->
|
||||||
updateView(usfBackground = checked as Boolean)
|
onUsfBackgroundChanged(checked as Boolean)
|
||||||
switchKeepOpen.isChecked = switchKeepOpen.isChecked && checked
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
switchExternalOpen.setOnPreferenceChangeListener { _, checked ->
|
switchExternalOpen.setOnPreferenceChangeListener { _, checked ->
|
||||||
updateView(usfOpen = checked as Boolean)
|
updateSafWrite(usfOpen = checked as Boolean)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
switchExpose.setOnPreferenceChangeListener { _, checked ->
|
switchExpose.setOnPreferenceChangeListener { _, checked ->
|
||||||
updateView(usfExpose = checked as Boolean)
|
updateSafWrite(usfExpose = checked as Boolean)
|
||||||
VolumeProvider.notifyRootsChanged(requireContext())
|
VolumeProvider.notifyRootsChanged(requireContext())
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -258,9 +258,8 @@ class SelectPathFragment: Fragment() {
|
|||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.show()
|
.show()
|
||||||
} else {
|
} else {
|
||||||
binding.editVolumeName.setText(path)
|
|
||||||
inputViewModel.showEditText = true
|
inputViewModel.showEditText = true
|
||||||
updateUi(path)
|
binding.editVolumeName.setText(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user