From 5b7903fb90567f80b35564fea3fd78cb65c53aee Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 12 May 2021 20:18:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=BE=E7=A4=BA=E6=9C=AA?= =?UTF-8?q?=E8=AF=BB=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + app/src/main/java/io/legado/app/help/AppConfig.kt | 6 ++++++ .../legado/app/ui/main/bookshelf/BookshelfFragment.kt | 6 ++++++ .../app/ui/main/bookshelf/books/BooksAdapterGrid.kt | 9 +++++++-- .../app/ui/main/bookshelf/books/BooksAdapterList.kt | 9 +++++++-- app/src/main/res/layout/dialog_bookshelf_config.xml | 10 ++++++++++ app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 11 files changed, 42 insertions(+), 4 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index bd696f3fe..4b204b77e 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2021/05/12** * 修复预下载bug +* 添加显示未读开关,书架布局中 **2021/05/11** * 修复部分webDav bug diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index bd0e86fc6..f60b7c361 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -4,6 +4,7 @@ object PreferKey { const val language = "language" const val themeMode = "themeMode" const val userAgent = "userAgent" + const val showUnread = "showUnread" const val hideStatusBar = "hideStatusBar" const val clickActionTL = "clickActionTopLeft" const val clickActionTC = "clickActionTopCenter" diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index a30f5c614..102f9507c 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -72,6 +72,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { } } + var showUnread: Boolean + get() = appCtx.getPrefBoolean(PreferKey.showUnread, true) + set(value) { + appCtx.putPrefBoolean(PreferKey.showUnread, value) + } + val isTransparentStatusBar: Boolean get() = appCtx.getPrefBoolean(PreferKey.transparentStatusBar, true) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 7a7113054..4a3eab128 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -22,6 +22,7 @@ import io.legado.app.data.entities.BookGroup import io.legado.app.databinding.DialogBookshelfConfigBinding import io.legado.app.databinding.DialogEditTextBinding import io.legado.app.databinding.FragmentBookshelfBinding +import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor @@ -170,6 +171,7 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b .apply { rgLayout.checkByIndex(bookshelfLayout) rgSort.checkByIndex(bookshelfSort) + swShowUnread.isChecked = AppConfig.showUnread } customView { alertBinding.root } okButton { @@ -183,6 +185,10 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b putPrefInt(PreferKey.bookshelfSort, rgSort.getCheckedIndex()) changed = true } + if (AppConfig.showUnread != swShowUnread.isChecked) { + AppConfig.showUnread = swShowUnread.isChecked + changed = true + } if (changed) { activity?.recreate() } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt index 62834745e..9eabfbd45 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt @@ -7,6 +7,7 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.constant.BookType import io.legado.app.data.entities.Book import io.legado.app.databinding.ItemBookshelfGridBinding +import io.legado.app.help.AppConfig import io.legado.app.utils.invisible import splitties.views.onLongClick @@ -45,8 +46,12 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) : binding.rlLoading.show() } else { binding.rlLoading.hide() - binding.bvUnread.setBadgeCount(item.getUnreadChapterNum()) - binding.bvUnread.setHighlight(item.lastCheckCount > 0) + if (AppConfig.showUnread) { + binding.bvUnread.setBadgeCount(item.getUnreadChapterNum()) + binding.bvUnread.setHighlight(item.lastCheckCount > 0) + } else { + binding.bvUnread.invisible() + } } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt index 08281b3b0..b93d3430a 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt @@ -7,6 +7,7 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.constant.BookType import io.legado.app.data.entities.Book import io.legado.app.databinding.ItemBookshelfListBinding +import io.legado.app.help.AppConfig import io.legado.app.utils.invisible import splitties.views.onLongClick @@ -51,8 +52,12 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) : binding.rlLoading.show() } else { binding.rlLoading.hide() - binding.bvUnread.setHighlight(item.lastCheckCount > 0) - binding.bvUnread.setBadgeCount(item.getUnreadChapterNum()) + if (AppConfig.showUnread) { + binding.bvUnread.setHighlight(item.lastCheckCount > 0) + binding.bvUnread.setBadgeCount(item.getUnreadChapterNum()) + } else { + binding.bvUnread.invisible() + } } } diff --git a/app/src/main/res/layout/dialog_bookshelf_config.xml b/app/src/main/res/layout/dialog_bookshelf_config.xml index 944913f4c..134d4d1c7 100644 --- a/app/src/main/res/layout/dialog_bookshelf_config.xml +++ b/app/src/main/res/layout/dialog_bookshelf_config.xml @@ -101,5 +101,15 @@ + + \ No newline at end of file diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index a854f5d40..302969db3 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -824,5 +824,6 @@ 使用屏幕最高刷新率 导出所有 完成 + 显示未读标志 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 604cfcaed..b826956ca 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -828,5 +828,6 @@ 使用螢幕最高刷新率 导出所有 完成 + 显示未读标志 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 987c5e6db..1f17b8764 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -828,5 +828,6 @@ 使用屏幕最高刷新率 导出所有 完成 + 显示未读标志 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bb353c4aa..cd76c1764 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -829,5 +829,6 @@ 使用屏幕最高刷新率 export_all complete + Show unread