XuqmGroup-AndroidSDK/sdk-webview
XuqmGroup 90975edc50 fix(sdk-webview): 修复中文文件名上传时变为下划线的问题
文件名 sanitize 正则从 [^a-zA-Z0-9_\-] 改为 [^\p{L}\p{N}_\-],
保留 Unicode 字母(含汉字)和数字,不再将中文替换为 _。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 14:18:43 +08:00
..
src/main fix(sdk-webview): 修复中文文件名上传时变为下划线的问题 2026-06-26 14:18:43 +08:00
build.gradle.kts fix: 移除库模块 isMinifyEnabled 修复 Duplicate class 冲突 2026-06-23 14:57:22 +08:00
consumer-rules.pro fix: 移除库模块 isMinifyEnabled 修复 Duplicate class 冲突 2026-06-23 14:57:22 +08:00
proguard-rules.pro fix: 移除库模块 isMinifyEnabled 修复 Duplicate class 冲突 2026-06-23 14:57:22 +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 权限