diff --git a/app/src/main/java/io/legado/app/help/ReadTipConfig.kt b/app/src/main/java/io/legado/app/help/ReadTipConfig.kt new file mode 100644 index 000000000..6b4a1292c --- /dev/null +++ b/app/src/main/java/io/legado/app/help/ReadTipConfig.kt @@ -0,0 +1,59 @@ +package io.legado.app.help + +import io.legado.app.App +import io.legado.app.R +import io.legado.app.utils.getPrefInt +import io.legado.app.utils.putPrefInt + +object ReadTipConfig { + val tipArray = App.INSTANCE.resources.getStringArray(R.array.read_tip) + const val none = 0 + const val chapterTitle = 1 + const val time = 2 + const val battery = 3 + const val page = 4 + const val totalProgress = 5 + + val tipHeaderLeftStr: String = tipArray[tipHeaderLeft] + val tipHeaderMiddleStr: String = tipArray[tipHeaderMiddle] + val tipHeaderRightStr: String = tipArray[tipHeaderRight] + val tipFooterLeftStr: String = tipArray[tipFooterLeft] + val tipFooterMiddleStr: String = tipArray[tipFooterMiddle] + val tipFooterRightStr: String = tipArray[tipFooterRight] + + var tipHeaderLeft: Int + get() = App.INSTANCE.getPrefInt("tipHeaderLeft", time) + set(value) { + App.INSTANCE.putPrefInt("tipHeaderLeft", value) + } + + var tipHeaderMiddle: Int + get() = App.INSTANCE.getPrefInt("tipHeaderMiddle", none) + set(value) { + App.INSTANCE.putPrefInt("tipHeaderMiddle", value) + } + + var tipHeaderRight: Int + get() = App.INSTANCE.getPrefInt("tipHeaderRight", battery) + set(value) { + App.INSTANCE.putPrefInt("tipHeaderRight", value) + } + + var tipFooterLeft: Int + get() = App.INSTANCE.getPrefInt("tipFooterLeft", chapterTitle) + set(value) { + App.INSTANCE.putPrefInt("tipFooterLeft", value) + } + + var tipFooterMiddle: Int + get() = App.INSTANCE.getPrefInt("tipFooterMiddle", none) + set(value) { + App.INSTANCE.putPrefInt("tipFooterMiddle", value) + } + + var tipFooterRight: Int + get() = App.INSTANCE.getPrefInt("tipFooterRight", page) + set(value) { + App.INSTANCE.putPrefInt("tipFooterRight", value) + } +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index d0ca45b62..62fc63f8a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -123,6 +123,9 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { tv_padding.onClick { dismiss() callBack?.showPaddingConfig() + } + tv_tip.onClick { + } rg_page_anim.onCheckedChange { _, checkedId -> ReadBookConfig.pageAnim = rg_page_anim.getIndexById(checkedId) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt index 7e2774b67..4bcb355f3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt @@ -7,7 +7,11 @@ import android.view.View import android.view.ViewGroup import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.help.ReadTipConfig +import io.legado.app.lib.dialogs.selector import io.legado.app.ui.book.read.Help +import kotlinx.android.synthetic.main.dialog_tip_config.* +import org.jetbrains.anko.sdk27.listeners.onClick class TipConfigDialog : BaseDialogFragment() { @@ -35,8 +39,56 @@ class TipConfigDialog : BaseDialogFragment() { } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { + initView() + initEvent() + } + private fun initView() { + tv_header_left.text = ReadTipConfig.tipHeaderLeftStr + tv_header_middle.text = ReadTipConfig.tipHeaderMiddleStr + tv_header_right.text = ReadTipConfig.tipHeaderRightStr + tv_footer_left.text = ReadTipConfig.tipFooterLeftStr + tv_footer_middle.text = ReadTipConfig.tipFooterMiddleStr + tv_footer_right.text = ReadTipConfig.tipFooterRightStr } + private fun initEvent() { + tv_header_left.onClick { + selector(items = ReadTipConfig.tipArray.toList()) { _, i -> + ReadTipConfig.tipHeaderLeft = i + tv_header_left.text = ReadTipConfig.tipArray[i] + } + } + tv_header_middle.onClick { + selector(items = ReadTipConfig.tipArray.toList()) { _, i -> + ReadTipConfig.tipHeaderMiddle = i + tv_header_middle.text = ReadTipConfig.tipArray[i] + } + } + tv_header_right.onClick { + selector(items = ReadTipConfig.tipArray.toList()) { _, i -> + ReadTipConfig.tipHeaderRight = i + tv_header_right.text = ReadTipConfig.tipArray[i] + } + } + tv_footer_left.onClick { + selector(items = ReadTipConfig.tipArray.toList()) { _, i -> + ReadTipConfig.tipFooterLeft = i + tv_footer_left.text = ReadTipConfig.tipArray[i] + } + } + tv_footer_middle.onClick { + selector(items = ReadTipConfig.tipArray.toList()) { _, i -> + ReadTipConfig.tipFooterMiddle = i + tv_footer_middle.text = ReadTipConfig.tipArray[i] + } + } + tv_footer_right.onClick { + selector(items = ReadTipConfig.tipArray.toList()) { _, i -> + ReadTipConfig.tipFooterRight = i + tv_footer_right.text = ReadTipConfig.tipArray[i] + } + } + } } \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_read_book_style.xml b/app/src/main/res/layout/dialog_read_book_style.xml index 4adff8b72..9436e0f0a 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -121,6 +121,24 @@ android:textSize="14sp" app:radius="3dp" /> + + + + 系统等宽字体 + + + 标题 + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1b20632ff..abf628b2f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -652,4 +652,5 @@ 全程响应耳机按键 即使退出软件也响应耳机按键 + 信息