feat: tipConfig

pull/193/head^2
kunfei 5 years ago
parent 3d971657f3
commit f363b467de
  1. 14
      app/src/main/java/io/legado/app/help/ReadTipConfig.kt
  2. 15
      app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt
  3. 14
      app/src/main/res/layout/dialog_tip_config.xml
  4. 2
      app/src/main/res/values/strings.xml

@ -2,7 +2,9 @@ package io.legado.app.help
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.getPrefInt import io.legado.app.utils.getPrefInt
import io.legado.app.utils.putPrefBoolean
import io.legado.app.utils.putPrefInt import io.legado.app.utils.putPrefInt
object ReadTipConfig { object ReadTipConfig {
@ -55,4 +57,16 @@ object ReadTipConfig {
set(value) { set(value) {
App.INSTANCE.putPrefInt("tipFooterRight", 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)
}
} }

@ -13,6 +13,7 @@ import io.legado.app.lib.dialogs.selector
import io.legado.app.ui.book.read.Help import io.legado.app.ui.book.read.Help
import io.legado.app.utils.postEvent 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.onClick import org.jetbrains.anko.sdk27.listeners.onClick
class TipConfigDialog : BaseDialogFragment() { class TipConfigDialog : BaseDialogFragment() {
@ -52,6 +53,8 @@ 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
sw_hide_header.isChecked = ReadTipConfig.hideHeader
sw_hide_footer.isChecked = ReadTipConfig.hideFooter
} }
private fun initEvent() { private fun initEvent() {
@ -97,6 +100,18 @@ class TipConfigDialog : BaseDialogFragment() {
postEvent(EventBus.UP_CONFIG, true) 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)
}
}
} }
} }

@ -108,4 +108,18 @@
</LinearLayout> </LinearLayout>
<Switch
android:id="@+id/sw_hide_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/hideHeader" />
<Switch
android:id="@+id/sw_hide_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/hideFooter" />
</LinearLayout> </LinearLayout>

@ -653,4 +653,6 @@
<string name="media_button_on_exit_summary">即使退出软件也响应耳机按键</string> <string name="media_button_on_exit_summary">即使退出软件也响应耳机按键</string>
<string name="middle"></string> <string name="middle"></string>
<string name="information">信息</string> <string name="information">信息</string>
<string name="hideHeader">隐藏页眉</string>
<string name="hideFooter">隐藏页脚</string>
</resources> </resources>

Loading…
Cancel
Save