新增书架新章节标记与相关设置 #384

This commit is contained in:
HapeLee
2025-11-27 00:00:13 +08:00
parent 15a25eface
commit d51b0a3199
20 changed files with 157 additions and 47 deletions
@@ -7,6 +7,7 @@ object PreferKey {
const val themeMode = "themeMode"
const val userAgent = "userAgent"
const val showUnread = "showUnread"
const val showUnreadNew = "showUnreadNew"
const val bookGroupStyle = "bookGroupStyle"
const val useDefaultCover = "useDefaultCover"
const val loadCoverOnlyWifi = "loadCoverOnlyWifi"
@@ -157,6 +157,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
appCtx.putPrefBoolean(PreferKey.showUnread, value)
}
var showUnreadNew: Boolean
get() = appCtx.getPrefBoolean(PreferKey.showUnreadNew, true)
set(value) {
appCtx.putPrefBoolean(PreferKey.showUnreadNew, value)
}
var showLastUpdateTime: Boolean
get() = appCtx.getPrefBoolean(PreferKey.showLastUpdateTime, false)
set(value) {
@@ -64,6 +64,7 @@ class BookshelfConfigBottomSheet : BaseBottomSheetDialogFragment(R.layout.dialog
}
swShowUnread.isChecked = AppConfig.showUnread
swShowUnreadNew.isChecked = AppConfig.showUnreadNew
swShowLastUpdateTime.isChecked = AppConfig.showLastUpdateTime
swShowWaitUpBooks.isChecked = AppConfig.showWaitUpCount
swShowBookshelfFastScroller.isChecked = AppConfig.showBookshelfFastScroller
@@ -119,6 +120,10 @@ class BookshelfConfigBottomSheet : BaseBottomSheetDialogFragment(R.layout.dialog
AppConfig.showUnread = swShowUnread.isChecked
postEvent(EventBus.BOOKSHELF_REFRESH, "")
}
if (AppConfig.showUnreadNew != swShowUnreadNew.isChecked) {
AppConfig.showUnreadNew = swShowUnreadNew.isChecked
postEvent(EventBus.BOOKSHELF_REFRESH, "")
}
if (AppConfig.showLastUpdateTime != swShowLastUpdateTime.isChecked) {
AppConfig.showLastUpdateTime = swShowLastUpdateTime.isChecked
postEvent(EventBus.BOOKSHELF_REFRESH, "")
@@ -3,6 +3,7 @@ package io.legado.app.ui.main.bookshelf.books.styleDefalut
import android.content.Context
import android.os.Bundle
import android.view.ViewGroup
import androidx.core.view.isVisible
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.data.entities.Book
import io.legado.app.databinding.ItemBookshelfGridBinding
@@ -53,8 +54,11 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
if (unreadCount > 0) {
binding.cdUnread.visible()
binding.tvUnread.text = unreadCount.toString()
if (AppConfig.showUnreadNew)
binding.newChapter.isVisible = item.lastCheckCount > 0
} else {
binding.cdUnread.gone()
binding.newChapter.gone()
}
} else {
binding.cdUnread.gone()
@@ -4,6 +4,7 @@ import android.content.Context
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.data.entities.Book
import io.legado.app.databinding.ItemBookshelfGridCompactBinding
@@ -59,6 +60,8 @@ class BooksAdapterGridCompact(context: Context, private val callBack: CallBack)
if (unreadCount > 0) {
binding.cdUnread.visibility = View.VISIBLE
binding.tvUnread.text = unreadCount.toString()
if (AppConfig.showUnreadNew)
binding.newChapter.isVisible = item.lastCheckCount > 0
} else {
binding.cdUnread.visibility = View.GONE
}
@@ -4,6 +4,7 @@ import android.content.Context
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.data.entities.Book
import io.legado.app.databinding.ItemBookshelfGridCompactBinding
@@ -60,6 +61,8 @@ class BooksAdapterGridCover(context: Context, private val callBack: CallBack) :
if (unreadCount > 0) {
binding.cdUnread.visibility = View.VISIBLE
binding.tvUnread.text = unreadCount.toString()
if (AppConfig.showUnreadNew)
binding.newChapter.isVisible = item.lastCheckCount > 0
} else {
binding.cdUnread.visibility = View.GONE
}
@@ -79,6 +79,8 @@ class BooksAdapterList(
if (unreadCount > 0) {
binding.cdUnread.visible()
binding.tvUnread.text = unreadCount.toString()
if (AppConfig.showUnreadNew)
binding.newChapter.isVisible = item.lastCheckCount > 0
} else {
binding.cdUnread.gone()
}
@@ -83,6 +83,8 @@ class BooksAdapterListCompact(
if (unreadCount > 0) {
binding.cdUnread.visible()
binding.tvUnread.text = unreadCount.toString()
if (AppConfig.showUnreadNew)
binding.newChapter.isVisible = item.lastCheckCount > 0
} else {
binding.cdUnread.gone()
}
@@ -5,6 +5,7 @@ import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.data.entities.Book
@@ -110,6 +111,8 @@ class BooksAdapterGrid(context: Context, callBack: CallBack) :
if (unreadCount > 0) {
binding.cdUnread.visibility = View.VISIBLE
binding.tvUnread.text = unreadCount.toString()
if (AppConfig.showUnreadNew)
binding.newChapter.isVisible = item.lastCheckCount > 0
} else {
binding.cdUnread.visibility = View.GONE
}
@@ -5,6 +5,7 @@ import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.data.entities.Book
@@ -117,6 +118,8 @@ class BooksAdapterGridCompact(context: Context, callBack: CallBack) :
if (unreadCount > 0) {
binding.cdUnread.visibility = View.VISIBLE
binding.tvUnread.text = unreadCount.toString()
if (AppConfig.showUnreadNew)
binding.newChapter.isVisible = item.lastCheckCount > 0
} else {
binding.cdUnread.visibility = View.GONE
}
@@ -5,6 +5,7 @@ import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.data.entities.Book
@@ -117,6 +118,8 @@ class BooksAdapterGridCover(context: Context, callBack: CallBack) :
if (unreadCount > 0) {
binding.cdUnread.visibility = View.VISIBLE
binding.tvUnread.text = unreadCount.toString()
if (AppConfig.showUnreadNew)
binding.newChapter.isVisible = item.lastCheckCount > 0
} else {
binding.cdUnread.visibility = View.GONE
}
@@ -4,6 +4,7 @@ import android.content.Context
import android.os.Bundle
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.data.entities.Book
@@ -131,6 +132,8 @@ class BooksAdapterList(context: Context, callBack: CallBack) :
if (unreadCount > 0) {
binding.cdUnread.visible()
binding.tvUnread.text = unreadCount.toString()
if (AppConfig.showUnreadNew)
binding.newChapter.isVisible = item.lastCheckCount > 0
} else {
binding.cdUnread.gone()
}
@@ -4,6 +4,7 @@ import android.content.Context
import android.os.Bundle
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.data.entities.Book
@@ -129,6 +130,8 @@ class BooksAdapterListCompact(context: Context, callBack: CallBack) :
if (unreadCount > 0) {
binding.cdUnread.visible()
binding.tvUnread.text = unreadCount.toString()
if (AppConfig.showUnreadNew)
binding.newChapter.isVisible = item.lastCheckCount > 0
} else {
binding.cdUnread.gone()
}