Skip to content

Commit e416b45

Browse files
committed
[update] 更新文档
1 parent 51b92cb commit e416b45

File tree

1 file changed

+56
-15
lines changed

1 file changed

+56
-15
lines changed

README.md

+56-15
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,13 @@
2121
- 由于各厂商 Android 定制化,最好能够统一处理应用没有安装权限的交互逻辑
2222

2323

24-
## 经过测试的机型
24+
## 如何使用
2525

26-
| 厂商 | 机型 | 系统版本 |
27-
| -------- | -----: | :----: |
28-
| 小米 | Redmi4 | Android 6.0.1 |
29-
| 华为 | 荣耀7i | Android 6.0.1 |
30-
| 华为 | 荣耀V8 | Android 7.0 |
31-
| 小米 | Note4X | Android 7.0 |
32-
| vivo | Y85A | Android 8.1.0 |
33-
| 华为 | 荣耀V10 | Android 9 |
34-
| 华为 | Mate20 | Android 9 |
35-
| vivo | x50 | Android 10 |
36-
| 荣耀 | Magic3 至臻版 | Android 11 |
37-
| 小米 | 小米 11 Ultra | Android 12 |
26+
添加依赖:
3827

39-
## 如何使用
28+
```
29+
implementation 'io.github.chiclaim:downloader:1.0.0'
30+
```
4031

4132
### 开始下载
4233
```
@@ -68,7 +59,7 @@ override fun onDownloadFailed(e: Throwable) {
6859
}
6960
```
7061

71-
### 移除监听
62+
**移除监听**
7263

7364
```
7465
override fun onDestroy() {
@@ -79,6 +70,56 @@ override fun onDestroy() {
7970

8071
> 注意:下载完成、下载失败都会自动移除监听器
8172
73+
### 默认升级弹窗
74+
75+
```
76+
UpgradeDialogActivity.launch(this, UpgradeDialogInfo().also {
77+
it.url = fileUrl
78+
it.ignoreLocal = ignoreLocalFile
79+
it.title = if (isForceUpdate) "重要安全升级" else "发现新版本"
80+
it.description = "1. 修复已知问题\n2. 修复已知问题"
81+
it.forceUpdate = isForceUpdate
82+
it.negativeText = if (isForceUpdate) "退出程序" else "取消"
83+
it.notifierSmallIcon = R.mipmap.ic_launcher
84+
it.backgroundDownload = isBackgroundDownload
85+
it.needInstall = needInstall
86+
})
87+
```
88+
89+
### 自定义升级弹窗
90+
91+
自定义升级弹窗非常简单,只需要在你的 Activity/Fragment/Dialog 调用:
92+
93+
```
94+
val request = DownloadRequest(applicationContext, url, mode)
95+
.setNotificationTitle(resources.getString(R.string.app_name))
96+
.setNotificationContent(getString(R.string.downloader_notifier_description))
97+
.setIgnoreLocal(ignoreLocalFile)
98+
.setNeedInstall(needInstall)
99+
.setNotificationVisibility(notifierVisibility)
100+
.setNotificationSmallIcon(R.mipmap.ic_launcher)
101+
.setShowNotificationDisableTip(notifierDisableTip)
102+
.registerListener(this) // 注册监听
103+
.startDownload()
104+
```
105+
106+
然后实现相应的监听即可,关闭自定义弹窗时移除件监听即可。
107+
108+
109+
## 经过测试的机型
110+
111+
| 厂商 | 机型 | 系统版本 |
112+
| -------- | -----: | :----: |
113+
| 小米 | Redmi4 | Android 6.0.1 |
114+
| 华为 | 荣耀7i | Android 6.0.1 |
115+
| 华为 | 荣耀V8 | Android 7.0 |
116+
| 小米 | Note4X | Android 7.0 |
117+
| vivo | Y85A | Android 8.1.0 |
118+
| 华为 | 荣耀V10 | Android 9 |
119+
| 华为 | Mate20 | Android 9 |
120+
| vivo | x50 | Android 10 |
121+
| 荣耀 | Magic3 至臻版 | Android 11 |
122+
| 小米 | 小米 11 Ultra | Android 12 |
82123

83124
## TODOs
84125

0 commit comments

Comments
 (0)