diff --git a/app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt b/app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt index c2d1b80ee..ad2b25706 100644 --- a/app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt @@ -25,6 +25,9 @@ interface RssSourceDao { @Query("SELECT * FROM rssSources where sourceName like :key or sourceUrl like :key or sourceGroup like :key order by customOrder") fun liveSearch(key: String): LiveData> + @Query("SELECT * FROM rssSources where sourceGroup like :key order by customOrder") + fun liveGroupSearch(key: String): LiveData> + @Query("SELECT * FROM rssSources where enabled = 1 and (sourceName like '%'||:searchKey||'%' or sourceGroup like '%'||:searchKey||'%' or sourceUrl like '%'||:searchKey||'%') order by customOrder") fun liveEnabled(searchKey: String): LiveData> diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index 717278bd8..0f7d10e8d 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -95,7 +95,7 @@ class RssSourceActivity : VMBaseActivity showHelp() else -> if (item.groupId == R.id.source_group) { binding.titleBar.findViewById(R.id.search_view) - .setQuery(item.title, true) + .setQuery("group:${item.title}", true) } } return super.onCompatOptionsItemSelected(item) @@ -197,13 +197,20 @@ class RssSourceActivity : VMBaseActivity { + App.db.rssSourceDao.liveAll() + } + searchKey.startsWith("group:") -> { + val key = searchKey.substringAfter("group:") + App.db.rssSourceDao.liveGroupSearch("%$key%") + } + else -> { + App.db.rssSourceDao.liveSearch("%$searchKey%") + } } sourceLiveData?.observe(this, { adapter.setItems(it, adapter.diffItemCallback)