diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 6f278bf1a..b9a40744e 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -13,6 +13,7 @@ **2022/07/09** +* 书源添加未分组筛选 * 修复使用自建WebDav一些bug by 821938089 * 修复换源按钮长按只能生效一次的bug diff --git a/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt b/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt index 204083bfe..182023f72 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt @@ -53,6 +53,9 @@ interface BookSourceDao { @Query("select * from book_sources where loginUrl is not null and loginUrl != ''") fun flowLogin(): Flow> + @Query("select * from book_sources where bookSourceGroup is null or bookSourceGroup = '' or bookSourceGroup like '%未分组%'") + fun flowNoGroup(): Flow> + @Query( """select * from book_sources where enabledExplore = 1 diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 99fcf954a..6df26267a 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -181,6 +181,9 @@ class BookSourceActivity : VMBaseActivity { searchView.setQuery(getString(R.string.need_login), true) } + R.id.menu_group_null -> { + searchView.setQuery(getString(R.string.no_group), true) + } R.id.menu_help -> showHelp() } if (item.groupId == R.id.source_group) { @@ -229,6 +232,9 @@ class BookSourceActivity : VMBaseActivity { appDb.bookSourceDao.flowLogin() } + searchKey == getString(R.string.no_group) -> { + appDb.bookSourceDao.flowNoGroup() + } searchKey.startsWith("group:") -> { val key = searchKey.substringAfter("group:") appDb.bookSourceDao.flowGroupSearch(key) @@ -296,10 +302,15 @@ class BookSourceActivity : VMBaseActivity - groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex)) + it.forEach { groupStr -> + groupStr.splitNotBlank(AppPattern.splitGroupRegex).forEach { group -> + if (group != noGroupName) { + groups.add(group) + } + } } upGroupMenu() } diff --git a/app/src/main/res/menu/book_source.xml b/app/src/main/res/menu/book_source.xml index 679c237e4..f86342f30 100644 --- a/app/src/main/res/menu/book_source.xml +++ b/app/src/main/res/menu/book_source.xml @@ -79,6 +79,10 @@ android:id="@+id/menu_group_login" android:title="@string/need_login" /> + +