diff --git a/app/src/main/java/io/legado/app/data/AppDatabase.kt b/app/src/main/java/io/legado/app/data/AppDatabase.kt index ae3d074fe..ff6a5f640 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -169,12 +169,47 @@ abstract class AppDatabase : RoomDatabase() { """.trimIndent() db.execSQL(insertBookGroupLocalSql) @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 = """ insert into book_groups(groupId, groupName, 'order', show) select ${BookGroup.IdAudio}, '音频', -8, 1 where not exists (select * from book_groups where groupId = ${BookGroup.IdAudio}) """.trimIndent() 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") val insertBookGroupNetNoneGroupSql = """ insert into book_groups(groupId, groupName, 'order', show) diff --git a/app/src/main/java/io/legado/app/data/dao/BookDao.kt b/app/src/main/java/io/legado/app/data/dao/BookDao.kt index e2cec7bd3..088722b21 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookDao.kt @@ -26,7 +26,12 @@ interface BookDao { BookGroup.IdAudio -> flowAudio() BookGroup.IdNetNone -> flowNetNoGroup() BookGroup.IdLocalNone -> flowLocalNoGroup() + BookGroup.IdManga -> flowManga() + BookGroup.IdText -> flowText() BookGroup.IdError -> flowUpdateError() + BookGroup.IdUnread -> flowUnread() + BookGroup.IdReading -> flowReading() + BookGroup.IdReadFinished -> flowReadFinished() else -> flowByUserGroup(groupId) }.map { list -> list.filterNot { it.isNotShelf } @@ -77,6 +82,21 @@ interface BookDao { @Query("SELECT * FROM books where type & ${BookType.updateError} > 0 order by durChapterTime desc") fun flowUpdateError(): Flow> + @Query("""SELECT * FROM books WHERE durChapterIndex = 0 AND durChapterPos = 0""") + fun flowUnread(): Flow> + + @Query("""SELECT * FROM books WHERE totalChapterNum > 0 AND durChapterIndex >= totalChapterNum - 1""") + fun flowReadFinished(): Flow> + + @Query("""SELECT * FROM books WHERE totalChapterNum > 0 AND durChapterIndex > 0 AND durChapterIndex < totalChapterNum - 1""") + fun flowReading(): Flow> + + @Query("SELECT * FROM books WHERE type & ${BookType.image} > 0") + fun flowManga(): Flow> + + @Query("SELECT * FROM books WHERE type & ${BookType.text} > 0") + fun flowText(): Flow> + @Query("SELECT * FROM books WHERE (`group` & :group) > 0") fun getBooksByGroup(group: Long): List diff --git a/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt b/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt index 59c8937a6..1c96669de 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt @@ -25,33 +25,53 @@ interface BookGroupDao { @get:Query( """ - with const as (SELECT sum(groupId) sumGroupId FROM book_groups where groupId > 0) - SELECT book_groups.* FROM book_groups join const - where show > 0 - and ( - (groupId >= 0 and exists (select 1 from books where `group` & book_groups.groupId > 0)) - or groupId = -1 - or (groupId = -2 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 = -11 and exists (select 1 from books where type & ${BookType.updateError} > 0)) - or (groupId = -4 - and exists ( - select 1 from books - where type & ${BookType.audio} = 0 - and type & ${BookType.local} = 0 - and const.sumGroupId & `group` = 0 - ) - ) - or (groupId = -5 - and exists ( - select 1 from books - where type & ${BookType.audio} = 0 - and type & ${BookType.local} > 0 - and const.sumGroupId & `group` = 0 - ) + with const as (SELECT sum(groupId) sumGroupId FROM book_groups where groupId > 0) + SELECT book_groups.* FROM book_groups join const + where show > 0 + and ( + (groupId >= 0 and exists (select 1 from books where `group` & book_groups.groupId > 0)) + or groupId = ${BookGroup.IdAll} + or (groupId = ${BookGroup.IdLocal} and exists (select 1 from books where type & ${BookType.local} > 0)) + or (groupId = ${BookGroup.IdAudio} and exists (select 1 from books where type & ${BookType.audio} > 0)) + or (groupId = ${BookGroup.IdManga} and exists (select 1 FROM books where type & ${BookType.image} > 0)) + 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 ( + select 1 from books + where type & ${BookType.audio} = 0 + and type & ${BookType.local} = 0 + and const.sumGroupId & `group` = 0 ) ) - ORDER BY `order`""" + or (groupId = ${BookGroup.IdLocalNone} + and exists ( + select 1 from books + where type & ${BookType.audio} = 0 + and type & ${BookType.local} > 0 + and const.sumGroupId & `group` = 0 + ) + ) + ) + ORDER BY `order`""" ) val show: LiveData> diff --git a/app/src/main/java/io/legado/app/data/entities/BookGroup.kt b/app/src/main/java/io/legado/app/data/entities/BookGroup.kt index 37eb08edf..97df3ddff 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookGroup.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookGroup.kt @@ -33,7 +33,12 @@ data class BookGroup( const val IdAudio = -3L const val IdNetNone = -4L const val IdLocalNone = -5L + const val IdManga = -7L + const val IdText = -8L const val IdError = -11L + const val IdReading = -20L + const val IdUnread = -21L + const val IdReadFinished = -22L } data class GroupNameInfo( @@ -48,7 +53,12 @@ data class BookGroup( IdLocal -> GroupNameInfo(groupName, context.getString(R.string.local)) IdNetNone -> GroupNameInfo(groupName, context.getString(R.string.net_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)) + 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) } } diff --git a/app/src/main/res/drawable/bg_gradient_black.xml b/app/src/main/res/drawable/bg_gradient_black.xml index 4d3a211d1..3f5b849cd 100644 --- a/app/src/main/res/drawable/bg_gradient_black.xml +++ b/app/src/main/res/drawable/bg_gradient_black.xml @@ -3,6 +3,6 @@ diff --git a/app/src/main/res/layout/item_bookshelf_grid_compact.xml b/app/src/main/res/layout/item_bookshelf_grid_compact.xml index b79210a12..6527e1318 100644 --- a/app/src/main/res/layout/item_bookshelf_grid_compact.xml +++ b/app/src/main/res/layout/item_bookshelf_grid_compact.xml @@ -129,6 +129,10 @@ android:textColor="@android:color/white" android:textSize="12sp" android:textStyle="bold" + android:shadowColor="#80000000" + android:shadowDx="0" + android:shadowDy="0" + android:shadowRadius="4.0" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" /> diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 3b5a438e1..dcc7bd2d3 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -1351,4 +1351,9 @@ 换源按钮默认弹出整书换源 反之则默认弹出单章换源 显示书籍类型 + 在读 + 未读 + 已读 + 漫画 + 小说 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9d95e3c75..fe4893b02 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1354,4 +1354,9 @@ 换源按钮默认弹出整书换源 反之则默认弹出单章换源 显示书籍类型 + 在读 + 未读 + 已读 + 漫画 + 小说 diff --git a/app/version.properties b/app/version.properties index 1894271ce..1a5b459ca 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,5 +1,5 @@ VERSION_MAJOR=3 VERSION_MINOR=26 -VERSION_PATCH=4 +VERSION_PATCH=5 VERSION_SUFFIX=0 # 1 = Pre, 0 = Release \ No newline at end of file