添加下划线配置
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,6 +62,14 @@
|
||||
android:text="@string/dark_status_icon"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
<io.legado.app.lib.theme.view.ThemeSwitch
|
||||
android:id="@+id/sw_underline"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp"
|
||||
android:text="@string/text_underline"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -1091,4 +1091,5 @@
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
<string name="text_underline">文字下划线</string>
|
||||
</resources>
|
||||
|
||||
@@ -1094,4 +1094,5 @@
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
<string name="text_underline">文字下划线</string>
|
||||
</resources>
|
||||
|
||||
@@ -1094,4 +1094,5 @@
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
<string name="text_underline">文字下划线</string>
|
||||
</resources>
|
||||
|
||||
@@ -1091,4 +1091,5 @@
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
<string name="text_underline">文字下划线</string>
|
||||
</resources>
|
||||
|
||||
@@ -1093,4 +1093,5 @@
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
<string name="text_underline">文字下划线</string>
|
||||
</resources>
|
||||
|
||||
@@ -1093,4 +1093,5 @@
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
<string name="text_underline">文字下划线</string>
|
||||
</resources>
|
||||
|
||||
@@ -1094,4 +1094,5 @@
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
<string name="text_underline">文字下划线</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user