From f0ead5b4882cb17f5a478f03ac8c2ce580b8f5b4 Mon Sep 17 00:00:00 2001 From: Seidko Date: Wed, 7 Sep 2022 22:42:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=AE=B5=E8=AF=84=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E5=85=B3=E9=97=AD=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=87=86?= =?UTF-8?q?=E5=A4=87=E5=AE=9E=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/constant/PreferKey.kt | 1 + .../legado/app/data/entities/BookChapterReview.kt | 15 +++++++++++++++ .../java/io/legado/app/help/config/AppConfig.kt | 6 ++++++ .../java/io/legado/app/model/webBook/WebBook.kt | 7 +++++++ .../legado/app/ui/book/read/ReadBookActivity.kt | 7 +++++-- .../app/ui/book/read/page/ContentTextView.kt | 13 ++----------- .../app/ui/book/read/page/entities/TextLine.kt | 2 +- .../ui/book/read/page/provider/ChapterProvider.kt | 4 ++-- 8 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 app/src/main/java/io/legado/app/data/entities/BookChapterReview.kt 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 b1bbf3663..761250413 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -32,6 +32,7 @@ object PreferKey { const val prevKeys = "prevKeyCodes" const val nextKeys = "nextKeyCodes" const val showDiscovery = "showDiscovery" + const val enableReview = "enableReview" const val showRss = "showRss" const val bookshelfLayout = "bookshelfLayout" const val bookshelfSort = "bookshelfSort" diff --git a/app/src/main/java/io/legado/app/data/entities/BookChapterReview.kt b/app/src/main/java/io/legado/app/data/entities/BookChapterReview.kt new file mode 100644 index 000000000..64a838f42 --- /dev/null +++ b/app/src/main/java/io/legado/app/data/entities/BookChapterReview.kt @@ -0,0 +1,15 @@ +package io.legado.app.data.entities + +import android.os.Parcelable +import androidx.room.ColumnInfo +import kotlinx.parcelize.Parcelize + +@Parcelize +class BookChapterReview( + @ColumnInfo(defaultValue = "0") + var bookId: Long = 0, + var chapterId: Long = 0, + var summaryUrl: String = "", +): Parcelable { + +} 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 60ea20f46..dcc797eec 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 @@ -154,6 +154,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { val autoRefreshBook: Boolean get() = appCtx.getPrefBoolean(PreferKey.autoRefresh) + var enableReview: Boolean + get() = appCtx.getPrefBoolean(PreferKey.enableReview, false) + set(value) { + appCtx.putPrefBoolean(PreferKey.enableReview, value) + } + var threadCount: Int get() = appCtx.getPrefInt(PreferKey.threadCount, 16) set(value) { diff --git a/app/src/main/java/io/legado/app/model/webBook/WebBook.kt b/app/src/main/java/io/legado/app/model/webBook/WebBook.kt index 7d37300a1..f80a4e0a7 100644 --- a/app/src/main/java/io/legado/app/model/webBook/WebBook.kt +++ b/app/src/main/java/io/legado/app/model/webBook/WebBook.kt @@ -300,6 +300,13 @@ object WebBook { } } + /** + * 获取段评 + */ + fun getReview() { + // TODO + } + /** * 精准搜索 */ diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 930ccf0c2..3aba40f8b 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -255,6 +255,7 @@ class ReadBookActivity : BaseReadBookActivity(), else -> when (item.itemId) { R.id.menu_enable_replace -> item.isChecked = book.getUseReplaceRule() R.id.menu_re_segment -> item.isChecked = book.getReSegment() + R.id.menu_enable_review -> item.isChecked = AppConfig.enableReview R.id.menu_reverse_content -> item.isVisible = onLine } } @@ -355,8 +356,10 @@ class ReadBookActivity : BaseReadBookActivity(), menu?.findItem(R.id.menu_re_segment)?.isChecked = it.getReSegment() ReadBook.loadContent(false) } - R.id.menu_enable_review -> ReadBook.book?.let { - // TODO + R.id.menu_enable_review -> { + AppConfig.enableReview = !AppConfig.enableReview + menu?.findItem(R.id.menu_enable_review)?.isChecked = AppConfig.enableReview + ReadBook.loadContent(false) } R.id.menu_page_anim -> showPageAnimConfig { binding.readView.upPageAnim() diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index 661873485..a9e72ed91 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -16,10 +16,7 @@ import io.legado.app.help.config.AppConfig import io.legado.app.help.config.ReadBookConfig import io.legado.app.lib.theme.accentColor import io.legado.app.model.ReadBook -import io.legado.app.ui.book.read.page.entities.TextColumn -import io.legado.app.ui.book.read.page.entities.TextLine -import io.legado.app.ui.book.read.page.entities.TextPage -import io.legado.app.ui.book.read.page.entities.TextPos +import io.legado.app.ui.book.read.page.entities.* import io.legado.app.ui.book.read.page.provider.ChapterProvider import io.legado.app.ui.book.read.page.provider.ImageProvider import io.legado.app.ui.book.read.page.provider.TextPageFactory @@ -30,7 +27,7 @@ import io.legado.app.utils.toastOnUi import kotlin.math.min /** - * 阅读内容视图 + * 阅读内容界面 */ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, attrs) { var selectAble = context.getPrefBoolean(PreferKey.textSelectAble, true) @@ -67,18 +64,12 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at callBack = activity as CallBack } - /** - * 设置内容 - */ fun setContent(textPage: TextPage) { this.textPage = textPage imagePaint.isAntiAlias = AppConfig.useAntiAlias invalidate() } - /** - * 更新绘制区域 - */ fun upVisibleRect() { visibleRect.set( ChapterProvider.paddingLeft.toFloat(), diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt index c1a5b4597..076c1bc2f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt @@ -11,7 +11,7 @@ import io.legado.app.utils.textHeight data class TextLine( var text: String = "", val textChars: ArrayList = arrayListOf(), - val reviewCount: Int = 1, + val reviewCount: Int = 0, var lineTop: Float = 0f, var lineBase: Float = 0f, var lineBottom: Float = 0f, diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt index e16513b8b..8dd49e208 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt @@ -119,7 +119,7 @@ object ChapterProvider { book, absStartX, durY, - text + "\ud83d\udcac", + if (AppConfig.enableReview) text + "\ud83d\udcac" else text, textPages, stringBuilder, titlePaint, @@ -180,7 +180,7 @@ object ChapterProvider { book, absStartX, durY, - text + "\ud83d\udcac", + if (AppConfig.enableReview) text + "\ud83d\udcac" else text, textPages, stringBuilder, contentPaint