From 9a46411a374ef1653a452c4e01dd7048428fea00 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 8 Mar 2020 20:25:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/help/ReadBookConfig.kt | 7 +++++++ .../app/ui/book/read/config/PaddingConfigDialog.kt | 11 +++++++++-- .../io/legado/app/ui/book/read/page/ContentView.kt | 1 + app/src/main/res/layout/dialog_read_padding.xml | 9 +++++---- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index b1a17905f..d0e67e901 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -251,6 +251,12 @@ object ReadBookConfig { if (shareLayout) shareConfig.footerPaddingTop = value else durConfig.footerPaddingTop = value + var showHeaderLine: Boolean + get() = if (shareLayout) shareConfig.showHeaderLine else durConfig.showHeaderLine + set(value) = + if (shareLayout) shareConfig.showHeaderLine = value + else durConfig.showHeaderLine = value + var showFooterLine: Boolean get() = if (shareLayout) shareConfig.showFooterLine else durConfig.showFooterLine set(value) = @@ -288,6 +294,7 @@ object ReadBookConfig { var footerPaddingLeft: Int = 16, var footerPaddingRight: Int = 16, var footerPaddingTop: Int = 6, + var showHeaderLine: Boolean = false, var showFooterLine: Boolean = true ) { fun setBg(bgType: Int, bg: String) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt index a19789fd3..ed1c296de 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt @@ -76,7 +76,8 @@ class PaddingConfigDialog : DialogFragment() { dsb_footer_padding_bottom.progress = footerPaddingBottom dsb_footer_padding_left.progress = footerPaddingLeft dsb_footer_padding_right.progress = footerPaddingRight - cb_show_line.isChecked = showFooterLine + cb_show_top_line.isChecked = showHeaderLine + cb_show_bottom_line.isChecked = showFooterLine } private fun initView() = with(ReadBookConfig) { @@ -131,7 +132,13 @@ class PaddingConfigDialog : DialogFragment() { footerPaddingRight = it postEvent(EventBus.UP_CONFIG, true) } - cb_show_line.onCheckedChangeListener = { cb, isChecked -> + cb_show_top_line.onCheckedChangeListener = { cb, isChecked -> + if (cb.isPressed) { + showHeaderLine = isChecked + postEvent(EventBus.UP_CONFIG, true) + } + } + cb_show_bottom_line.onCheckedChangeListener = { cb, isChecked -> if (cb.isPressed) { showFooterLine = isChecked postEvent(EventBus.UP_CONFIG, true) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt index 5ecc2bba3..96a2ce454 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt @@ -61,6 +61,7 @@ class ContentView(context: Context) : FrameLayout(context) { footerPaddingRight.dp, footerPaddingBottom.dp ) + vw_top_divider.visible(showHeaderLine) vw_bottom_divider.visible(showFooterLine) content_text_view.upVisibleRect() durConfig.textColor().let { diff --git a/app/src/main/res/layout/dialog_read_padding.xml b/app/src/main/res/layout/dialog_read_padding.xml index 79b89ec40..d867c6814 100644 --- a/app/src/main/res/layout/dialog_read_padding.xml +++ b/app/src/main/res/layout/dialog_read_padding.xml @@ -11,19 +11,20 @@ android:id="@+id/ll_header_padding" android:layout_width="match_parent" android:layout_height="wrap_content" - android:gravity="center_vertical" android:orientation="vertical"> @@ -128,7 +129,7 @@ android:text="@string/showLine" />