pull/517/head
gedoor 4 years ago
parent f6420de9ff
commit c15c6237ef
  1. 1
      app/src/main/java/io/legado/app/constant/EventBus.kt
  2. 2
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  3. 6
      app/src/main/java/io/legado/app/help/ReadTipConfig.kt
  4. 7
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  5. 39
      app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt
  6. 30
      app/src/main/res/layout/dialog_tip_config.xml
  7. 1
      app/src/main/res/values-zh-rHK/strings.xml
  8. 1
      app/src/main/res/values-zh-rTW/strings.xml
  9. 1
      app/src/main/res/values-zh/strings.xml
  10. 1
      app/src/main/res/values/strings.xml

@ -23,4 +23,5 @@ object EventBus {
const val CHECK_SOURCE = "checkSource" const val CHECK_SOURCE = "checkSource"
const val CHECK_SOURCE_DONE = "checkSourceDone" const val CHECK_SOURCE_DONE = "checkSourceDone"
const val REPLACE_RULE_SAVE = "replaceRuleSave" const val REPLACE_RULE_SAVE = "replaceRuleSave"
const val TIP_COLOR = "tipColor"
} }

@ -350,6 +350,7 @@ object ReadBookConfig {
exportConfig.tipFooterLeft = shareConfig.tipFooterLeft exportConfig.tipFooterLeft = shareConfig.tipFooterLeft
exportConfig.tipFooterMiddle = shareConfig.tipFooterMiddle exportConfig.tipFooterMiddle = shareConfig.tipFooterMiddle
exportConfig.tipFooterRight = shareConfig.tipFooterRight exportConfig.tipFooterRight = shareConfig.tipFooterRight
exportConfig.tipColor = shareConfig.tipColor
exportConfig.headerMode = shareConfig.headerMode exportConfig.headerMode = shareConfig.headerMode
exportConfig.footerMode = shareConfig.footerMode exportConfig.footerMode = shareConfig.footerMode
} }
@ -405,6 +406,7 @@ object ReadBookConfig {
var tipFooterLeft: Int = ReadTipConfig.chapterTitle, var tipFooterLeft: Int = ReadTipConfig.chapterTitle,
var tipFooterMiddle: Int = ReadTipConfig.none, var tipFooterMiddle: Int = ReadTipConfig.none,
var tipFooterRight: Int = ReadTipConfig.pageAndTotal, var tipFooterRight: Int = ReadTipConfig.pageAndTotal,
var tipColor: Int = 0,
var headerMode: Int = 0, var headerMode: Int = 0,
var footerMode: Int = 0 var footerMode: Int = 0
) : Parcelable { ) : Parcelable {

@ -77,4 +77,10 @@ object ReadTipConfig {
set(value) { set(value) {
ReadBookConfig.config.footerMode = value ReadBookConfig.config.footerMode = value
} }
var tipColor: Int
get() = ReadBookConfig.config.tipColor
set(value) {
ReadBookConfig.config.tipColor = value
}
} }

@ -21,6 +21,7 @@ import io.legado.app.constant.Status
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
import io.legado.app.help.ReadTipConfig
import io.legado.app.help.storage.Backup import io.legado.app.help.storage.Backup
import io.legado.app.help.storage.SyncBookProgress import io.legado.app.help.storage.SyncBookProgress
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
@ -34,6 +35,7 @@ import io.legado.app.ui.book.info.BookInfoActivity
import io.legado.app.ui.book.read.config.* import io.legado.app.ui.book.read.config.*
import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.BG_COLOR import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.BG_COLOR
import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.TEXT_COLOR import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.TEXT_COLOR
import io.legado.app.ui.book.read.config.TipConfigDialog.Companion.TIP_COLOR
import io.legado.app.ui.book.read.page.ContentTextView import io.legado.app.ui.book.read.page.ContentTextView
import io.legado.app.ui.book.read.page.PageView import io.legado.app.ui.book.read.page.PageView
import io.legado.app.ui.book.read.page.TextPageFactory import io.legado.app.ui.book.read.page.TextPageFactory
@ -700,6 +702,11 @@ class ReadBookActivity : ReadBookBaseActivity(),
ReadBookConfig.upBg() ReadBookConfig.upBg()
postEvent(EventBus.UP_CONFIG, false) postEvent(EventBus.UP_CONFIG, false)
} }
TIP_COLOR -> {
ReadTipConfig.tipColor = color
postEvent(EventBus.TIP_COLOR, "")
postEvent(EventBus.UP_CONFIG, true)
}
} }
} }

@ -4,21 +4,24 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import com.jaredrummler.android.colorpicker.ColorPickerDialog
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseDialogFragment import io.legado.app.base.BaseDialogFragment
import io.legado.app.constant.EventBus import io.legado.app.constant.EventBus
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
import io.legado.app.help.ReadTipConfig import io.legado.app.help.ReadTipConfig
import io.legado.app.lib.dialogs.selector import io.legado.app.lib.dialogs.selector
import io.legado.app.utils.checkByIndex import io.legado.app.utils.*
import io.legado.app.utils.getIndexById
import io.legado.app.utils.postEvent
import kotlinx.android.synthetic.main.dialog_tip_config.* import kotlinx.android.synthetic.main.dialog_tip_config.*
import org.jetbrains.anko.sdk27.listeners.onCheckedChange import org.jetbrains.anko.sdk27.listeners.onCheckedChange
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
class TipConfigDialog : BaseDialogFragment() { class TipConfigDialog : BaseDialogFragment() {
companion object {
const val TIP_COLOR = 7897
}
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
dialog?.window dialog?.window
@ -36,6 +39,9 @@ class TipConfigDialog : BaseDialogFragment() {
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
initView() initView()
initEvent() initEvent()
observeEvent<String>(EventBus.TIP_COLOR) {
upTvTipColor()
}
} }
private fun initView() { private fun initView() {
@ -53,6 +59,17 @@ class TipConfigDialog : BaseDialogFragment() {
tv_footer_left.text = ReadTipConfig.tipFooterLeftStr tv_footer_left.text = ReadTipConfig.tipFooterLeftStr
tv_footer_middle.text = ReadTipConfig.tipFooterMiddleStr tv_footer_middle.text = ReadTipConfig.tipFooterMiddleStr
tv_footer_right.text = ReadTipConfig.tipFooterRightStr tv_footer_right.text = ReadTipConfig.tipFooterRightStr
upTvTipColor()
}
private fun upTvTipColor() {
tv_tip_color.text =
if (ReadTipConfig.tipColor == 0) {
"跟随正文"
} else {
"#${ReadTipConfig.tipColor.hexString}"
}
} }
private fun initEvent() { private fun initEvent() {
@ -134,6 +151,22 @@ class TipConfigDialog : BaseDialogFragment() {
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
} }
ll_tip_color.onClick {
selector(items = arrayListOf("跟随正文", "自定义")) { _, i ->
when (i) {
0 -> {
ReadTipConfig.tipColor = 0
upTvTipColor()
postEvent(EventBus.UP_CONFIG, true)
}
1 -> ColorPickerDialog.newBuilder()
.setShowAlphaSlider(false)
.setDialogType(ColorPickerDialog.TYPE_CUSTOM)
.setDialogId(TIP_COLOR)
.show(requireActivity())
}
}
}
} }
private fun clearRepeat(repeat: Int) = ReadTipConfig.apply { private fun clearRepeat(repeat: Int) = ReadTipConfig.apply {

@ -270,4 +270,34 @@
</LinearLayout> </LinearLayout>
<io.legado.app.ui.widget.text.AccentTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/header_footer"
android:textSize="18sp" />
<LinearLayout
android:id="@+id/ll_tip_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
tools:ignore="RtlHardcoded,RtlSymmetry">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="6dp"
android:text="@string/text_color" />
<TextView
android:id="@+id/tv_tip_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
tools:text="@string/text_color" />
</LinearLayout>
</LinearLayout> </LinearLayout>

@ -785,5 +785,6 @@
<string name="non_action">无操作</string> <string name="non_action">无操作</string>
<string name="body_title">正文标题</string> <string name="body_title">正文标题</string>
<string name="show_hide">显示/隐藏</string> <string name="show_hide">显示/隐藏</string>
<string name="header_footer">页眉<![CDATA[&]]>页脚</string>
</resources> </resources>

@ -786,5 +786,6 @@
<string name="non_action">无操作</string> <string name="non_action">无操作</string>
<string name="body_title">正文标题</string> <string name="body_title">正文标题</string>
<string name="show_hide">显示/隐藏</string> <string name="show_hide">显示/隐藏</string>
<string name="header_footer">页眉<![CDATA[&]]>页脚</string>
</resources> </resources>

@ -789,5 +789,6 @@
<string name="non_action">无操作</string> <string name="non_action">无操作</string>
<string name="body_title">正文标题</string> <string name="body_title">正文标题</string>
<string name="show_hide">显示/隐藏</string> <string name="show_hide">显示/隐藏</string>
<string name="header_footer">页眉<![CDATA[&]]>页脚</string>
</resources> </resources>

@ -792,5 +792,6 @@
<string name="non_action">无操作</string> <string name="non_action">无操作</string>
<string name="body_title">正文标题</string> <string name="body_title">正文标题</string>
<string name="show_hide">显示/隐藏</string> <string name="show_hide">显示/隐藏</string>
<string name="header_footer">footer <![CDATA[&]]> header</string>
</resources> </resources>

Loading…
Cancel
Save