Просмотр исходного кода

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

HapeLee 1 год назад
Родитель
Сommit
243da5dea6

+ 38 - 0
app/src/main/java/io/legado/app/help/config/ReadBookConfig.kt

@@ -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

+ 1 - 1
app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt

@@ -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 - 0
app/src/main/res/values-zh/arrays.xml

@@ -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 - 0
app/src/main/res/values/array_values.xml

@@ -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 - 0
app/src/main/res/values/arrays.xml

@@ -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>

+ 8 - 0
app/src/main/res/xml/pref_config_read.xml

@@ -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"

+ 1 - 1
app/version.properties

@@ -1,4 +1,4 @@
 VERSION_MAJOR=3
 VERSION_MINOR=26
 VERSION_PATCH=3
-VERSION_SUFFIX=-beta.1
+VERSION_SUFFIX=-beta.2