[新增] 新增更多伴生分组:已读、未读、在读等

This commit is contained in:
HapeLee committed 2025-12-09 01:08:04 +08:00
1 parent 3385197d6a
commit 2546a8aa5d
9 files changed
+107 -8

No files matched your search

@@ -169,12 +169,47 @@ abstract class AppDatabase : RoomDatabase() {
""".trimIndent() """.trimIndent()
db.execSQL(insertBookGroupLocalSql) db.execSQL(insertBookGroupLocalSql)
@Language("sql") @Language("sql")
val insertBookGroupTextSql = """
insert into book_groups(groupId, groupName, 'order', show)
select ${BookGroup.IdText}, '小说', -26, 1
where not exists (select * from book_groups where groupId = ${BookGroup.IdText})
""".trimIndent()
db.execSQL(insertBookGroupTextSql)
@Language("sql")
val insertBookGroupMangaSql = """
insert into book_groups(groupId, groupName, 'order', show)
select ${BookGroup.IdManga}, '漫画', -25, 1
where not exists (select * from book_groups where groupId = ${BookGroup.IdManga})
""".trimIndent()
db.execSQL(insertBookGroupMangaSql)
@Language("sql")
val insertBookGroupMusicSql = """ val insertBookGroupMusicSql = """
insert into book_groups(groupId, groupName, 'order', show) insert into book_groups(groupId, groupName, 'order', show)
select ${BookGroup.IdAudio}, '音频', -8, 1 select ${BookGroup.IdAudio}, '音频', -8, 1
where not exists (select * from book_groups where groupId = ${BookGroup.IdAudio}) where not exists (select * from book_groups where groupId = ${BookGroup.IdAudio})
""".trimIndent() """.trimIndent()
db.execSQL(insertBookGroupMusicSql) db.execSQL(insertBookGroupMusicSql)
Language("sql")
val insertGroupReading = """
insert into book_groups(groupId, groupName, 'order', show)
select ${BookGroup.IdReading}, '在读', -30, 1
where not exists (select * from book_groups where groupId = ${BookGroup.IdReading})
""".trimIndent()
db.execSQL(insertGroupReading)
@Language("sql")
val insertGroupUnread = """
insert into book_groups(groupId, groupName, 'order', show)
select ${BookGroup.IdUnread}, '未读', -29, 1
where not exists (select * from book_groups where groupId = ${BookGroup.IdUnread})
""".trimIndent()
db.execSQL(insertGroupUnread)
@Language("sql")
val insertGroupReadFinished = """
insert into book_groups(groupId, groupName, 'order', show)
select ${BookGroup.IdReadFinished}, '已读', -28, 1
where not exists (select * from book_groups where groupId = ${BookGroup.IdReadFinished})
""".trimIndent()
db.execSQL(insertGroupReadFinished)
@Language("sql") @Language("sql")
val insertBookGroupNetNoneGroupSql = """ val insertBookGroupNetNoneGroupSql = """
insert into book_groups(groupId, groupName, 'order', show) insert into book_groups(groupId, groupName, 'order', show)
@@ -26,7 +26,12 @@ interface BookDao {
BookGroup.IdAudio -> flowAudio() BookGroup.IdAudio -> flowAudio()
BookGroup.IdNetNone -> flowNetNoGroup() BookGroup.IdNetNone -> flowNetNoGroup()
BookGroup.IdLocalNone -> flowLocalNoGroup() BookGroup.IdLocalNone -> flowLocalNoGroup()
BookGroup.IdManga -> flowManga()
BookGroup.IdText -> flowText()
BookGroup.IdError -> flowUpdateError() BookGroup.IdError -> flowUpdateError()
BookGroup.IdUnread -> flowUnread()
BookGroup.IdReading -> flowReading()
BookGroup.IdReadFinished -> flowReadFinished()
else -> flowByUserGroup(groupId) else -> flowByUserGroup(groupId)
}.map { list -> }.map { list ->
list.filterNot { it.isNotShelf } list.filterNot { it.isNotShelf }
@@ -77,6 +82,21 @@ interface BookDao {
@Query("SELECT * FROM books where type & ${BookType.updateError} > 0 order by durChapterTime desc") @Query("SELECT * FROM books where type & ${BookType.updateError} > 0 order by durChapterTime desc")
fun flowUpdateError(): Flow<List<Book>> fun flowUpdateError(): Flow<List<Book>>
@Query("""SELECT * FROM books WHERE durChapterIndex = 0 AND durChapterPos = 0""")
fun flowUnread(): Flow<List<Book>>
@Query("""SELECT * FROM books WHERE totalChapterNum > 0 AND durChapterIndex >= totalChapterNum - 1""")
fun flowReadFinished(): Flow<List<Book>>
@Query("""SELECT * FROM books WHERE totalChapterNum > 0 AND durChapterIndex > 0 AND durChapterIndex < totalChapterNum - 1""")
fun flowReading(): Flow<List<Book>>
@Query("SELECT * FROM books WHERE type & ${BookType.image} > 0")
fun flowManga(): Flow<List<Book>>
@Query("SELECT * FROM books WHERE type & ${BookType.text} > 0")
fun flowText(): Flow<List<Book>>
@Query("SELECT * FROM books WHERE (`group` & :group) > 0") @Query("SELECT * FROM books WHERE (`group` & :group) > 0")
fun getBooksByGroup(group: Long): List<Book> fun getBooksByGroup(group: Long): List<Book>
@@ -30,11 +30,31 @@ interface BookGroupDao {
where show > 0 where show > 0
and ( and (
(groupId >= 0 and exists (select 1 from books where `group` & book_groups.groupId > 0)) (groupId >= 0 and exists (select 1 from books where `group` & book_groups.groupId > 0))
or groupId = -1 or groupId = ${BookGroup.IdAll}
or (groupId = -2 and exists (select 1 from books where type & ${BookType.local} > 0)) or (groupId = ${BookGroup.IdLocal} and exists (select 1 from books where type & ${BookType.local} > 0))
or (groupId = -3 and exists (select 1 from books where type & ${BookType.audio} > 0)) or (groupId = ${BookGroup.IdAudio} and exists (select 1 from books where type & ${BookType.audio} > 0))
or (groupId = -11 and exists (select 1 from books where type & ${BookType.updateError} > 0)) or (groupId = ${BookGroup.IdManga} and exists (select 1 FROM books where type & ${BookType.image} > 0))
or (groupId = -4 or (groupId = ${BookGroup.IdText} and exists (select 1 FROM books where type & ${BookType.text} > 0))
or (groupId = ${BookGroup.IdReading} and exists (
SELECT 1 FROM books
WHERE totalChapterNum > 0
AND durChapterIndex > 0
AND durChapterIndex < totalChapterNum - 1
))
or (groupId = ${BookGroup.IdUnread} and exists (
SELECT 1 FROM books
WHERE durChapterIndex = 0
AND durChapterPos = 0
))
or (groupId = ${BookGroup.IdReadFinished} and exists (
SELECT 1 FROM books
WHERE totalChapterNum > 0
AND durChapterIndex >= totalChapterNum - 1
))
or (groupId = ${BookGroup.IdError} and exists (select 1 from books where type & ${BookType.updateError} > 0))
or (groupId = ${BookGroup.IdNetNone}
and exists ( and exists (
select 1 from books select 1 from books
where type & ${BookType.audio} = 0 where type & ${BookType.audio} = 0
@@ -42,7 +62,7 @@ interface BookGroupDao {
and const.sumGroupId & `group` = 0 and const.sumGroupId & `group` = 0
) )
) )
or (groupId = -5 or (groupId = ${BookGroup.IdLocalNone}
and exists ( and exists (
select 1 from books select 1 from books
where type & ${BookType.audio} = 0 where type & ${BookType.audio} = 0
@@ -33,7 +33,12 @@ data class BookGroup(
const val IdAudio = -3L const val IdAudio = -3L
const val IdNetNone = -4L const val IdNetNone = -4L
const val IdLocalNone = -5L const val IdLocalNone = -5L
const val IdManga = -7L
const val IdText = -8L
const val IdError = -11L const val IdError = -11L
const val IdReading = -20L
const val IdUnread = -21L
const val IdReadFinished = -22L
} }
data class GroupNameInfo( data class GroupNameInfo(
@@ -48,7 +53,12 @@ data class BookGroup(
IdLocal -> GroupNameInfo(groupName, context.getString(R.string.local)) IdLocal -> GroupNameInfo(groupName, context.getString(R.string.local))
IdNetNone -> GroupNameInfo(groupName, context.getString(R.string.net_no_group)) IdNetNone -> GroupNameInfo(groupName, context.getString(R.string.net_no_group))
IdLocalNone -> GroupNameInfo(groupName, context.getString(R.string.local_no_group)) IdLocalNone -> GroupNameInfo(groupName, context.getString(R.string.local_no_group))
IdManga -> GroupNameInfo(groupName, context.getString(R.string.manga))
IdText -> GroupNameInfo(groupName, context.getString(R.string.noval))
IdError -> GroupNameInfo(groupName, context.getString(R.string.update_book_fail)) IdError -> GroupNameInfo(groupName, context.getString(R.string.update_book_fail))
IdReading -> GroupNameInfo(groupName, context.getString(R.string.is_reading))
IdUnread -> GroupNameInfo(groupName, context.getString(R.string.is_unread))
IdReadFinished -> GroupNameInfo(groupName, context.getString(R.string.is_read_finished))
else -> GroupNameInfo(groupName) else -> GroupNameInfo(groupName)
} }
} }
@@ -3,6 +3,6 @@
<gradient <gradient
android:angle="90" android:angle="90"
android:endColor="#00000000" android:endColor="#00000000"
android:startColor="#CC000000" android:startColor="#80000000"
android:type="linear" /> android:type="linear" />
</shape> </shape>
@@ -129,6 +129,10 @@
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="12sp" android:textSize="12sp"
android:textStyle="bold" android:textStyle="bold"
android:shadowColor="#80000000"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="4.0"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" /> app:layout_constraintEnd_toEndOf="parent" />
+5
View File
@@ -1351,4 +1351,9 @@
<string name="read_change_all">换源按钮默认弹出整书换源</string> <string name="read_change_all">换源按钮默认弹出整书换源</string>
<string name="read_change_all_s">反之则默认弹出单章换源</string> <string name="read_change_all_s">反之则默认弹出单章换源</string>
<string name="show_tip">显示书籍类型</string> <string name="show_tip">显示书籍类型</string>
<string name="is_reading">在读</string>
<string name="is_unread">未读</string>
<string name="is_read_finished">已读</string>
<string name="manga">漫画</string>
<string name="noval">小说</string>
</resources> </resources>
+5
View File
@@ -1354,4 +1354,9 @@
<string name="read_change_all">换源按钮默认弹出整书换源</string> <string name="read_change_all">换源按钮默认弹出整书换源</string>
<string name="read_change_all_s">反之则默认弹出单章换源</string> <string name="read_change_all_s">反之则默认弹出单章换源</string>
<string name="show_tip">显示书籍类型</string> <string name="show_tip">显示书籍类型</string>
<string name="is_reading">在读</string>
<string name="is_unread">未读</string>
<string name="is_read_finished">已读</string>
<string name="manga">漫画</string>
<string name="noval">小说</string>
</resources> </resources>
+1 -1
View File
@@ -1,5 +1,5 @@
VERSION_MAJOR=3 VERSION_MAJOR=3
VERSION_MINOR=26 VERSION_MINOR=26
VERSION_PATCH=4 VERSION_PATCH=5
VERSION_SUFFIX=0 VERSION_SUFFIX=0
# 1 = Pre, 0 = Release # 1 = Pre, 0 = Release