From f363b467de88774ff1f109b8fbb115def28e7360 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 19 Apr 2020 16:54:01 +0800 Subject: [PATCH] feat: tipConfig --- .../main/java/io/legado/app/help/ReadTipConfig.kt | 14 ++++++++++++++ .../app/ui/book/read/config/TipConfigDialog.kt | 15 +++++++++++++++ app/src/main/res/layout/dialog_tip_config.xml | 14 ++++++++++++++ app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 45 insertions(+) diff --git a/app/src/main/java/io/legado/app/help/ReadTipConfig.kt b/app/src/main/java/io/legado/app/help/ReadTipConfig.kt index 7aa97a104..8515fa07e 100644 --- a/app/src/main/java/io/legado/app/help/ReadTipConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadTipConfig.kt @@ -2,7 +2,9 @@ package io.legado.app.help import io.legado.app.App import io.legado.app.R +import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.getPrefInt +import io.legado.app.utils.putPrefBoolean import io.legado.app.utils.putPrefInt object ReadTipConfig { @@ -55,4 +57,16 @@ object ReadTipConfig { set(value) { App.INSTANCE.putPrefInt("tipFooterRight", value) } + + var hideHeader: Boolean + get() = App.INSTANCE.getPrefBoolean("hideHeader", true) + set(value) { + App.INSTANCE.putPrefBoolean("hideHeader", value) + } + + var hideFooter: Boolean + get() = App.INSTANCE.getPrefBoolean("hideFooter", false) + set(value) { + App.INSTANCE.putPrefBoolean("hideFooter", value) + } } \ No newline at end of file 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 280142c9f..cb9cfa594 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 @@ -13,6 +13,7 @@ import io.legado.app.lib.dialogs.selector import io.legado.app.ui.book.read.Help import io.legado.app.utils.postEvent import kotlinx.android.synthetic.main.dialog_tip_config.* +import org.jetbrains.anko.sdk27.listeners.onCheckedChange import org.jetbrains.anko.sdk27.listeners.onClick class TipConfigDialog : BaseDialogFragment() { @@ -52,6 +53,8 @@ class TipConfigDialog : BaseDialogFragment() { tv_footer_left.text = ReadTipConfig.tipFooterLeftStr tv_footer_middle.text = ReadTipConfig.tipFooterMiddleStr tv_footer_right.text = ReadTipConfig.tipFooterRightStr + sw_hide_header.isChecked = ReadTipConfig.hideHeader + sw_hide_footer.isChecked = ReadTipConfig.hideFooter } private fun initEvent() { @@ -97,6 +100,18 @@ class TipConfigDialog : BaseDialogFragment() { postEvent(EventBus.UP_CONFIG, true) } } + sw_hide_header.onCheckedChange { buttonView, isChecked -> + if (buttonView?.isPressed == true) { + ReadTipConfig.hideHeader = isChecked + postEvent(EventBus.UP_CONFIG, true) + } + } + sw_hide_footer.onCheckedChange { buttonView, isChecked -> + if (buttonView?.isPressed == true) { + ReadTipConfig.hideFooter = isChecked + postEvent(EventBus.UP_CONFIG, true) + } + } } } \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_tip_config.xml b/app/src/main/res/layout/dialog_tip_config.xml index f17910c20..9ef889a05 100644 --- a/app/src/main/res/layout/dialog_tip_config.xml +++ b/app/src/main/res/layout/dialog_tip_config.xml @@ -108,4 +108,18 @@ + + + + \ 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 abf628b2f..b3d77a73a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -653,4 +653,6 @@ 即使退出软件也响应耳机按键 信息 + 隐藏页眉 + 隐藏页脚