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

View File

@ -26,6 +26,10 @@ object ReadTipConfig {
)
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
get() = ReadBookConfig.config.tipHeaderLeft
set(value) {

View File

@ -4,6 +4,7 @@ import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatRadioButton
import androidx.appcompat.widget.TooltipCompat
import io.legado.app.R
import io.legado.app.lib.theme.Selector
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.recycle()
initTheme()
TooltipCompat.setTooltipText(this, text)
}
private fun initTheme() {

View File

@ -11,6 +11,7 @@ import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.SeekBar
import androidx.appcompat.widget.TooltipCompat
import androidx.documentfile.provider.DocumentFile
import com.jaredrummler.android.colorpicker.ColorPickerDialog
import io.legado.app.R
@ -220,6 +221,9 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
.setDialogId(BG_COLOR)
.show(requireActivity())
}
binding.tvBgColor.apply {
TooltipCompat.setTooltipText(this, text)
}
binding.ivImport.setOnClickListener {
selectImportDoc.launch {
mode = HandleFileContract.FILE

View File

@ -15,7 +15,7 @@ import io.legado.app.ui.widget.text.StrokeTextView
class TextFontWeightConverter(context: Context, attrs: AttributeSet?) :
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 onChanged: (() -> Unit)? = null

View File

@ -75,19 +75,21 @@ class TipConfigDialog : BaseDialogFragment(R.layout.dialog_tip_config) {
}
private fun upTvTipColor() {
binding.tvTipColor.text =
if (ReadTipConfig.tipColor == 0) {
"跟随正文"
} else {
"#${ReadTipConfig.tipColor.hexString}"
}
val tipColorNames = ReadTipConfig.tipColorNames
val tipColor = ReadTipConfig.tipColor
binding.tvTipColor.text = if (tipColor == 0) {
tipColorNames.first()
} else {
"#${tipColor.hexString}"
}
}
private fun upTvTipDividerColor() {
binding.tvTipDividerColor.text = when (ReadTipConfig.tipDividerColor) {
-1 -> "默认"
0 -> "跟随文字颜色"
else -> "#${ReadTipConfig.tipDividerColor.hexString}"
val tipDividerColorNames = ReadTipConfig.tipDividerColorNames
val tipDividerColor = ReadTipConfig.tipDividerColor
binding.tvTipDividerColor.text = when (tipDividerColor) {
-1, 0 -> tipDividerColorNames[tipDividerColor + 1]
else -> "#${tipDividerColor.hexString}"
}
}
@ -179,13 +181,14 @@ class TipConfigDialog : BaseDialogFragment(R.layout.dialog_tip_config) {
}
}
llTipColor.setOnClickListener {
context?.selector(items = arrayListOf("跟随正文", "自定义")) { _, i ->
context?.selector(items = ReadTipConfig.tipColorNames) { _, i ->
when (i) {
0 -> {
ReadTipConfig.tipColor = 0
upTvTipColor()
postEvent(EventBus.UP_CONFIG, arrayOf(2))
}
1 -> ColorPickerDialog.newBuilder()
.setShowAlphaSlider(false)
.setDialogType(ColorPickerDialog.TYPE_CUSTOM)
@ -195,13 +198,14 @@ class TipConfigDialog : BaseDialogFragment(R.layout.dialog_tip_config) {
}
}
llTipDividerColor.setOnClickListener {
context?.selector(items = arrayListOf("默认", "跟随文字颜色", "自定义")) { _, i ->
context?.selector(items = ReadTipConfig.tipDividerColorNames) { _, i ->
when (i) {
0, 1 -> {
ReadTipConfig.tipDividerColor = i - 1
upTvTipDividerColor()
postEvent(EventBus.UP_CONFIG, arrayOf(2))
}
2 -> ColorPickerDialog.newBuilder()
.setShowAlphaSlider(false)
.setDialogType(ColorPickerDialog.TYPE_CUSTOM)

View File

@ -6,6 +6,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.FrameLayout
import android.widget.SeekBar
import androidx.appcompat.widget.TooltipCompat
import io.legado.app.R
import io.legado.app.databinding.ViewDetailSeekBarBinding
import io.legado.app.lib.theme.bottomBackground
@ -42,7 +43,11 @@ class DetailSeekBar @JvmOverloads constructor(
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.DetailSeekBar)
isBottomBackground =
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)
typedArray.recycle()
if (isBottomBackground && !isInEditMode) {

View File

@ -1144,4 +1144,5 @@
<string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources>

View File

@ -1147,4 +1147,5 @@
<string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources>

View File

@ -1147,4 +1147,5 @@
<string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources>

View File

@ -1143,4 +1143,5 @@ Còn </string>
<string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources>

View File

@ -1144,4 +1144,5 @@
<string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources>

View File

@ -1146,4 +1146,5 @@
<string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources>

View File

@ -103,4 +103,15 @@
<item>替换规则</item>
</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>

View File

@ -1146,4 +1146,5 @@
<string name="create_heap_dump">创建堆转储</string>
<string name="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">中/粗/细</string>
</resources>

View File

@ -158,4 +158,15 @@
<item>my</item>
</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>

View File

@ -288,10 +288,10 @@
<string name="bottom">Bottom</string>
<string name="top">Top</string>
<string name="padding">Padding</string>
<string name="padding_top">Padding top</string>
<string name="padding_bottom">Padding bottom</string>
<string name="padding_left">Padding left</string>
<string name="padding_right">Padding right</string>
<string name="padding_top">Top</string>
<string name="padding_bottom">Bottom</string>
<string name="padding_left">Left</string>
<string name="padding_right">Right</string>
<string name="check_book_source">Check book sources</string>
<string name="check_select_source">Check the selected source</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="body_title">Title</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_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>
@ -854,7 +854,7 @@
<string name="list_src">List source code</string>
<string name="title_font_size">Font size</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="hide">Hide</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="show_last_update_time">Show last updated time</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="update_book_fail">Update failed</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="record_heap_dump_s">当应用发生OOM崩溃时保存堆转储</string>
<string name="record_heap_dump_t">记录堆转储</string>
<string name="font_weight_text">N/B/L</string>
</resources>