From c558d64f3a6745a0ec34a40334cc0d4df7338676 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 17 Nov 2020 20:41:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=BC=E8=88=AA=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt | 3 +-- .../java/io/legado/app/ui/book/read/page/ContentView.kt | 2 +- .../main/java/io/legado/app/utils/ActivityExtensions.kt | 9 +++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt index e21e3ffe1..7570b2f8c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt @@ -237,8 +237,7 @@ class ReadMenu @JvmOverloads constructor( override fun onAnimationEnd(animation: Animation) { vw_menu_bg.onClick { runMenuOut() } vwNavigationBar.layoutParams = vwNavigationBar.layoutParams.apply { - height = - if (SystemUtils.isNavigationBarExist(activity)) context.navigationBarHeight else 0 + height = activity!!.navigationBarHeight } if (LocalConfig.isFirstReadMenuShow) { callBack.showReadMenuHelp() 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 7c470c34c..bcc375a69 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 @@ -85,7 +85,7 @@ class ContentView(context: Context) : FrameLayout(context) { vw_top_divider.visible(showHeaderLine) vw_bottom_divider.visible(showFooterLine) page_nv_bar.layoutParams = page_nv_bar.layoutParams.apply { - height = if (hideStatusBar) 0 else context.navigationBarHeight + height = if (hideNavigationBar) 0 else activity!!.navigationBarHeight } content_text_view.upVisibleRect() } diff --git a/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt b/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt index 689d5b443..c8a0531ec 100644 --- a/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt @@ -21,3 +21,12 @@ fun Activity.getSize(): DisplayMetrics { } return displayMetrics } + +val Activity.navigationBarHeight: Int + get() { + if (SystemUtils.isNavigationBarExist(this)) { + val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android") + return resources.getDimensionPixelSize(resourceId) + } + return 0 + } \ No newline at end of file