一些自定义下划线与阅读顶栏的前提工作

This commit is contained in:
HapeLee
2025-11-11 00:56:26 +08:00
parent 4b0c1af501
commit 243da5dea6
7 changed files with 84 additions and 2 deletions
@@ -382,6 +382,12 @@ object ReadBookConfig {
config.underline = value
}
var underlineHeight: Int
get() = config.underlineHeight
set(value) {
config.underlineHeight = value
}
var dottedLine: Boolean
get() = config.dottedLine
set(value) {
@@ -622,6 +628,9 @@ object ReadBookConfig {
var titleSegFlag: String = "",//分段判断,碰到指定值时分段
var paragraphIndent: String = "  ",//段落缩进
var underline: Boolean = false, //下划线
var underlineHeight: Int = 1,
var underlineColor: String = "#3E3D3B",
var underlineColorNight: String = "#ADADAD",
var dottedLine: Boolean = false, //虚线
var dottedBase: Float = 6f, //长度
var dottedRatio: Float = 6f,
@@ -678,6 +687,12 @@ object ReadBookConfig {
@Transient
private var menuAcColorNightInt = -1
@Transient
private var underlineColorInt = -1
@Transient
private var underlineColorNightInt = -1
@Transient
private var initColorInt = false
@@ -691,6 +706,8 @@ object ReadBookConfig {
menuBgColorNightInt = menuBgColorNight.toColorInt()
menuAcColorInt = menuAcColor.toColorInt()
menuAcColorNightInt = menuAcColorNight.toColorInt()
underlineColorInt = underlineColor.toColorInt()
underlineColorNightInt = underlineColorNight.toColorInt()
initColorInt = true
}
@@ -846,6 +863,27 @@ object ReadBookConfig {
}
}
fun curUnderlineColor(): Int {
return when {
AppConfig.isNightTheme -> underlineColorNightInt
else -> underlineColorInt
}
}
fun setUnderlineColor(bg: Int) {
when {
AppConfig.isNightTheme -> {
underlineColorNight = "#${bg.hexString}"
underlineColorNightInt = bg
}
else -> {
underlineColor = "#${bg.hexString}"
underlineColorInt = bg
}
}
}
fun curBgType(): Int {
return when {
AppConfig.isEInkMode -> bgTypeEInk
@@ -61,7 +61,7 @@ object ChapterProvider {
Paint(contentPaint).apply {
clearShadowLayer()
isAntiAlias = true
strokeWidth = 1.dpToPx().toFloat()
strokeWidth = ReadBookConfig.underlineHeight.toFloat()
style = Paint.Style.STROKE
}
}
+12
View File
@@ -175,5 +175,17 @@
<item>仅显示滑动条</item>
</string-array>
<string-array name="title_bar_mode">
<item>自动</item>
<item>在应用栏上显示</item>
<item>在独立行上显示</item>
</string-array>
<string-array name="title_chapter_mode">
<item>不显示标题</item>
<item>不显示</item>
<item>Disable title and chapter display</item>
</string-array>
<string name="all_version">所有版本</string>
</resources>
+12
View File
@@ -98,4 +98,16 @@
<item>4</item>
</string-array>
<string-array name="title_bar_mode_value">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string-array name="title_chapter_mode_value">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
</resources>
+12
View File
@@ -94,6 +94,18 @@
<item>Only slider</item>
</string-array>
<string-array name="title_bar_mode">
<item>Auto</item>
<item>Show in TopBar</item>
<item>Show in another line</item>
</string-array>
<string-array name="title_chapter_mode">
<item>Disable title display</item>
<item>Disable chapter display</item>
<item>Disable title and chapter display</item>
</string-array>
<string-array name="screen_direction_title">
<item>@string/screen_unspecified</item>
<item>@string/screen_portrait</item>
@@ -41,6 +41,14 @@
android:title="@string/padding_display_cutouts"
app:isBottomBackground="true" />
<io.legado.app.lib.prefs.NameListPreference
android:defaultValue="0"
android:entries="@array/read_slider_mode"
android:entryValues="@array/read_slider_mode_value"
android:key="title_bar_mode"
android:title="@string/read_slider_mode"
app:isBottomBackground="true" />
<io.legado.app.lib.prefs.Preference
android:key="menuAlpha"
android:summary="@string/menu_alpha_sum"