Commit 84e26c4b authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Disable the search icon if the dns rules are not enabled

parent dd6e005a
......@@ -534,14 +534,17 @@ class DnsRuleFragment : Fragment() {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.menu_dnsrule, menu)
val switch = menu.findItem(R.id.rulesEnabled)?.actionView?.findViewById<Switch>(R.id.actionbarSwitch)
val search = menu.findItem(R.id.search)
switch?.isChecked = getPreferences().dnsRulesEnabled.also {
overlay.visibility = if(it) View.GONE else View.VISIBLE
search.isEnabled = it
}
switch?.setOnCheckedChangeListener { _, isChecked ->
getPreferences().dnsRulesEnabled = isChecked
overlay.visibility = if(isChecked) View.GONE else View.VISIBLE
search.isEnabled = isChecked
}
menu.findItem(R.id.search).setOnMenuItemClickListener {
search?.setOnMenuItemClickListener {
DnsRuleSearchDialog(requireContext()).show()
true
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment