55 行
1.9 KiB
Markdown
55 行
1.9 KiB
Markdown
|
|
# 08 Android SDK 说明
|
|||
|
|
|
|||
|
|
## 当前模块拆分
|
|||
|
|
|
|||
|
|
- `commonsdk-core`
|
|||
|
|
- 网络能力:`HttpManager`、`RetrofitManager`
|
|||
|
|
- 下载能力:`DownloadManager`
|
|||
|
|
- 文件能力:`FileHelper`
|
|||
|
|
- 权限能力:`PermissionManager`
|
|||
|
|
- 缓存能力:`GlobalCache`、`SharedCacheManager`
|
|||
|
|
- 通信能力:`PluginMessenger`
|
|||
|
|
- 通用 UI 能力:`ToastCenter`、`DialogCenter`
|
|||
|
|
- 工具能力:`Logger`、`DateTimeUtils`
|
|||
|
|
- `commonsdk-compose`
|
|||
|
|
- 下拉刷新:`SwipeRefreshContainer`、`RefreshableLazyColumn`
|
|||
|
|
- 折叠面板:`AccordionPanel`、`RefreshableAccordionList`
|
|||
|
|
- 左滑操作:`SwipeActionItem`
|
|||
|
|
- WebView:`CommonWebView`、`WebViewPageActivity`
|
|||
|
|
- 图片:`AdaptiveImage`、`CircleImage`
|
|||
|
|
- `commonsdk-update`
|
|||
|
|
- 宿主更新:`AppUpdater`
|
|||
|
|
- 插件更新:`PluginPackageManager`
|
|||
|
|
- SDK 门面:`UpdateSDK`
|
|||
|
|
- 版本比较:`VersionComparator`
|
|||
|
|
|
|||
|
|
## 设计原则
|
|||
|
|
|
|||
|
|
- 下载与文件安装归 `core`,保证后续任意业务 SDK 都能复用。
|
|||
|
|
- 宿主更新和插件更新归 `commonsdk-update`,避免核心模块承担业务升级策略。
|
|||
|
|
- Compose 组件保持业务无关,App 可直接引用或二次封装。
|
|||
|
|
|
|||
|
|
## 接入方式
|
|||
|
|
|
|||
|
|
### 宿主应用
|
|||
|
|
|
|||
|
|
- 初始化基础 SDK:`CoreSDK.init(context, CoreSDK.SDKConfig(...))`
|
|||
|
|
- 使用更新能力:`UpdateSDK.appUpdater()`、`UpdateSDK.pluginPackageManager()`
|
|||
|
|
- 使用公共能力:`CoreSDK.fileHelper()`、`CoreSDK.cache()`、`CoreSDK.dialogCenter()`
|
|||
|
|
|
|||
|
|
### WebView 页面
|
|||
|
|
|
|||
|
|
- 内嵌组件:直接使用 `CommonWebView(url = "...")`
|
|||
|
|
- 独立页面:通过 `WebViewPageActivity.createIntent(context, url, title)` 跳转
|
|||
|
|
|
|||
|
|
### 权限申请
|
|||
|
|
|
|||
|
|
- 通过 `PermissionManager.register(...)` 注册权限请求器
|
|||
|
|
- 请求时传入权限标题和描述,框架会先弹出确认说明,再真正调用系统权限弹窗
|
|||
|
|
|
|||
|
|
## 当前验证
|
|||
|
|
|
|||
|
|
- 2026-03-27 已执行:
|
|||
|
|
- `./gradlew --no-daemon --no-configuration-cache :sample-app:assembleDebug :plugins:plugin-ui:assembleDebug`
|
|||
|
|
- 结果:构建通过
|