[新增] 正文强调色设置 (@Luoyacheng)
This commit is contained in:
@@ -5,6 +5,7 @@ import android.graphics.drawable.BitmapDrawable
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.annotation.Keep
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
import androidx.core.graphics.toColorInt
|
||||
import com.google.android.material.color.MaterialColors
|
||||
import io.legado.app.constant.AppLog
|
||||
@@ -27,14 +28,11 @@ import io.legado.app.utils.getPrefBoolean
|
||||
import io.legado.app.utils.getPrefInt
|
||||
import io.legado.app.utils.hexString
|
||||
import io.legado.app.utils.printOnDebug
|
||||
import io.legado.app.utils.putPrefBoolean
|
||||
import io.legado.app.utils.putPrefInt
|
||||
import io.legado.app.utils.resizeAndRecycle
|
||||
import splitties.init.appCtx
|
||||
import java.io.File
|
||||
import kotlin.String
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
import io.legado.app.utils.FileDoc
|
||||
import io.legado.app.utils.putPrefBoolean
|
||||
|
||||
/**
|
||||
* 阅读界面配置
|
||||
@@ -61,6 +59,7 @@ object ReadBookConfig {
|
||||
var bg: Drawable? = null
|
||||
var bgMeanColor: Int = 0
|
||||
val textColor: Int get() = durConfig.curTextColor()
|
||||
val textAccentColor: Int get() = durConfig.curTextAccentColor()
|
||||
val textShadowColor: Int get() = durConfig.curTextShadowColor()
|
||||
val menuColor: Int get() = durConfig.curMenuAc()
|
||||
init {
|
||||
@@ -603,6 +602,7 @@ object ReadBookConfig {
|
||||
config.bgStrEInk.toColorInt()
|
||||
}
|
||||
config.curTextColor()
|
||||
config.curTextAccentColor()
|
||||
return config
|
||||
}
|
||||
|
||||
@@ -626,6 +626,9 @@ object ReadBookConfig {
|
||||
private var textColor: String = "#3E3D3B",//白天文字颜色
|
||||
private var textColorNight: String = "#ADADAD",//夜间文字颜色
|
||||
private var textColorEInk: String = "#000000",
|
||||
private var textAccentColor: String = "#834E00",//白天强调文字颜色
|
||||
private var textAccentColorNight: String = "#FE4D55",//夜间强调文字颜色
|
||||
private var textAccentColorEInk: String = "#000000",
|
||||
private var pageAnim: Int = 0,//翻页动画
|
||||
private var pageAnimEInk: Int = 4,
|
||||
var textFont: String = "",//字体
|
||||
@@ -718,6 +721,18 @@ object ReadBookConfig {
|
||||
@Transient
|
||||
private var underlineColorNightInt = -1
|
||||
|
||||
@Transient
|
||||
private var textAccentColorIntEInk = -1
|
||||
|
||||
@Transient
|
||||
private var textAccentColorIntNight = -1
|
||||
|
||||
@Transient
|
||||
private var textAccentColorInt = -1
|
||||
|
||||
@Transient
|
||||
private var initAccentColorInt = false
|
||||
|
||||
@Transient
|
||||
private var initColorInt = false
|
||||
|
||||
@@ -760,6 +775,43 @@ object ReadBookConfig {
|
||||
initColorInt = true
|
||||
}
|
||||
|
||||
private fun initAccentColorInt() {
|
||||
textAccentColorIntEInk = textAccentColorEInk.toColorInt()
|
||||
textAccentColorIntNight = textAccentColorNight.toColorInt()
|
||||
textAccentColorInt = textAccentColor.toColorInt()
|
||||
initAccentColorInt = true
|
||||
}
|
||||
|
||||
fun setCurTextAccentColor(color: Int) {
|
||||
when {
|
||||
AppConfig.isEInkMode -> {
|
||||
textAccentColorEInk = "#${color.hexString}"
|
||||
textAccentColorIntEInk = color
|
||||
}
|
||||
|
||||
AppConfig.isNightTheme -> {
|
||||
textAccentColorNight = "#${color.hexString}"
|
||||
textAccentColorIntNight = color
|
||||
}
|
||||
|
||||
else -> {
|
||||
textAccentColor = "#${color.hexString}"
|
||||
textAccentColorInt = color
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun curTextAccentColor(): Int {
|
||||
if (!initAccentColorInt) {
|
||||
initAccentColorInt()
|
||||
}
|
||||
return when {
|
||||
AppConfig.isEInkMode -> textAccentColorIntEInk
|
||||
AppConfig.isNightTheme -> textAccentColorIntNight
|
||||
else -> textAccentColorInt
|
||||
}
|
||||
}
|
||||
|
||||
fun setCurShadColor(color: Int){
|
||||
when {
|
||||
AppConfig.isNightTheme -> {
|
||||
|
||||
@@ -76,8 +76,9 @@ import io.legado.app.ui.book.info.BookInfoActivity
|
||||
import io.legado.app.ui.book.read.config.AutoReadDialog
|
||||
import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.BG_COLOR
|
||||
import io.legado.app.ui.book.read.config.FontConfigDialog
|
||||
import io.legado.app.ui.book.read.config.FontConfigDialog.Companion.TEXT_COLOR
|
||||
import io.legado.app.ui.book.read.config.FontConfigDialog.Companion.S_COLOR
|
||||
import io.legado.app.ui.book.read.config.FontConfigDialog.Companion.TEXT_ACCENT_COLOR
|
||||
import io.legado.app.ui.book.read.config.FontConfigDialog.Companion.TEXT_COLOR
|
||||
import io.legado.app.ui.book.read.config.FontSelectDialog
|
||||
import io.legado.app.ui.book.read.config.ReadAloudDialog
|
||||
import io.legado.app.ui.book.read.config.ReadStyleDialog
|
||||
@@ -1529,10 +1530,10 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
}
|
||||
val (result, urlOptionStr) = when {
|
||||
braceIndex != -1 -> {
|
||||
clickjs.substring(0, braceIndex) to clickjs.substring(braceIndex + 1)
|
||||
clickjs.take(braceIndex) to clickjs.substring(braceIndex + 1)
|
||||
}
|
||||
else -> {
|
||||
clickjs.substring(0, braceIndex2) to clickjs.substring(braceIndex2 + 2)
|
||||
clickjs.take(braceIndex2) to clickjs.substring(braceIndex2 + 2)
|
||||
}
|
||||
}
|
||||
if (urlOptionStr.isJsonObject()) {
|
||||
@@ -1602,6 +1603,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
setCurShadColor(color)
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(2, 6, 9, 11))
|
||||
}
|
||||
|
||||
TEXT_COLOR -> {
|
||||
setCurTextColor(color)
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(2, 6, 9, 11))
|
||||
@@ -1610,6 +1612,14 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
TEXT_ACCENT_COLOR -> {
|
||||
setCurTextAccentColor(color)
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(2, 6, 9, 11))
|
||||
if (AppConfig.readBarStyleFollowPage) {
|
||||
postEvent(EventBus.UPDATE_READ_ACTION_BAR, true)
|
||||
}
|
||||
}
|
||||
|
||||
BG_COLOR -> {
|
||||
setCurBg(0, "#${color.hexString}")
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(1))
|
||||
|
||||
@@ -2,13 +2,13 @@ package io.legado.app.ui.book.read.config
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import io.legado.app.help.config.ReadBookConfig
|
||||
import com.jaredrummler.android.colorpicker.ColorPickerDialog
|
||||
import io.legado.app.R
|
||||
import io.legado.app.base.BaseBottomSheetDialogFragment
|
||||
import io.legado.app.constant.EventBus
|
||||
import io.legado.app.databinding.DialogFontConfigBinding
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.config.ReadBookConfig
|
||||
import io.legado.app.help.config.ReadBookConfig.underline
|
||||
import io.legado.app.lib.dialogs.alert
|
||||
import io.legado.app.ui.book.read.ReadBookActivity
|
||||
@@ -24,6 +24,7 @@ class FontConfigDialog : BaseBottomSheetDialogFragment(R.layout.dialog_font_conf
|
||||
companion object {
|
||||
const val S_COLOR = 123
|
||||
const val TEXT_COLOR = 121
|
||||
const val TEXT_ACCENT_COLOR = 122
|
||||
}
|
||||
private val binding by viewBinding(DialogFontConfigBinding::bind)
|
||||
|
||||
@@ -39,6 +40,7 @@ class FontConfigDialog : BaseBottomSheetDialogFragment(R.layout.dialog_font_conf
|
||||
if (list.contains(2)) {
|
||||
binding.btnTextColor.color = ReadBookConfig.durConfig.curTextColor()
|
||||
binding.btnShadowColor.color = ReadBookConfig.durConfig.curTextShadowColor()
|
||||
binding.btnTextAccentColor.color = ReadBookConfig.durConfig.curTextAccentColor()
|
||||
}
|
||||
}
|
||||
initView()
|
||||
@@ -48,6 +50,8 @@ class FontConfigDialog : BaseBottomSheetDialogFragment(R.layout.dialog_font_conf
|
||||
|
||||
private fun initView() = binding.run {
|
||||
binding.btnTextColor.color = ReadBookConfig.durConfig.curTextColor()
|
||||
binding.btnShadowColor.color = ReadBookConfig.durConfig.curTextShadowColor()
|
||||
binding.btnTextAccentColor.color = ReadBookConfig.durConfig.curTextAccentColor()
|
||||
binding.swUnderline.isChecked = underline
|
||||
dsbTextLetterSpacing.valueFormat = {
|
||||
((it - 50) / 100f).toString()
|
||||
@@ -129,7 +133,14 @@ class FontConfigDialog : BaseBottomSheetDialogFragment(R.layout.dialog_font_conf
|
||||
.setDialogId(TEXT_COLOR)
|
||||
.show(requireActivity())
|
||||
}
|
||||
|
||||
binding.btnTextAccentColor.setOnClickListener {
|
||||
ColorPickerDialog.newBuilder()
|
||||
.setColor(ReadBookConfig.durConfig.curTextAccentColor())
|
||||
.setShowAlphaSlider(false)
|
||||
.setDialogType(ColorPickerDialog.TYPE_CUSTOM)
|
||||
.setDialogId(TEXT_ACCENT_COLOR)
|
||||
.show(requireActivity())
|
||||
}
|
||||
binding.swUnderline.addOnCheckedChangeListener { _, isChecked ->
|
||||
callBack2?.showUnderlineConfig()
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ data class TextLine(
|
||||
ChapterProvider.contentPaint
|
||||
}
|
||||
val textColor = if (isReadAloud) {
|
||||
ReadBookConfig.menuColor
|
||||
ReadBookConfig.textAccentColor
|
||||
} else {
|
||||
ReadBookConfig.textColor
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import io.legado.app.ui.book.read.page.ContentTextView
|
||||
import io.legado.app.ui.book.read.page.entities.TextLine
|
||||
import io.legado.app.ui.book.read.page.entities.TextLine.Companion.emptyTextLine
|
||||
import io.legado.app.ui.book.read.page.provider.ChapterProvider
|
||||
import io.legado.app.utils.themeColor
|
||||
|
||||
/**
|
||||
* 文字列
|
||||
@@ -49,7 +48,7 @@ data class TextColumn(
|
||||
ChapterProvider.contentPaint
|
||||
}
|
||||
val textColor = if (textLine.isReadAloud || isSearchResult) {
|
||||
view.context.themeColor(androidx.appcompat.R.attr.colorPrimary)
|
||||
ReadBookConfig.textAccentColor
|
||||
} else {
|
||||
ReadBookConfig.textColor
|
||||
}
|
||||
|
||||
@@ -81,8 +81,25 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:icon="@drawable/ic_text_weight_2"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btnShadowSet"
|
||||
style="@style/Widget.Material3Expressive.Button.IconButton.Tonal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:icon="@drawable/ic_fill_colors" />
|
||||
|
||||
</com.google.android.material.button.MaterialButtonGroup>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginVertical="8dp"
|
||||
android:text="@string/read_color"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<com.google.android.material.button.MaterialButtonGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -97,6 +114,13 @@
|
||||
style="@style/Widget.Material3Expressive.Button.OutlinedButton"
|
||||
android:text="@string/text_color" />
|
||||
|
||||
<io.legado.app.ui.widget.AccentColorButton
|
||||
android:id="@+id/btn_text_accent_color"
|
||||
style="@style/Widget.Material3Expressive.Button.OutlinedButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/text_accent_color" />
|
||||
|
||||
<io.legado.app.ui.widget.AccentColorButton
|
||||
android:id="@+id/btnShadowColor"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -104,15 +128,6 @@
|
||||
style="@style/Widget.Material3Expressive.Button.OutlinedButton"
|
||||
android:text="@string/text_shadow_color" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btnShadowSet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.Material3Expressive.Button.IconButton.Outlined"
|
||||
app:iconSize="20sp"
|
||||
app:iconGravity="textStart"
|
||||
app:icon="@drawable/ic_fill_colors" />
|
||||
|
||||
</com.google.android.material.button.MaterialButtonGroup>
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -577,7 +577,7 @@
|
||||
<string name="speak_engine">朗读引擎</string>
|
||||
<string name="bg_image">背景图片</string>
|
||||
<string name="bg_color">背景颜色</string>
|
||||
<string name="text_color">文字颜色</string>
|
||||
<string name="text_color">正文</string>
|
||||
<string name="select_image">选择图片</string>
|
||||
<string name="group_manage">分组管理</string>
|
||||
<string name="group_select">分组选择</string>
|
||||
@@ -1306,7 +1306,7 @@
|
||||
<string name="text_shadow_x">X轴距离</string>
|
||||
<string name="text_shadow_y">Y轴距离</string>
|
||||
<string name="text_shadow_radius">阴影半径</string>
|
||||
<string name="text_shadow_color">阴影颜色</string>
|
||||
<string name="text_shadow_color">阴影</string>
|
||||
<string name="global_read_setting">阅读显示 • 漫画相关</string>
|
||||
<string name="screen_settings">屏幕显示与亮度</string>
|
||||
<string name="reading_behavior">阅读行为</string>
|
||||
@@ -1364,4 +1364,6 @@
|
||||
<string name="edit_remark">编辑备注</string>
|
||||
<string name="book_remark">书籍备注</string>
|
||||
<string name="auto_check_new_backup_t">自动检查新备份</string>
|
||||
<string name="text_accent_color">强调</string>
|
||||
<string name="read_color">颜色样式</string>
|
||||
</resources>
|
||||
@@ -1309,7 +1309,7 @@
|
||||
<string name="text_shadow_x">X轴距离</string>
|
||||
<string name="text_shadow_y">Y轴距离</string>
|
||||
<string name="text_shadow_radius">阴影半径</string>
|
||||
<string name="text_shadow_color">阴影颜色</string>
|
||||
<string name="text_shadow_color">阴影</string>
|
||||
<string name="global_read_setting">阅读显示 • 漫画相关</string>
|
||||
<string name="screen_settings">屏幕显示与亮度</string>
|
||||
<string name="reading_behavior">阅读行为</string>
|
||||
@@ -1369,4 +1369,6 @@
|
||||
<string name="book_remark">书籍备注</string>
|
||||
<string name="save_to_local">保存至本地</string>
|
||||
<string name="select_operation">选择操作</string>
|
||||
<string name="text_accent_color">强调</string>
|
||||
<string name="read_color">颜色样式</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user