XuqmGroup-AndroidSDK/sdk-webview
XuqmGroup 265994042e fix(sdk-webview): reject file picker result when MIME type doesn't match accepted types
Some devices show .doc files in the picker even when only .docx was
requested (accept=".docx"). Passing the .doc URI to the WebView renderer
could cause a native crash. Now we check the actual MIME type of the
selected file against the accepted list and cancel the upload if it does
not match, preventing the renderer from receiving an unexpected file type.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-23 11:27:21 +08:00
..
src/main fix(sdk-webview): reject file picker result when MIME type doesn't match accepted types 2026-06-23 11:27:21 +08:00
build.gradle.kts build: 各 SDK 模块独立版本,publish.gradle 改用 project.version 2026-05-21 16:48:10 +08:00
consumer-rules.pro chore: sync local changes 2026-05-07 19:39:38 +08:00
README.md docs: 添加 CLAUDE.md + 各 module README + sdk-webview JSBridge 补全 2026-06-16 12:14:54 +08:00

sdk-webview

XuqmGroup Android SDK WebView 模块。提供嵌入式 WebView 组件和独立页面,内置 JSBridge、文件选择、下载拦截。

依赖

implementation("com.xuqm:sdk-webview:VERSION")
implementation("com.xuqm:sdk-core:VERSION")  // 必须

使用

嵌入式组件

import com.xuqm.sdk.webview.XWebViewView
import com.xuqm.sdk.webview.XWebViewConfig

XWebViewView(
    config = XWebViewConfig(
        url = "https://example.com",
        title = "嵌入式网页",
    ),
)

独立页面

import com.xuqm.sdk.webview.openXWebView
import com.xuqm.sdk.webview.XWebViewConfig

openXWebView(XWebViewConfig(url = "https://example.com", title = "独立页面"))
// navigate("xwebview") 后使用 XWebViewScreen()

XWebViewConfig 参数

参数 类型 默认值 说明
url String "" 初始加载地址
title String "" 页面标题
hideToolbar Boolean false 隐藏顶栏
hideStatusBar Boolean false 隐藏状态栏
userAgent String? null 自定义 User-Agent
injectedJavaScript String? null 注入的 JS
jsBridgeName String "XWebViewBridge" JS 桥接对象名
debugEnabled Boolean false 开启远程调试
downloadDestination FileDownloadDestination Sandbox 下载存储目标
downloadNotificationTitle String? null 通知栏下载进度
onMessage (String) -> Unit? null H5 消息回调

JSBridge 通信

// H5 → Native
window.XWebViewBridge.postMessage(JSON.stringify({ type: 'login', token: '...' }))

// 监听下载进度
window.addEventListener('__xwvDownloadProgress', (e) => { ... })
window.addEventListener('__xwvDownloadDone', (e) => { ... })

文件选择与拍照

  • <input type="file"> + accept="image/*" + capture → 系统相机
  • <input type="file"> + .docx/.xlsx → 文件选择器
  • getUserMedia() WebRTC → 自动请求 CAMERA 权限