From 49484a1f4a15ca4097b3bd6855e9612b100fbeb5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 11 Sep 2021 21:07:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 3 +++ app/src/main/java/io/legado/app/App.kt | 4 ---- app/src/main/java/io/legado/app/base/BaseActivity.kt | 8 -------- app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt | 7 +++++-- .../main/java/io/legado/app/ui/book/read/page/PageView.kt | 4 ++-- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 562bf79c8..3c8db5eb8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -150,6 +150,9 @@ dependencies { implementation('com.google.code.gson:gson:2.8.8') implementation('androidx.webkit:webkit:1.4.0') + //状态栏和导航栏 + implementation('com.gitee.zackratos:UltimateBarX:0.7.1') + //media implementation("androidx.media:media:1.4.1") def exoplayer_version = '2.15.0' diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 991097d3c..5ecda4c4a 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -84,8 +84,4 @@ class App : MultiDexApplication() { } } - companion object { - var navigationBarHeight = 0 - } - } 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 88f2ee150..86b3932e1 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -12,7 +12,6 @@ import android.view.View import android.widget.FrameLayout import androidx.appcompat.app.AppCompatActivity import androidx.viewbinding.ViewBinding -import io.legado.app.App import io.legado.app.R import io.legado.app.constant.AppConst import io.legado.app.constant.Theme @@ -79,13 +78,6 @@ abstract class BaseActivity( observeLiveBus() } - override fun onWindowFocusChanged(hasFocus: Boolean) { - super.onWindowFocusChanged(hasFocus) - if (hasFocus) { - App.navigationBarHeight = navigationBarHeight - } - } - override fun onMultiWindowModeChanged(isInMultiWindowMode: Boolean, newConfig: Configuration?) { super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig) findViewById(R.id.title_bar) 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 51e6df405..b797dd036 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 @@ -11,6 +11,7 @@ import android.widget.FrameLayout import android.widget.SeekBar import androidx.core.view.isGone import androidx.core.view.isVisible +import com.zackratos.ultimatebarx.ultimatebarx.navigationBarHeight import io.legado.app.R import io.legado.app.constant.PreferKey import io.legado.app.databinding.ViewReadMenuBinding @@ -246,8 +247,10 @@ class ReadMenu @JvmOverloads constructor( override fun onAnimationEnd(animation: Animation) { binding.vwMenuBg.setOnClickListener { runMenuOut() } - binding.vwNavigationBar.layoutParams = binding.vwNavigationBar.layoutParams.apply { - height = activity!!.navigationBarHeight + binding.vwNavigationBar.run { + layoutParams = layoutParams.apply { + height = navigationBarHeight + } } if (!LocalConfig.readMenuHelpVersionIsLast) { callBack.showReadMenuHelp() 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 ea34c2a74..696129147 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 @@ -7,7 +7,7 @@ import android.view.LayoutInflater import android.widget.FrameLayout import androidx.core.view.isGone import androidx.core.view.isInvisible -import io.legado.app.App +import com.zackratos.ultimatebarx.ultimatebarx.navigationBarHeight import io.legado.app.R import io.legado.app.base.BaseActivity import io.legado.app.constant.AppConst.timeFormat @@ -87,7 +87,7 @@ class PageView(context: Context) : FrameLayout(context) { pageNvBar.layoutParams = pageNvBar.layoutParams.apply { height = if (it.hideNavigationBar) 0 - else App.navigationBarHeight + else navigationBarHeight } } contentTextView.upVisibleRect()