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 5cbd9bac9..11602b208 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 @@ -381,7 +381,11 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo textActionMenu = TextActionMenu(this, this) } val x = cursor_left.x.toInt() + cursor_left.width - val y = (page_view.height - cursor_left.y + ReadBookConfig.textSize.dp * 1.5).toInt() + val y = if (cursor_left.y - statusBarHeight > ReadBookConfig.textSize.dp * 1.5 + 20.dp) { + (page_view.height - cursor_left.y + ReadBookConfig.textSize.dp * 1.5).toInt() + } else { + (page_view.height - cursor_left.y - cursor_left.height - 40.dp).toInt() + } textActionMenu?.let { popup -> if (!popup.isShowing) { popup.showAtLocation(cursor_left, Gravity.BOTTOM or Gravity.START, x, y) 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 12bbb6d8b..076215c40 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 @@ -201,7 +201,7 @@ class ReadMenu : FrameLayout { height = if (context.getPrefBoolean(PreferKey.hideNavigationBar) && Help.isNavigationBarExist(activity) - ) context.getNavigationBarHeight() + ) context.navigationBarHeight else 0 } } 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 2334e481a..5c387ac92 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 @@ -36,7 +36,7 @@ class ContentView(context: Context) : FrameLayout(context) { //显示状态栏时隐藏header if (context.getPrefBoolean(PreferKey.hideStatusBar, false)) { ll_header.layoutParams = - ll_header.layoutParams.apply { height = context.getStatusBarHeight() } + ll_header.layoutParams.apply { height = context.statusBarHeight } ll_header.setPadding( headerPaddingLeft.dp, headerPaddingTop.dp, @@ -47,7 +47,7 @@ class ContentView(context: Context) : FrameLayout(context) { page_panel.setPadding(0, 0, 0, 0) } else { ll_header.gone() - page_panel.setPadding(0, context.getStatusBarHeight(), 0, 0) + page_panel.setPadding(0, context.statusBarHeight, 0, 0) } content_text_view.setPadding( paddingLeft.dp, @@ -75,7 +75,7 @@ class ContentView(context: Context) : FrameLayout(context) { return if (context.getPrefBoolean(PreferKey.hideStatusBar, false)) { ll_header.height } else { - context.getStatusBarHeight() + context.statusBarHeight } } diff --git a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt index ab931f3ab..d19c8929f 100644 --- a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt @@ -12,8 +12,8 @@ import com.google.android.material.appbar.AppBarLayout import io.legado.app.R import io.legado.app.lib.theme.primaryColor import io.legado.app.utils.activity -import io.legado.app.utils.getNavigationBarHeight -import io.legado.app.utils.getStatusBarHeight +import io.legado.app.utils.navigationBarHeight +import io.legado.app.utils.statusBarHeight import org.jetbrains.anko.backgroundColor import org.jetbrains.anko.bottomPadding import org.jetbrains.anko.topPadding @@ -132,11 +132,11 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a } if (a.getBoolean(R.styleable.TitleBar_fitStatusBar, true)) { - topPadding = context.getStatusBarHeight() + topPadding = context.statusBarHeight } if (a.getBoolean(R.styleable.TitleBar_fitNavigationBar, false)) { - bottomPadding = context.getNavigationBarHeight() + bottomPadding = context.navigationBarHeight } backgroundColor = context.primaryColor diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index 5b266a343..cb1eb6fe9 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -30,7 +30,6 @@ fun Context.getPrefBoolean(key: String, defValue: Boolean = false) = fun Context.putPrefBoolean(key: String, value: Boolean = false) = defaultSharedPreferences.edit { putBoolean(key, value) } - fun Context.getPrefInt(key: String, defValue: Int = 0) = defaultSharedPreferences.getInt(key, defValue) @@ -79,12 +78,14 @@ fun Context.getScreenOffTime(): Int { return screenOffTime } -fun Context.getStatusBarHeight(): Int { +val Context.statusBarHeight: Int + get() { val resourceId = resources.getIdentifier("status_bar_height", "dimen", "android") return resources.getDimensionPixelSize(resourceId) } -fun Context.getNavigationBarHeight(): Int { +val Context.navigationBarHeight: Int + get() { val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android") return resources.getDimensionPixelSize(resourceId) }