diff --git a/app/src/main/java/io/legado/app/data/entities/rule/LogInRule.kt b/app/src/main/java/io/legado/app/data/entities/rule/LogInRule.kt new file mode 100644 index 000000000..f8046237c --- /dev/null +++ b/app/src/main/java/io/legado/app/data/entities/rule/LogInRule.kt @@ -0,0 +1,7 @@ +package io.legado.app.data.entities.rule + +data class LogInRule( + val ui: HashMap, + val logInUrl: String, + val checkJs: String +) \ No newline at end of file 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 0d9c0c146..73fe4ca0c 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 @@ -84,7 +84,9 @@ class PageView(context: Context) : FrameLayout(context) { vwTopDivider.visible(it.showHeaderLine) vwBottomDivider.visible(it.showFooterLine) pageNvBar.layoutParams = pageNvBar.layoutParams.apply { - height = if (it.hideNavigationBar) 0 else activity?.navigationBarHeight ?: 0 + height = + if (it.hideNavigationBar) 0 + else activity?.navigationBarHeight ?: 0 } } contentTextView.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 842a95bbe..a1d9e02a4 100644 --- a/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt @@ -3,6 +3,8 @@ package io.legado.app.utils import android.app.Activity import android.os.Build import android.util.DisplayMetrics +import android.view.View +import android.view.ViewGroup import android.view.WindowInsets import android.view.WindowMetrics @@ -22,13 +24,39 @@ val Activity.windowSize: DisplayMetrics return displayMetrics } + +/** + * 返回NavigationBar是否存在 + * 该方法需要在View完全被绘制出来之后调用,否则判断不了 + * 在比如 onWindowFocusChanged()方法中可以得到正确的结果 + */ +val Activity.isNavigationBarExist: Boolean + get() { + val viewGroup = window.decorView as? ViewGroup + if (viewGroup != null) { + for (i in 0 until viewGroup.childCount) { + viewGroup.getChildAt(i).context.packageName + if (viewGroup.getChildAt(i).id != View.NO_ID + && "navigationBarBackground" == resources.getResourceEntryName( + viewGroup.getChildAt( + i + ).id + ) + ) { + return true + } + } + } + return false + } + /** * 该方法需要在View完全被绘制出来之后调用,否则判断不了 * 在比如 onWindowFocusChanged()方法中可以得到正确的结果 */ val Activity.navigationBarHeight: Int get() { - if (SystemUtils.isNavigationBarExist(this)) { + if (isNavigationBarExist) { val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android") return resources.getDimensionPixelSize(resourceId) } diff --git a/app/src/main/java/io/legado/app/utils/SystemUtils.kt b/app/src/main/java/io/legado/app/utils/SystemUtils.kt index 4625ebeb1..f1c135306 100644 --- a/app/src/main/java/io/legado/app/utils/SystemUtils.kt +++ b/app/src/main/java/io/legado/app/utils/SystemUtils.kt @@ -8,15 +8,11 @@ import android.content.Intent import android.net.Uri import android.os.PowerManager import android.provider.Settings -import android.view.View -import android.view.ViewGroup @Suppress("unused") object SystemUtils { - private const val NAVIGATION = "navigationBarBackground" - fun getScreenOffTime(context: Context): Int { var screenOffTime = 0 kotlin.runCatching { @@ -49,29 +45,4 @@ object SystemUtils { } } - /** - * 返回NavigationBar是否存在 - * 该方法需要在View完全被绘制出来之后调用,否则判断不了 - * 在比如 onWindowFocusChanged()方法中可以得到正确的结果 - */ - fun isNavigationBarExist(activity: Activity?): Boolean { - activity?.let { - val viewGroup = it.window.decorView as? ViewGroup - if (viewGroup != null) { - for (i in 0 until viewGroup.childCount) { - viewGroup.getChildAt(i).context.packageName - if (viewGroup.getChildAt(i).id != View.NO_ID - && NAVIGATION == activity.resources.getResourceEntryName( - viewGroup.getChildAt( - i - ).id - ) - ) { - return true - } - } - } - } - return false - } }