#52: Properly handle content filter selection and state.

This commit is contained in:
Antoine POPINEAU 2020-09-03 22:53:06 +02:00
parent ce8d956cee
commit e60814d28f
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
1 changed files with 19 additions and 2 deletions

View File

@ -156,7 +156,11 @@ class MainActivity : AppCompatActivity() {
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.toolbar, menu)
menu?.findItem(R.id.nav_all_music)?.isChecked = Settings.getScopes().contains("all")
menu?.findItem(R.id.nav_all_music)?.let {
it.isChecked = Settings.getScopes().contains("all")
it.isEnabled = !it.isChecked
}
menu?.findItem(R.id.nav_my_music)?.isChecked = Settings.getScopes().contains("me")
menu?.findItem(R.id.nav_followed)?.isChecked = Settings.getScopes().contains("subscribed")
@ -197,6 +201,7 @@ class MainActivity : AppCompatActivity() {
R.id.nav_followed -> "subscribed"
else -> {
menu.findItem(R.id.nav_all_music).isEnabled = false
menu.findItem(R.id.nav_my_music).isChecked = false
menu.findItem(R.id.nav_followed).isChecked = false
@ -207,7 +212,10 @@ class MainActivity : AppCompatActivity() {
}
}
menu.findItem(R.id.nav_all_music).isChecked = false
menu.findItem(R.id.nav_all_music).let {
it.isChecked = false
it.isEnabled = true
}
scopes.remove("all")
@ -216,6 +224,15 @@ class MainActivity : AppCompatActivity() {
false -> scopes.remove(new)
}
if (scopes.isEmpty()) {
menu.findItem(R.id.nav_all_music).let {
it.isChecked = true
it.isEnabled = false
}
scopes.add("all")
}
PowerPreference.getDefaultFile().set("scope", scopes.joinToString(","))
EventBus.send(Event.ListingsChanged)