33<p align =" center " ><img src =" https://github.com/azhon/AppUpdate/blob/main/img/logo.png " ></p >
44<p align =" center " >
55 <img src =" https://img.shields.io/badge/miniSdk-15%2B-blue.svg " >
6- <img src =" https://img.shields.io/badge/jitpack%20version-3 .0.7 -brightgreen.svg " >
6+ <img src =" https://img.shields.io/badge/jitpack%20version-4 .0.0 -brightgreen.svg " >
77 <img src =" https://img.shields.io/badge/author-azhon-%23E066FF.svg " >
88 <img src =" https://img.shields.io/badge/license-Apache2.0-orange.svg " >
99</p >
1515* Rendering
1616* Function introduction
1717* Demo download experience
18- * DownloadManager
19- * UpdateConfiguration
2018* Steps for usage
2119* Skills
2220* Version update record
4341* [x] Support download completion Delete old APK file after opening new version
4442* [x] Download using HttpURLConnection, no other third-party framework is integrated
4543
46- ### [ Demo download experience] ( https://github.com/azhon/AppUpdate/releases/tag/3.0.7 )
47-
48- ### DownloadManager:Configuration Doc
49-
50- > Initial use` DownloadManager.getInstance(this) `
51-
52- | Attributes | Description | Default Value | Must be set |
53- | :-------------- | :---------------------------------------------------------------------------------------------------------------------------- | :--------------------- | :----------- |
54- | context | Context | null | true |
55- | apkUrl | Apk download Url | null | true |
56- | apkName | Apk download name | null | true |
57- | downloadPath | apk download path(2.7.0 or higher is deprecated) | getExternalCacheDir() | false |
58- | showNewerToast | Whether to prompt the user<br > "currently the latest version" toast | false | false |
59- | smallIcon | Notification icon (resource id) | -1 | true |
60- | configuration | Additional configuration of this library | null | false |
61- | apkVersionCode | new apk versionCode <br >(If set, the version will be judged in the library,<br >The following properties also need to be set) | Integer.MIN_VALUE | false |
62- | apkVersionName | new apk versionName | null | false |
63- | apkDescription | Update description | null | false |
64- | apkSize | New version of the apk size (unit M) | null | false |
65- | apkMD5 | Md5 (32 bit) of the new apk | null | false |
66-
67- ### UpdateConfiguration:Configuration Doc
68-
69- | Attributes | Description | Default Value |
70- | :--------------------- | :--------------------------------------------------------------------------------------- | :-------------------------- |
71- | notifyId | notification id | 1011 |
72- | notificationChannel | Adapt to Android O notifications | See the source for details |
73- | httpManager | Set up your own download process | null |
74- | enableLog | Whether need to log output | true |
75- | onDownloadListener | Callback of the download process | null |
76- | jumpInstallPage | Whether the download completes automatically<br > pops up the installation page | true |
77- | showNotification | Whether to display the progress of the<br > notification bar (background download toast) | true |
78- | forcedUpgrade | Whether to force an upgrade | false |
79- | showBgdToast | Whether need to “Downloading new version in the background…” | true |
80- | usePlatform | Whether to use AppUpdate website | true |
81- | onButtonClickListener | Button click event listener | null |
82- | dialogImage | Dialog background image resource<br > (picture specification reference demo) | -1 |
83- | dialogButtonColor | The color of the dialog button | -1 |
84- | dialogButtonTextColor | The text color of the dialog button | -1 |
85- | dialogProgressBarColor | Dialog progress bar and text color | -1 |
44+ ### [ Demo download experience] ( https://github.com/azhon/AppUpdate/releases/tag/4.0.0 )
8645
8746### Steps for usage
8847
@@ -102,24 +61,23 @@ allprojects {
10261- ` app/build.gradle `
10362
10463``` groovy
105- implementation 'com.github.azhon:AppUpdate:3 .0.7 '
64+ implementation 'com.github.azhon:AppUpdate:4 .0.0 '
10665```
10766
108- #### Step2:Create ` DownloadManager ` ,For more usage, please see [ sample code here] ( https://github.com/azhon/AppUpdate/blob/main/app/src/main/java/com/azhon/app/MainActivity.java )
67+ #### Step2:Create ` DownloadManager ` ,For more usage, please see [ sample code here] ( https://github.com/azhon/AppUpdate/blob/main/app/src/main/java/com/azhon/app/MainActivity.kt )
10968
11069``` java
111- UpdateConfiguration configuration = new UpdateConfiguration ()
112-
113- DownloadManager manager = DownloadManager . getInstance(this );
114- manager. setApkName(" appupdate.apk" )
115- .setApkUrl(" https://raw.githubusercontent.com/azhon/AppUpdate/main/apk/appupdate.apk" )
116- .setSmallIcon(R . mipmap. ic_launcher)
117- // Optional parameters
118- .setConfiguration(configuration)
119- // If this parameter is set, it will automatically determine whether to show tip dialog
120- .setApkVersionCode(2 )
121- .setApkDescription(" description..." )
122- .download();
70+ val manager = DownloadManager . Builder(this ). run {
71+ apkUrl(" your apk url" )
72+ apkName(" appupdate.apk" )
73+ smallIcon(R . mipmap. ic_launcher)
74+ // If this parameter is set, it will automatically determine whether to show tip dialog
75+ apkVersionCode(2 )
76+ apkDescription(" description..." )
77+ // Optional parameters...
78+ build()
79+ }
80+ manager? . download()
12381```
12482
12583#### Step3:ProGuard Rules
@@ -137,21 +95,21 @@ manager.setApkName("appupdate.apk")
13795
13896``` java
13997// Old version apk file save path
140- boolean b = ApkUtil . deleteOldApk(this , getExternalCacheDir() . getPath() + " /appupdate.apk" );
98+ val result = ApkUtil . deleteOldApk(this , " ${externalCacheDir?.path} /appupdate.apk" )
14199```
142100
143101* Tips: The contents of the upgrade dialog can be swiped up and down!
144102* If you need to implement your own set of download process, you only need to ` extends ` ` BaseHttpDownloadManager ` and update the progress with listener.
145103
146104``` java
147- public class MyDownload extends BaseHttpDownloadManager {}
105+ class MyDownload : BaseHttpDownloadManager() {}
148106```
149107
150108### Version update record
151109
152- * v3 .0.7 (2022/02/19 )
110+ * v4 .0.0 (2022/04/08 )
153111
154- * [ Fix ] Fix the problem of content leakage when the host activity is destroy
112+ * [ Refactor ] Refactoring with Kotlin and coroutines
155113
156114#### [ More update records click here to view] ( https://github.com/azhon/AppUpdate/wiki/更新日志 )
157115
0 commit comments