feat(device): implement scanCode API with CameraX/ML Kit/ZXing support#244
Open
jovkchan wants to merge 1 commit into
Open
feat(device): implement scanCode API with CameraX/ML Kit/ZXing support#244jovkchan wants to merge 1 commit into
jovkchan wants to merge 1 commit into
Conversation
- Add ScanCodeActivity with Jetpack Compose UI (camera preview, scan frame overlay, result panel) - Add ScanCodeHandler for camera permission and Activity result management - Register scanCode API in ScanApi with support for UI customization params - Integrate CameraX for camera preview, ML Kit (Android 9+) and ZXing (<9) for barcode decoding - Support non-continuous (single scan + confirm) and continuous (dedup + batch return) modes - Support square/circle/SVG custom scan frame shapes - Add CAMERA permission, uses-feature, and Activity declaration to AndroidManifest - Add CameraX, ML Kit Barcode, ZXing dependencies fix(core): ensure JSSDK integrity and improve WebView resource loading - Re-extract JSSDK if local files are missing even when version matches - Set text/javascript MIME type for .js files in WebViewCacheManager - Fallback to local storage if WebViewAssetLoader fails
dos1in
reviewed
Jun 3, 2026
| config = uiConfig, | ||
| ) { success, data -> | ||
| data.put("errMsg", if (success) "scanCode:ok" else data.optString("errMsg", "scanCode:fail")) | ||
| responseCallback(data.toString()) |
Member
There was a problem hiding this comment.
需要参考其他 api 实现,走 ApiUtils.invokeSuccess/Fail/Complete
dos1in
reviewed
Jun 3, 2026
| val oldVersionCode = VersionUtils.getJSVersion() | ||
| if (newVersionCode > oldVersionCode) { | ||
| // 检查本地存储的 JSSDK 文件是否实际存在 | ||
| val jsSdkDir = File(context.filesDir, "jssdk/$oldVersionCode/main") |
Member
There was a problem hiding this comment.
发布模式下 App 版本没变时,即使 files/jssdk//main/pageFrame.html 被删,也会直接走 “Skipping JSSDK update check”,建议把文件存在性检查移到外层,或把 !jsSdkFilesExist 纳入外层 shouldCheckJssdk 条件。
Member
扫码类型按微信标准,除了 wxCode。参照: wx.scanCode。 另外需要根据 scanType 初始化扫码解析器,而不是全量初始化。 |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


feat(device): 实现 scanCode 扫码 API,集成 CameraX / ML Kit / ZXing
新增 ScanCodeActivity,基于 Jetpack Compose 构建扫码界面(相机预览、扫描框覆盖层、结果面板)
新增 ScanCodeHandler,统一管理相机权限申请和 Activity 结果回调
在 ScanApi 中注册 API,支持前端传入自定义 UI 参数(标题、颜色、文案等)
集成 CameraX 实现相机预览,Android 9+ 使用 ML Kit、低于 Android 9 使用 ZXing 进行条码解码
支持非连续模式(单次扫码 + 确认)和连续模式(去重 + 批量返回)
支持方形、圆形、SVG 自定义三种扫描框形状
在 AndroidManifest.xml 中补充 CAMERA 权限、uses-feature 声明和 Activity 注册
添加 CameraX、ML Kit Barcode Scanning、ZXing 三方依赖
fix(core): 修复 JSSDK 完整性校验并优化 WebView 资源加载
JSSDK 本地文件缺失时,即使版本号未变更也触发重新解压,修复文件丢失后无法恢复的问题
在 WebViewCacheManager 中显式设置 .js 文件的 MIME 类型为 text/javascript,解决部分设备 MimeTypeMap 不完整导致 ES Module 加载失败
在 shouldInterceptRequest 中增加兜底逻辑:WebViewAssetLoader 加载失败时,直接从本地存储提供资源
第一次提交PR,请 甄 别。