XuqmGroup-AndroidSDK/sdk-webview
XuqmGroup d8ac97255d fix(file): 解决文件下载和时间戳处理问题
- 实现文件名扩展名推断逻辑,从URL路径自动提取并添加扩展名
- 添加下载错误处理和日志记录功能
- 在下载失败时显示错误通知而非成功通知
- 将服务器时间戳处理统一调整为CST(亚洲/上海)时区
- 更新sdk-core版本号至1.1.6-SNAPSHOT
2026-07-13 17:17:47 +08:00
..
src/main fix(file): 解决文件下载和时间戳处理问题 2026-07-13 17:17:47 +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 权限