From 7225449c41cf652400104c235c39e27a1bfbdb67 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 9 Sep 2020 11:14:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=86=E5=B1=8F=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/ReadBookActivity.kt | 1 + .../ui/book/read/config/TipConfigDialog.kt | 8 ++------ .../app/ui/book/read/page/ContentView.kt | 20 ++++++++++++------- .../legado/app/ui/book/read/page/PageView.kt | 8 +++++++- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index fe21c3b40..22cf977c3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -125,6 +125,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) + page_view.upStatusBar() ReadBook.loadContent(resetPageOffset = false) } 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 325279977..583afb4d4 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 @@ -10,7 +10,6 @@ import io.legado.app.base.BaseDialogFragment import io.legado.app.constant.EventBus import io.legado.app.help.ReadTipConfig import io.legado.app.lib.dialogs.selector -import io.legado.app.ui.book.read.ReadBookActivityHelp import io.legado.app.utils.postEvent import kotlinx.android.synthetic.main.dialog_tip_config.* import org.jetbrains.anko.sdk27.listeners.onCheckedChange @@ -24,11 +23,8 @@ class TipConfigDialog : BaseDialogFragment() { activity?.let { it.windowManager?.defaultDisplay?.getMetrics(dm) } - dialog?.window?.let { - ReadBookActivityHelp.upSystemUiVisibility(it) - it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT) - } + dialog?.window + ?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) } override fun onCreateView( 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 66333c901..e89ee5ae8 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 @@ -7,17 +7,16 @@ import android.widget.FrameLayout import androidx.core.view.isGone import androidx.core.view.isInvisible import io.legado.app.R +import io.legado.app.base.BaseActivity import io.legado.app.constant.AppConst.timeFormat import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadTipConfig import io.legado.app.ui.book.read.page.entities.TextPage import io.legado.app.ui.book.read.page.provider.ChapterProvider import io.legado.app.ui.widget.BatteryView -import io.legado.app.utils.dp -import io.legado.app.utils.getCompatColor -import io.legado.app.utils.statusBarHeight -import io.legado.app.utils.visible +import io.legado.app.utils.* import kotlinx.android.synthetic.main.view_book_page.view.* +import org.jetbrains.anko.topPadding import java.util.* @@ -65,9 +64,7 @@ class ContentView(context: Context) : FrameLayout(context) { tv_footer_left.setColor(textColor) tv_footer_middle.setColor(textColor) tv_footer_right.setColor(textColor) - //显示状态栏时隐藏header - vw_status_bar.setPadding(0, context.statusBarHeight, 0, 0) - vw_status_bar.isGone = hideStatusBar + upStatusBar() ll_header.setPadding( headerPaddingLeft.dp, headerPaddingTop.dp, @@ -88,6 +85,15 @@ class ContentView(context: Context) : FrameLayout(context) { upBattery(battery) } + /** + * 显示状态栏时隐藏header + */ + fun upStatusBar() { + vw_status_bar.topPadding = context.statusBarHeight + vw_status_bar.isGone = + ReadBookConfig.hideStatusBar || (activity as? BaseActivity)?.isInMultiWindow == true + } + fun upTipStyle() { ReadTipConfig.apply { tv_header_left.isInvisible = tipHeaderLeft != chapterTitle diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index b2871d38c..3d4d6e266 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -85,9 +85,9 @@ class PageView(context: Context, attrs: AttributeSet) : override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { super.onSizeChanged(w, h, oldw, oldh) + centerRectF.set(width * 0.33f, height * 0.33f, width * 0.66f, height * 0.66f) prevPage.x = -w.toFloat() pageDelegate?.setViewSize(w, h) - centerRectF.set(width * 0.33f, height * 0.33f, width * 0.66f, height * 0.66f) if (oldw != 0 && oldh != 0) { ReadBook.loadContent(resetPageOffset = false) } @@ -180,6 +180,12 @@ class PageView(context: Context, attrs: AttributeSet) : return true } + fun upStatusBar() { + curPage.upStatusBar() + prevPage.upStatusBar() + nextPage.upStatusBar() + } + /** * 保存开始位置 */