diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index 3e35e1a02..91010e820 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -75,9 +75,9 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se else -> if (item.groupId == R.id.source_group) { item.isChecked = true if (item.title.toString() == getString(R.string.all_source)) { - putPrefString("sourceGroup", "") + putPrefString("searchGroup", "") } else { - putPrefString("sourceGroup", item.title.toString()) + putPrefString("searchGroup", item.title.toString()) } } } @@ -171,10 +171,17 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se } private fun upGroupMenu() { + val selectedGroup = getPrefString("searchGroup") ?: "" menu?.removeGroup(R.id.source_group) - menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, R.string.all_source) + var item = menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, R.string.all_source) + if (selectedGroup == "") { + item?.isChecked = true + } groups.map { - menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) + item = menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) + if (it == selectedGroup) { + item?.isChecked = true + } } menu?.setGroupCheckable(R.id.source_group, true, true) }