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 2ce1bec08..5e8f84640 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -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" diff --git a/app/src/main/java/io/legado/app/help/config/AppConfig.kt b/app/src/main/java/io/legado/app/help/config/AppConfig.kt index c5e8ab816..5fad091f9 100644 --- a/app/src/main/java/io/legado/app/help/config/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/config/AppConfig.kt @@ -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) { diff --git a/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt b/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt index e5eebd612..80015d2a6 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt @@ -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() diff --git a/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt b/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt index a0003c071..6bd508d3a 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt @@ -132,6 +132,8 @@ class TocActivity : VMBaseActivity(), } 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(), 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 } diff --git a/app/src/main/res/menu/book_toc.xml b/app/src/main/res/menu/book_toc.xml index 214708267..d8af1015c 100644 --- a/app/src/main/res/menu/book_toc.xml +++ b/app/src/main/res/menu/book_toc.xml @@ -42,6 +42,12 @@ android:title="@string/use_replace" app:showAsAction="never" /> + +