This commit is contained in:
Horis
2024-02-27 14:48:58 +08:00
parent 9501c2b680
commit cc53f7d0c5
16 changed files with 70 additions and 21 deletions
@@ -26,6 +26,10 @@ object ReadTipConfig {
) )
val tipNames get() = appCtx.resources.getStringArray(R.array.read_tip).toList() val tipNames get() = appCtx.resources.getStringArray(R.array.read_tip).toList()
val tipColorNames get() = appCtx.resources.getStringArray(R.array.tip_color).toList()
val tipDividerColorNames
get() = appCtx.resources.getStringArray(R.array.tip_divider_color).toList()
var tipHeaderLeft: Int var tipHeaderLeft: Int
get() = ReadBookConfig.config.tipHeaderLeft get() = ReadBookConfig.config.tipHeaderLeft
set(value) { set(value) {
@@ -4,6 +4,7 @@ import android.content.Context
import android.graphics.Color import android.graphics.Color
import android.util.AttributeSet import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatRadioButton import androidx.appcompat.widget.AppCompatRadioButton
import androidx.appcompat.widget.TooltipCompat
import io.legado.app.R import io.legado.app.R
import io.legado.app.lib.theme.Selector import io.legado.app.lib.theme.Selector
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
@@ -24,6 +25,7 @@ class ThemeRadioNoButton(context: Context, attrs: AttributeSet) :
typedArray.getBoolean(R.styleable.ThemeRadioNoButton_isBottomBackground, false) typedArray.getBoolean(R.styleable.ThemeRadioNoButton_isBottomBackground, false)
typedArray.recycle() typedArray.recycle()
initTheme() initTheme()
TooltipCompat.setTooltipText(this, text)
} }
private fun initTheme() { private fun initTheme() {
@@ -11,6 +11,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.WindowManager import android.view.WindowManager
import android.widget.SeekBar import android.widget.SeekBar
import androidx.appcompat.widget.TooltipCompat
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import com.jaredrummler.android.colorpicker.ColorPickerDialog import com.jaredrummler.android.colorpicker.ColorPickerDialog
import io.legado.app.R import io.legado.app.R
@@ -220,6 +221,9 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
.setDialogId(BG_COLOR) .setDialogId(BG_COLOR)
.show(requireActivity()) .show(requireActivity())
} }
binding.tvBgColor.apply {
TooltipCompat.setTooltipText(this, text)
}
binding.ivImport.setOnClickListener { binding.ivImport.setOnClickListener {
selectImportDoc.launch { selectImportDoc.launch {
mode = HandleFileContract.FILE mode = HandleFileContract.FILE
@@ -15,7 +15,7 @@ import io.legado.app.ui.widget.text.StrokeTextView
class TextFontWeightConverter(context: Context, attrs: AttributeSet?) : class TextFontWeightConverter(context: Context, attrs: AttributeSet?) :
StrokeTextView(context, attrs) { StrokeTextView(context, attrs) {
private val spannableString = SpannableString("中/粗/细") private val spannableString = SpannableString(context.getString(R.string.font_weight_text))
private var enabledSpan: ForegroundColorSpan = ForegroundColorSpan(context.accentColor) private var enabledSpan: ForegroundColorSpan = ForegroundColorSpan(context.accentColor)
private var onChanged: (() -> Unit)? = null private var onChanged: (() -> Unit)? = null
@@ -75,19 +75,21 @@ class TipConfigDialog : BaseDialogFragment(R.layout.dialog_tip_config) {
} }
private fun upTvTipColor() { private fun upTvTipColor() {
binding.tvTipColor.text = val tipColorNames = ReadTipConfig.tipColorNames
if (ReadTipConfig.tipColor == 0) { val tipColor = ReadTipConfig.tipColor
"跟随正文" binding.tvTipColor.text = if (tipColor == 0) {
} else { tipColorNames.first()
"#${ReadTipConfig.tipColor.hexString}" } else {
} "#${tipColor.hexString}"
}
} }
private fun upTvTipDividerColor() { private fun upTvTipDividerColor() {
binding.tvTipDividerColor.text = when (ReadTipConfig.tipDividerColor) { val tipDividerColorNames = ReadTipConfig.tipDividerColorNames
-1 -> "默认" val tipDividerColor = ReadTipConfig.tipDividerColor
0 -> "跟随文字颜色" binding.tvTipDividerColor.text = when (tipDividerColor) {
else -> "#${ReadTipConfig.tipDividerColor.hexString}" -1, 0 -> tipDividerColorNames[tipDividerColor + 1]
else -> "#${tipDividerColor.hexString}"
} }
} }
@@ -179,13 +181,14 @@ class TipConfigDialog : BaseDialogFragment(R.layout.dialog_tip_config) {
} }
} }
llTipColor.setOnClickListener { llTipColor.setOnClickListener {
context?.selector(items = arrayListOf("跟随正文", "自定义")) { _, i -> context?.selector(items = ReadTipConfig.tipColorNames) { _, i ->
when (i) { when (i) {
0 -> { 0 -> {
ReadTipConfig.tipColor = 0 ReadTipConfig.tipColor = 0
upTvTipColor() upTvTipColor()
postEvent(EventBus.UP_CONFIG, arrayOf(2)) postEvent(EventBus.UP_CONFIG, arrayOf(2))
} }
1 -> ColorPickerDialog.newBuilder() 1 -> ColorPickerDialog.newBuilder()
.setShowAlphaSlider(false) .setShowAlphaSlider(false)
.setDialogType(ColorPickerDialog.TYPE_CUSTOM) .setDialogType(ColorPickerDialog.TYPE_CUSTOM)
@@ -195,13 +198,14 @@ class TipConfigDialog : BaseDialogFragment(R.layout.dialog_tip_config) {
} }
} }
llTipDividerColor.setOnClickListener { llTipDividerColor.setOnClickListener {
context?.selector(items = arrayListOf("默认", "跟随文字颜色", "自定义")) { _, i -> context?.selector(items = ReadTipConfig.tipDividerColorNames) { _, i ->
when (i) { when (i) {
0, 1 -> { 0, 1 -> {
ReadTipConfig.tipDividerColor = i - 1 ReadTipConfig.tipDividerColor = i - 1
upTvTipDividerColor() upTvTipDividerColor()
postEvent(EventBus.UP_CONFIG, arrayOf(2)) postEvent(EventBus.UP_CONFIG, arrayOf(2))
} }
2 -> ColorPickerDialog.newBuilder() 2 -> ColorPickerDialog.newBuilder()
.setShowAlphaSlider(false) .setShowAlphaSlider(false)
.setDialogType(ColorPickerDialog.TYPE_CUSTOM) .setDialogType(ColorPickerDialog.TYPE_CUSTOM)
@@ -6,6 +6,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater import android.view.LayoutInflater
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.SeekBar import android.widget.SeekBar
import androidx.appcompat.widget.TooltipCompat
import io.legado.app.R import io.legado.app.R
import io.legado.app.databinding.ViewDetailSeekBarBinding import io.legado.app.databinding.ViewDetailSeekBarBinding
import io.legado.app.lib.theme.bottomBackground import io.legado.app.lib.theme.bottomBackground
@@ -42,7 +43,11 @@ class DetailSeekBar @JvmOverloads constructor(
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.DetailSeekBar) val typedArray = context.obtainStyledAttributes(attrs, R.styleable.DetailSeekBar)
isBottomBackground = isBottomBackground =
typedArray.getBoolean(R.styleable.DetailSeekBar_isBottomBackground, false) typedArray.getBoolean(R.styleable.DetailSeekBar_isBottomBackground, false)
binding.tvSeekTitle.text = typedArray.getText(R.styleable.DetailSeekBar_title) val title = typedArray.getText(R.styleable.DetailSeekBar_title)
binding.tvSeekTitle.apply {
text = title
TooltipCompat.setTooltipText(this, title)
}
binding.seekBar.max = typedArray.getInteger(R.styleable.DetailSeekBar_max, 0) binding.seekBar.max = typedArray.getInteger(R.styleable.DetailSeekBar_max, 0)
typedArray.recycle() typedArray.recycle()
if (isBottomBackground && !isInEditMode) { if (isBottomBackground && !isInEditMode) {
@@ -1144,4 +1144,5 @@
<string name="create_heap_dump">创建堆转储</string> <string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string> <string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string> <string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources> </resources>
@@ -1147,4 +1147,5 @@
<string name="create_heap_dump">创建堆转储</string> <string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string> <string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string> <string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources> </resources>
@@ -1147,4 +1147,5 @@
<string name="create_heap_dump">创建堆转储</string> <string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string> <string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string> <string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources> </resources>
+1
View File
@@ -1143,4 +1143,5 @@ Còn </string>
<string name="create_heap_dump">创建堆转储</string> <string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string> <string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string> <string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources> </resources>
@@ -1144,4 +1144,5 @@
<string name="create_heap_dump">创建堆转储</string> <string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string> <string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string> <string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources> </resources>
@@ -1146,4 +1146,5 @@
<string name="create_heap_dump">创建堆转储</string> <string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string> <string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string> <string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources> </resources>
+11
View File
@@ -103,4 +103,15 @@
<item>替换规则</item> <item>替换规则</item>
</string-array> </string-array>
<string-array name="tip_color">
<item>跟随内容</item>
<item>自定义</item>
</string-array>
<string-array name="tip_divider_color">
<item>默认</item>
<item>跟随内容</item>
<item>自定义</item>
</string-array>
</resources> </resources>
+1
View File
@@ -1146,4 +1146,5 @@
<string name="create_heap_dump">创建堆转储</string> <string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string> <string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string> <string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources> </resources>
+11
View File
@@ -158,4 +158,15 @@
<item>my</item> <item>my</item>
</string-array> </string-array>
<string-array name="tip_color">
<item>Same color as content</item>
<item>Customize</item>
</string-array>
<string-array name="tip_divider_color">
<item>Default</item>
<item>Same color as content</item>
<item>Customize</item>
</string-array>
</resources> </resources>
+8 -7
View File
@@ -288,10 +288,10 @@
<string name="bottom">Bottom</string> <string name="bottom">Bottom</string>
<string name="top">Top</string> <string name="top">Top</string>
<string name="padding">Padding</string> <string name="padding">Padding</string>
<string name="padding_top">Padding top</string> <string name="padding_top">Top</string>
<string name="padding_bottom">Padding bottom</string> <string name="padding_bottom">Bottom</string>
<string name="padding_left">Padding left</string> <string name="padding_left">Left</string>
<string name="padding_right">Padding right</string> <string name="padding_right">Right</string>
<string name="check_book_source">Check book sources</string> <string name="check_book_source">Check book sources</string>
<string name="check_select_source">Check the selected source</string> <string name="check_select_source">Check the selected source</string>
<string name="progress_show">%1$s Progress %2$d/%3$d</string> <string name="progress_show">%1$s Progress %2$d/%3$d</string>
@@ -808,7 +808,7 @@
<string name="non_action">None</string> <string name="non_action">None</string>
<string name="body_title">Title</string> <string name="body_title">Title</string>
<string name="show_hide">Show/Hide</string> <string name="show_hide">Show/Hide</string>
<string name="header_footer">footer <![CDATA[&]]> header</string> <string name="header_footer">Footer <![CDATA[&]]> Header</string>
<string name="rule_subscription">Rule Subscription</string> <string name="rule_subscription">Rule Subscription</string>
<string name="rule_sub_empty_msg">Add the rule import address provided by the bosses\nClick to import rules after adding</string> <string name="rule_sub_empty_msg">Add the rule import address provided by the bosses\nClick to import rules after adding</string>
<string name="get_book_progress">Pull the cloud progress</string> <string name="get_book_progress">Pull the cloud progress</string>
@@ -854,7 +854,7 @@
<string name="list_src">List source code</string> <string name="list_src">List source code</string>
<string name="title_font_size">Font size</string> <string name="title_font_size">Font size</string>
<string name="title_margin_top">Margin top</string> <string name="title_margin_top">Margin top</string>
<string name="title_margin_bottom">Marigin bottom</string> <string name="title_margin_bottom">Margin bottom</string>
<string name="show">Show</string> <string name="show">Show</string>
<string name="hide">Hide</string> <string name="hide">Hide</string>
<string name="hide_when_status_bar_show">Hide when status bar show</string> <string name="hide_when_status_bar_show">Hide when status bar show</string>
@@ -1064,7 +1064,7 @@
<string name="replace_state_change">Replace (enable / disable)</string> <string name="replace_state_change">Replace (enable / disable)</string>
<string name="show_last_update_time">Show last updated time</string> <string name="show_last_update_time">Show last updated time</string>
<string name="refresh_list">Refresh list</string> <string name="refresh_list">Refresh list</string>
<string name="tip_divider_color">Separator color</string> <string name="tip_divider_color">Divider color</string>
<string name="same_title_removed">Remove duplicate title</string> <string name="same_title_removed">Remove duplicate title</string>
<string name="update_book_fail">Update failed</string> <string name="update_book_fail">Update failed</string>
<string name="notification_permission_rationale">Reading requires sending notifications to show reading control and download progress</string> <string name="notification_permission_rationale">Reading requires sending notifications to show reading control and download progress</string>
@@ -1147,4 +1147,5 @@
<string name="create_heap_dump">创建堆转储</string> <string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string> <string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string> <string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">N/B/L</string>
</resources> </resources>