From 7d515e425eaf930b290d77a7caa7cd9214d2b973 Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:55:25 +0800 Subject: [PATCH] Fix missing navigation bar padding in page view --- .../main/java/io/legado/app/base/BaseActivity.kt | 13 ++++++++++++- .../io/legado/app/ui/book/read/ReadBookActivity.kt | 1 - .../app/ui/book/read/config/MoreConfigDialog.kt | 2 +- .../io/legado/app/ui/book/read/page/PageView.kt | 7 +++++++ app/src/main/res/layout/view_book_page.xml | 8 +++++++- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index 4cb60445564c..2434d744e9d6 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -25,7 +25,18 @@ import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.backgroundColor import io.legado.app.lib.theme.primaryColor import io.legado.app.ui.widget.TitleBar -import io.legado.app.utils.* +import io.legado.app.utils.ColorUtils +import io.legado.app.utils.applyBackgroundTint +import io.legado.app.utils.applyOpenTint +import io.legado.app.utils.applyTint +import io.legado.app.utils.disableAutoFill +import io.legado.app.utils.fullScreen +import io.legado.app.utils.hideSoftInput +import io.legado.app.utils.setLightStatusBar +import io.legado.app.utils.setNavigationBarColorAuto +import io.legado.app.utils.setStatusBarColorAuto +import io.legado.app.utils.toastOnUi +import io.legado.app.utils.windowSize abstract class BaseActivity( 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 0ee492cbe6d9..feb34948a22f 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 @@ -128,7 +128,6 @@ import io.legado.app.utils.visible import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.Job -import kotlinx.coroutines.Runnable import kotlinx.coroutines.delay import kotlinx.coroutines.ensureActive import kotlinx.coroutines.launch diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt index fe0df9e34ac2..9f00cb263217 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt @@ -117,7 +117,7 @@ class MoreConfigDialog : BasePrefDialogFragment() { PreferKey.hideNavigationBar -> { ReadBookConfig.hideNavigationBar = getPrefBoolean(PreferKey.hideNavigationBar) - postEvent(EventBus.UP_CONFIG, arrayListOf(0)) + postEvent(EventBus.UP_CONFIG, arrayListOf(0, 2)) } PreferKey.keepLight -> postEvent(key, true) 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 fdafca43d36b..571126830f5f 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 @@ -21,6 +21,7 @@ import io.legado.app.ui.book.read.page.entities.TextPos import io.legado.app.ui.book.read.page.provider.ChapterProvider import io.legado.app.ui.widget.BatteryView import io.legado.app.utils.activity +import io.legado.app.utils.applyNavigationBarPadding import io.legado.app.utils.applyStatusBarPadding import io.legado.app.utils.dpToPx import io.legado.app.utils.gone @@ -61,6 +62,7 @@ class PageView(context: Context) : FrameLayout(context) { if (!isInEditMode) { upStyle() binding.vwStatusBar.applyStatusBarPadding() + binding.vwNavigationBar.applyNavigationBarPadding() } } @@ -92,6 +94,7 @@ class PageView(context: Context) : FrameLayout(context) { vwTopDivider.backgroundColor = tipDividerColor vwBottomDivider.backgroundColor = tipDividerColor upStatusBar() + upNavigationBar() llHeader.setPadding( it.headerPaddingLeft.dpToPx(), it.headerPaddingTop.dpToPx(), @@ -119,6 +122,10 @@ class PageView(context: Context) : FrameLayout(context) { isGone = ReadBookConfig.hideStatusBar || readBookActivity?.isInMultiWindow == true } + fun upNavigationBar() { + binding.vwNavigationBar.isGone = ReadBookConfig.hideNavigationBar + } + /** * 更新阅读信息 */ diff --git a/app/src/main/res/layout/view_book_page.xml b/app/src/main/res/layout/view_book_page.xml index 81a0401076c5..656b4e8d46fb 100644 --- a/app/src/main/res/layout/view_book_page.xml +++ b/app/src/main/res/layout/view_book_page.xml @@ -96,7 +96,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" - app:layout_constraintBottom_toBottomOf="parent"> + app:layout_constraintBottom_toTopOf="@id/vw_navigation_bar"> + + \ No newline at end of file