diff --git a/app/src/main/java/io/legado/app/constant/BookType.kt b/app/src/main/java/io/legado/app/constant/BookType.kt index 5cf3a3fef791..3f3670e479a1 100644 --- a/app/src/main/java/io/legado/app/constant/BookType.kt +++ b/app/src/main/java/io/legado/app/constant/BookType.kt @@ -6,6 +6,7 @@ import androidx.annotation.IntDef * 以二进制位来区分,可能一本书籍包含多个类型,每一位代表一个类型,数值为2的n次方 * 以二进制位来区分,数据库查询更高效, 数值>=8和老版本类型区分开 */ +@Suppress("ConstPropertyName") object BookType { /** * 8 文本 diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index 285ddd918b9c..611ce1a9a56e 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -13,6 +13,7 @@ import androidx.activity.viewModels import androidx.lifecycle.lifecycleScope import io.legado.app.R import io.legado.app.base.VMBaseActivity +import io.legado.app.constant.BookType import io.legado.app.constant.Theme import io.legado.app.data.appDb import io.legado.app.data.entities.Book @@ -26,6 +27,7 @@ import io.legado.app.help.book.isAudio import io.legado.app.help.book.isLocal import io.legado.app.help.book.isLocalTxt import io.legado.app.help.book.isWebFile +import io.legado.app.help.book.removeType import io.legado.app.help.config.AppConfig import io.legado.app.help.config.LocalConfig import io.legado.app.lib.dialogs.alert @@ -224,6 +226,9 @@ class BookInfoActivity : viewModel.getBook()?.let { it.canUpdate = !it.canUpdate if (viewModel.inBookshelf) { + if (!it.canUpdate) { + it.removeType(BookType.updateError) + } viewModel.saveBook(it) } } diff --git a/app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageViewModel.kt b/app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageViewModel.kt index 8a74fed8c3b6..775d48e16c53 100644 --- a/app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageViewModel.kt @@ -37,7 +37,11 @@ class BookshelfManageViewModel(application: Application) : BaseViewModel(applica fun upCanUpdate(books: List, canUpdate: Boolean) { execute { val array = Array(books.size) { - books[it].copy(canUpdate = canUpdate) + books[it].copy(canUpdate = canUpdate).apply { + if (!canUpdate) { + removeType(BookType.updateError) + } + } } appDb.bookDao.update(*array) }