From 473de328ac12642e78745a1af625375f2572b4b8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 2 Apr 2023 10:52:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8B=E5=88=92=E7=BA=BF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/help/config/ReadBookConfig.kt | 11 +++++++-- .../ui/book/read/config/BgTextConfigDialog.kt | 6 +++++ .../app/ui/book/read/page/ContentTextView.kt | 24 +++++++++++++++---- .../main/res/layout/dialog_read_bg_text.xml | 8 +++++++ app/src/main/res/values-es-rES/strings.xml | 1 + app/src/main/res/values-ja-rJP/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + 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, 50 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/config/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/config/ReadBookConfig.kt index 4f25352a8..08f49f028 100644 --- a/app/src/main/java/io/legado/app/help/config/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/config/ReadBookConfig.kt @@ -255,6 +255,12 @@ object ReadBookConfig { config.paragraphIndent = value } + var underline: Boolean + get() = config.underline + set(value) { + config.underline = value + } + var paddingBottom: Int get() = config.paddingBottom set(value) { @@ -448,14 +454,14 @@ object ReadBookConfig { var bgAlpha: Int = 100,//背景透明度 var bgType: Int = 0,//白天背景类型 0:颜色, 1:assets图片, 2其它图片 var bgTypeNight: Int = 0,//夜间背景类型 - var bgTypeEInk: Int = 0, + var bgTypeEInk: Int = 0,//EInk背景类型 private var darkStatusIcon: Boolean = true,//白天是否暗色状态栏 private var darkStatusIconNight: Boolean = false,//晚上是否暗色状态栏 private var darkStatusIconEInk: Boolean = true, private var textColor: String = "#3E3D3B",//白天文字颜色 private var textColorNight: String = "#ADADAD",//夜间文字颜色 private var textColorEInk: String = "#000000", - private var pageAnim: Int = 0, + private var pageAnim: Int = 0,//翻页动画 private var pageAnimEInk: Int = 3, var textFont: String = "",//字体 var textBold: Int = 0,//是否粗体字 0:正常, 1:粗体, 2:细体 @@ -468,6 +474,7 @@ object ReadBookConfig { var titleTopSpacing: Int = 0, var titleBottomSpacing: Int = 0, var paragraphIndent: String = "  ",//段落缩进 + var underline: Boolean = false, //下划线 var paddingBottom: Int = 6, var paddingLeft: Int = 16, var paddingRight: Int = 16, diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt index 740e62955..1745776e6 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt @@ -112,6 +112,7 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) { ivEdit.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN) tvRestore.setTextColor(primaryTextColor) swDarkStatusIcon.setTextColor(primaryTextColor) + swUnderline.setTextColor(primaryTextColor) ivImport.setColorFilter(primaryTextColor, PorterDuff.Mode.SRC_IN) ivExport.setColorFilter(primaryTextColor, PorterDuff.Mode.SRC_IN) ivDelete.setColorFilter(primaryTextColor, PorterDuff.Mode.SRC_IN) @@ -138,6 +139,7 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) { private fun initData() = with(ReadBookConfig.durConfig) { binding.tvName.text = name.ifBlank { "文字" } binding.swDarkStatusIcon.isChecked = curStatusIconDark() + binding.swUnderline.isChecked = underline binding.sbBgAlpha.progress = bgAlpha } @@ -174,6 +176,10 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) { setCurStatusIconDark(isChecked) (activity as? ReadBookActivity)?.upSystemUiVisibility() } + binding.swUnderline.setOnCheckedChangeListener { _, isChecked -> + underline = isChecked + postEvent(EventBus.UP_CONFIG, true) + } binding.tvTextColor.setOnClickListener { ColorPickerDialog.newBuilder() .setColor(curTextColor()) 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 745eede7a..4dd00ce93 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 @@ -114,7 +114,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at private fun drawPage(canvas: Canvas) { var relativeOffset = relativeOffset(0) textPage.lines.forEach { textLine -> - draw(canvas, textPage, textLine, relativeOffset) + drawLine(canvas, textPage, textLine, relativeOffset) } if (!callBack.isScroll) return //滚动翻页 @@ -122,14 +122,14 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at val textPage1 = relativePage(1) relativeOffset = relativeOffset(1) textPage1.lines.forEach { textLine -> - draw(canvas, textPage1, textLine, relativeOffset) + drawLine(canvas, textPage1, textLine, relativeOffset) } if (!pageFactory.hasNextPlus()) return relativeOffset = relativeOffset(2) if (relativeOffset < ChapterProvider.visibleHeight) { val textPage2 = relativePage(2) textPage2.lines.forEach { textLine -> - draw(canvas, textPage2, textLine, relativeOffset) + drawLine(canvas, textPage2, textLine, relativeOffset) } } } @@ -137,7 +137,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at /** * 绘制页面 */ - private fun draw( + private fun drawLine( canvas: Canvas, textPage: TextPage, textLine: TextLine, @@ -147,6 +147,22 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at val lineBase = textLine.lineBase + relativeOffset val lineBottom = textLine.lineBottom + relativeOffset drawChars(canvas, textPage, textLine, lineTop, lineBase, lineBottom) + if (ReadBookConfig.underline) { + drawUnderline(canvas, textLine, lineBottom) + } + } + + /** + * 绘制下划线 + */ + private fun drawUnderline(canvas: Canvas, textLine: TextLine, lineY: Float) { + canvas.drawLine( + textLine.lineStart, + lineY, + textLine.lineEnd, + lineY, + ChapterProvider.contentPaint + ) } /** diff --git a/app/src/main/res/layout/dialog_read_bg_text.xml b/app/src/main/res/layout/dialog_read_bg_text.xml index 54c38f967..d366b9d9d 100644 --- a/app/src/main/res/layout/dialog_read_bg_text.xml +++ b/app/src/main/res/layout/dialog_read_bg_text.xml @@ -62,6 +62,14 @@ android:text="@string/dark_status_icon" tools:ignore="TouchTargetSizeCheck" /> + + 管理私有文件夹的文件 创建文件夹 允许下拉刷新 + 文字下划线 diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 26dd3e79e..3083b0f1c 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -1094,4 +1094,5 @@ 管理私有文件夹的文件 创建文件夹 允许下拉刷新 + 文字下划线 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index f35a26488..76c6c0211 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1094,4 +1094,5 @@ 管理私有文件夹的文件 创建文件夹 允许下拉刷新 + 文字下划线 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 41f02d108..e0b25b807 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -1091,4 +1091,5 @@ 管理私有文件夹的文件 创建文件夹 允许下拉刷新 + 文字下划线 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index f7a778205..2e9b75b58 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1093,4 +1093,5 @@ 管理私有文件夹的文件 创建文件夹 允许下拉刷新 + 文字下划线 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 7159a4b80..38118e3b9 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -1093,4 +1093,5 @@ 管理私有文件夹的文件 创建文件夹 允许下拉刷新 + 文字下划线 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5a4638ab6..912521f5e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1094,4 +1094,5 @@ 管理私有文件夹的文件 创建文件夹 允许下拉刷新 + 文字下划线