|
1 | 1 | # Android Version Status Resolver and Fetcher |
2 | 2 |
|
3 | 3 | ## Purpose of library |
4 | | -Many applications have need to tell users to update current application because they have outdated version. Google Play doesnt support any API for that so we need to use custom solution - even some api request or service like Firebase Remote Configuration. |
| 4 | +Many applications have need to tell users to update current application because they have outdated version. Google Play doesnt support any API for that so we need to use custom solution. This library will compare current application version number to the versions that are stored in remote locations (Api request/Firebase Remote Config, ...) and show dialog to user with prompt to update his app. |
5 | 5 |
|
6 | 6 | ## Usage |
7 | 7 | The simplest way for use this library is |
8 | 8 | ```java |
9 | 9 | val versionFetcher = ... |
10 | | - val versionHandler = new VersionHandler(versionFetcher) |
11 | | - versionHandler.checkVersionStatusAndShowDefault(BuildConfig.VERSION_CODE, getSupportFragmentManager()) |
| 10 | + val versionResolver = new VersionStatusResolver(versionFetcher) |
| 11 | + versionResolver.checkVersionStatusAndShowDefault(BuildConfig.VERSION_CODE, getSupportFragmentManager()) |
12 | 12 | ``` |
13 | 13 |
|
14 | | -this will check versions and show update dialog with the right settings. |
| 14 | +this will check versions and show update dialog with default texts. If you want to modify strings in dialog and maybe package name, you can via DialogSettings.Builder() class. |
15 | 15 |
|
16 | | -If you want to show custom UI with update info, you can use different method: |
| 16 | +```java |
| 17 | + val versionFetcher = ... |
| 18 | + val versionResolver = new VersionStatusResolver(versionFetcher) |
| 19 | + versionResolver.checkVersionStatusAndShowDefault(BuildConfig.VERSION_CODE, getSupportFragmentManager(), |
| 20 | + DialogSettings.Builder() |
| 21 | + .title("My custom title") |
| 22 | + .messageRes(R.string.update_dialog_message) |
| 23 | + .positiveButton("Yaay") |
| 24 | + .negativeButton("Never") |
| 25 | + .build()) |
| 26 | +``` |
| 27 | + |
| 28 | + |
| 29 | +If you want to show UI that built in dialog cant handle, you can use different method and based on result show particular UI: |
17 | 30 |
|
18 | 31 | ```java |
19 | 32 | val versionFetcher = ... |
20 | | -val versionHandler = new VersionHandler(versionFetcher) |
| 33 | +val versionResolver = new VersionStatusResolver(versionFetcher) |
21 | 34 |
|
22 | | -versionHandler.checkVersionStatus(BuildConfig.VERSION_CODE) |
| 35 | +versionResolver.checkVersionStatus(BuildConfig.VERSION_CODE) |
23 | 36 | .subscribe({ status -> |
24 | 37 | if(status == UP_TO_DATE) { |
25 | 38 | // app is up to date |
@@ -51,7 +64,7 @@ Class `RestVersionFetcher` accepts as argument base url of server. On url GET ${ |
51 | 64 | compile "cz.ackee.versionfetcher:rest-fetcher:x.x.x" |
52 | 65 | ``` |
53 | 66 | ## Dependencies |
54 | | - |
| 67 | +For current version check `gradle.properties` file |
55 | 68 | ```groovy |
56 | 69 | compile "cz.ackee.versionfetcher:status-resolver:x.x.x" |
57 | 70 | ``` |
0 commit comments