书籍目录页面,增加字段统计开关,默认开启 (#4470)

This commit is contained in:
niuhb 2024-12-26 14:14:31 +08:00 committed by GitHub
parent db3ee32496
commit f1a99fd361
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 1 deletions

View File

@ -107,6 +107,7 @@ object PreferKey {
const val checkSource = "checkSource"
const val uploadRule = "uploadRule"
const val tocUiUseReplace = "tocUiUseReplace"
const val tocCountWords = "tocCountWords"
const val enableReadRecord = "enableReadRecord"
const val localBookImportSort = "localBookImportSort"
const val customWelcome = "customWelcome"

View File

@ -381,6 +381,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
appCtx.putPrefBoolean(PreferKey.tocUiUseReplace, value)
}
var tocCountWords: Boolean
get() = appCtx.getPrefBoolean(PreferKey.tocCountWords, true)
set(value) {
appCtx.putPrefBoolean(PreferKey.tocCountWords, value)
}
var enableReadRecord: Boolean
get() = appCtx.getPrefBoolean(PreferKey.enableReadRecord, true)
set(value) {

View File

@ -150,7 +150,7 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
} else {
tvTag.gone()
}
if (!item.wordCount.isNullOrEmpty() && !item.isVolume) {
if (AppConfig.tocCountWords && !item.wordCount.isNullOrEmpty() && !item.isVolume) {
//章节字数
tvWordCount.text = item.wordCount
tvWordCount.visible()

View File

@ -132,6 +132,8 @@ class TocActivity : VMBaseActivity<ActivityChapterListBinding, TocViewModel>(),
}
menu.findItem(R.id.menu_use_replace)?.isChecked =
AppConfig.tocUiUseReplace
menu.findItem(R.id.menu_load_word_count)?.isChecked =
AppConfig.tocCountWords
menu.findItem(R.id.menu_split_long_chapter)?.isChecked =
viewModel.bookData.value?.getSplitLongChapter() == true
return super.onMenuOpened(featureId, menu)
@ -165,6 +167,10 @@ class TocActivity : VMBaseActivity<ActivityChapterListBinding, TocViewModel>(),
viewModel.chapterListCallBack?.upChapterList(searchView?.query?.toString())
}
R.id.menu_load_word_count -> {
AppConfig.tocCountWords = !item.isChecked
}
R.id.menu_export_bookmark -> exportDir.launch {
requestCode = 1
}

View File

@ -42,6 +42,12 @@
android:title="@string/use_replace"
app:showAsAction="never" />
<item
android:id="@+id/menu_load_word_count"
android:checkable="true"
android:title="@string/load_word_count"
app:showAsAction="never" />
</group>
<group