diff --git a/.changelog/lang_zh-Hans.json b/.changelog/lang_zh-Hans.json index 1f583fab..2997c656 100644 --- a/.changelog/lang_zh-Hans.json +++ b/.changelog/lang_zh-Hans.json @@ -15,7 +15,7 @@ "webview 元素支持基于 JsBridge 的 Web 页面布局 (Ref to [Auto.js Pro](https://g.pro.autojs.org/)) [参阅 示例代码 > 布局 > 可交互 HTML / Vue2 + Vant (SFC)] _[`issue #281`](http://issues.autojs6.com/281)_" ], "fix": [ - "主页文档标签显示在线文档时部分内容被系统导航栏遮挡的问题", + "主页文档标签及文档活动页面显示在线文档时部分内容被系统导航栏遮挡的问题", "部分设备代码编辑器空行显示方框字符的问题", "主题色设置页面调色盘对话框可能无限叠加的问题", "无障碍服务关闭时音量加键停止所有脚本功能失效的问题", diff --git a/app/src/main/java/org/autojs/autojs/ui/doc/DocumentationActivity.kt b/app/src/main/java/org/autojs/autojs/ui/doc/DocumentationActivity.kt index a85b070b..18b3a9e5 100644 --- a/app/src/main/java/org/autojs/autojs/ui/doc/DocumentationActivity.kt +++ b/app/src/main/java/org/autojs/autojs/ui/doc/DocumentationActivity.kt @@ -8,6 +8,7 @@ import org.autojs.autojs.util.DocsUtils.getUrl import org.autojs.autojs.util.ViewUtils import org.autojs.autojs.util.WebViewUtils import org.autojs.autojs6.databinding.ActivityDocumentationBinding +import org.intellij.lang.annotations.Language /** * Created by Stardust on Oct 24, 2017. @@ -31,7 +32,9 @@ class DocumentationActivity : BaseActivity() { if (ViewUtils.isNightModeYes(this)) { WebViewUtils.adaptDarkMode(webView) } - WebViewUtils.excludeWebViewFromStatusBarAndNavigationBar(ewebView, webView) + WebViewUtils.excludeWebViewFromStatusBarAndNavigationBar(ewebView, webView) { + generateInjectCodeForBottomInsets(it) + } webView.loadUrl(intent.getStringExtra(EXTRA_URL) ?: getUrl("index.html")) } } @@ -57,6 +60,26 @@ class DocumentationActivity : BaseActivity() { const val EXTRA_URL = "url" + fun generateInjectCodeForBottomInsets(systemBarInsetsBottom: Int): String { + @Language("JavaScript") + val injectCode = """ + (function() { + let mainElements = document.querySelectorAll('main > *'); + if (mainElements.length > 0) { + // Online docs (zh-CN: 在线文档) + mainElements.forEach(ele => { + let basePaddingBottom = ele.className === 'sidebar-toggle' ? 10 : 0; + ele.style.paddingBottom = (basePaddingBottom + ${systemBarInsetsBottom}) / window.devicePixelRatio + 'px'; + }); + } else { + // Local docs (zh-CN: 本地文档) + document.body.style.paddingBottom = '${systemBarInsetsBottom}px'; + } + })(); + """.trimIndent() + return injectCode + } + } } \ No newline at end of file diff --git a/app/src/main/java/org/autojs/autojs/ui/doc/DocumentationFragment.kt b/app/src/main/java/org/autojs/autojs/ui/doc/DocumentationFragment.kt index c13e7e7f..e8b8aead 100644 --- a/app/src/main/java/org/autojs/autojs/ui/doc/DocumentationFragment.kt +++ b/app/src/main/java/org/autojs/autojs/ui/doc/DocumentationFragment.kt @@ -9,6 +9,7 @@ import android.webkit.WebView import com.google.android.material.floatingactionbutton.FloatingActionButton import com.google.android.material.tabs.TabLayout import org.autojs.autojs.event.BackPressedHandler +import org.autojs.autojs.ui.doc.DocumentationActivity.Companion.generateInjectCodeForBottomInsets import org.autojs.autojs.ui.fragment.BindingDelegates.viewBinding import org.autojs.autojs.ui.main.MainActivity import org.autojs.autojs.ui.main.QueryEvent @@ -21,7 +22,6 @@ import org.autojs.autojs6.R import org.autojs.autojs6.databinding.FragmentOnlineDocsBinding import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.Subscribe -import org.intellij.lang.annotations.Language /** * Created by Stardust on Aug 22, 2017. @@ -60,24 +60,8 @@ class DocumentationFragment : ViewPagerFragment(ROTATION_GONE), BackPressedHandl if (ViewUtils.isNightModeYes(requireContext())) { WebViewUtils.adaptDarkMode(webView) } - WebViewUtils.excludeWebViewFromNavigationBar(ewebView, webView) { systemBarInsetsBottom -> - @Language("JavaScript") - val injectCode = """ - (function() { - let mainElements = document.querySelectorAll('main > *'); - if (mainElements.length > 0) { - // Online docs (zh-CN: 在线文档) - mainElements.forEach(ele => { - let basePaddingBottom = ele.className === 'sidebar-toggle' ? 10 : 0; - ele.style.paddingBottom = (basePaddingBottom + ${systemBarInsetsBottom}) / window.devicePixelRatio + 'px'; - }); - } else { - // Local docs (zh-CN: 本地文档) - document.body.style.paddingBottom = '${systemBarInsetsBottom}px'; - } - })(); - """.trimIndent() - injectCode + WebViewUtils.excludeWebViewFromNavigationBar(ewebView, webView) { + generateInjectCodeForBottomInsets(it) } } } diff --git a/app/src/main/java/org/autojs/autojs/util/WebViewUtils.kt b/app/src/main/java/org/autojs/autojs/util/WebViewUtils.kt index 0b9915ec..230793a1 100644 --- a/app/src/main/java/org/autojs/autojs/util/WebViewUtils.kt +++ b/app/src/main/java/org/autojs/autojs/util/WebViewUtils.kt @@ -81,6 +81,10 @@ class WebViewUtils { excludeWebViewFromSystemBars(webViewWrapper, webView, excludeStatusBar = true, excludeNavigationBar = true) } + fun excludeWebViewFromStatusBarAndNavigationBar(webViewWrapper: View, webView: WebView, excludeNavigationBarInjectCode: (systemBarInsetsBottom: Int) -> String) { + excludeWebViewFromSystemBars(webViewWrapper, webView, excludeStatusBar = true, excludeNavigationBarInjectCode = excludeNavigationBarInjectCode) + } + private fun excludeWebViewFromSystemBars(webViewWrapper: View, webView: WebView, excludeStatusBar: Boolean, excludeNavigationBarInjectCode: (systemBarInsetsBottom: Int) -> String) { var mSystemBarInsets: Insets? = null ViewCompat.setOnApplyWindowInsetsListener(webViewWrapper) { v, insets -> diff --git a/version.properties b/version.properties index dec680cc..3f269eab 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ -#Sun May 25 23:31:03 CST 2025 -BUILD_TIME=1748187063682 +#Mon May 26 00:57:45 CST 2025 +BUILD_TIME=1748192265701 COMPILE_SDK_VERSION=35 IMAGE_QUANT_CMAKE_VERSION=3.22.1 IMAGE_QUANT_NDK_VERSION=26.1.10909125 @@ -19,6 +19,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13 RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3 TARGET_SDK_VERSION=35 TARGET_SDK_VERSION_INRT=29 -VERSION_BUILD=3255 +VERSION_BUILD=3256 VERSION_NAME=6.6.3 Alpha5 VSCODE_EXT_REQUIRED_VERSION=1.0.8