Home

Awesome

<p align="center"> <img src="https://raw.githubusercontent.com/SirLordPouya/AndroidAppUpdater/master/pics/icon.png" width="250"> </p>

Android App Updater

Android Arsenal Codacy Badge API ktlint

App Updater is an easy-to-use and fully customizable library to show update dialog to users. The update dialog can contain different app stores or direct download links. It can be used as a FragmentDialog or Composable.

<p align="center"> <img src="https://raw.githubusercontent.com/SirLordPouya/AndroidAppUpdater/master/pics/header.png" width="800"> </p>

Usage

Available stores

The library currently supports bellow markets:

App Store NameApp Store Enum
Google PlayStore.GOOGLE_PLAY
Huawei App GalleryStore.HUAWEI_APP_GALLERY
Samsung Galaxy StoreStore.SAMSUNG_GALAXY_STORE
Amazon App StoreStore.AMAZON_APP_STORE
Xiaomi GetApp MarketStore.MI_GET_APP_STORE
Oppo App MarketStore.OPPO_APP_MARKET
F-Droid App StoreStore.FDROID
Aptoide App StoreStore.APTOIDE
OneStore App MarketStore.ONE_STORE_APP_MARKET
Vivo V-AppStoreStore.V_APP_STORE
9-Apps MarketStore.NINE_APPS_STORE
ZTE App CenterStore.ZTE_APP_CENTER
Lenovo App CenterStore.LENOVO_APP_CENTER
Tencent App StoreStore.TENCENT_APPS_STORE
Cafe Bazaar StoreStore.CAFE_BAZAAR
Myket App StoreStore.MYKET

Showing stores

If you provide your application on above mentioned stores, you can list all of them in the update dialog. To create a new store:

val list = arrayListOf<StoreListItem>()
list.add(
    StoreListItem(
        store = Store.GOOGLE_PLAY,
        title = "Store Title",
        icon = R.drawable.appupdater_ic_google_play,
        url = "https://url/to/your/website",
        packageName = "YOUR_APPS_PACKAGE_NAME"
    )
)

Parameters of StoreListItem, in order:

orderParameter NameParameter TypeDescription
1storeStoreStore Enum (e.g. GOOGLE_PLAY, CAFE_BAZAAR, ...)
2titleStringTitle of the store that user sees
3iconIntIcon of the store that user sees
4urlStringAn url to open in a webview if the store is not installed in user's device
5packageNameStringPackage name of the application on the store

You can omit adding some properties in Kotlin:

list.add(
    StoreListItem(
        store = Store.GOOGLE_PLAY,
        title = "Google Play",
        packageName = "YOUR_APPS_PACKAGE_NAME"
    )
)

Direct Download

You can also make as many direct APK download links as you need. Users can download the APK directly on their phone. After downloading finishes, the install page will be shown to the user automatically.

list.add(
    StoreListItem(
        store = Store.DIRECT_URL,
        title = "Direct Download",
        url = "https://cafebazaar.ir/download/bazaar.apk"
    )
)

Remember to put WRITE_EXTERNAL_STORAGE, INTERNET and REQUEST_INSTALL_PACKAGES permissions in your manifest. The library asks for these permissions at runtime if needed

Show UpdateDialog with Jetpack Compose

You can show a native compose UpdateDialog to the user:

AndroidAppUpdaterTheme {
    AndroidAppUpdater(
        UpdaterDialogData(
            dialogTitle = "New Update !",
            dialogDescription = "Lots of new features! Update right now",
            storeList = list,
            theme = Theme.DARK
        )
    )
}

Parameters in the UpdaterDialogData in order are:

orderParameter NameParameter TypeDescription
1dialogTitleStringTitle of the update dialog
2dialogDescriptionStringDescription of the update dialog
3storeListList<UpdaterStoreList>List of Stores and Direct links to be shown to the user in the update dialog
4onDismissRequested() -> UnitGets invoked when the user requests to dismiss the dialog
5typefaceTypeface?Typeface to customize the font style if needed (You can omit this parameter if you don 't need it)
6themeThemeTheme of the dialog (can be set to Theme.Light, Theme.Dark or Theme.SYSTEM_DEFAULT)

Show UpdateDialog with Fragments

AppUpdaterDialog.getInstance(
    UpdaterDialogData(
        title = "New Update !",
        description = "Lots of new features! Update right now",
        storeList = list,
        isForceUpdate = false,
        typeface = typeface,
        theme = Theme.LIGHT
    )
).show(supportFragmentManager, TAG)

Parameters in the UpdaterDialogData in order are:

orderParameter NameParameter TypeDescription
1titleStringTitle of the update dialog
2descriptionStringDescription of the update dialog
3storeListList<UpdaterStoreList>List of Stores and Direct links to be shown to the user in the update dialog
4isForceUpdateBooleanMakes the dialog non-cancelable if sets to true
5typefaceTypeface?Typeface to customize the font style if needed (You can omit this parameter if you don't need it)
6themeThemeTheme of the dialog (can be set to Theme.Light, Theme.Dark or Theme.SYSTEM_DEFAULT)

Customizing dialog texts

If you need to customize any texts in the updater or the update in progress dialogs, you can add these strings resources in your strings.xml file to override them:


<resources>
    <string name="appupdater_please_wait">Please wait</string>
    <string name="appupdater_downloading_new_version">Downloading new version...</string>
    <string name="appupdater_download_notification_title">Downloading...</string>
    <string name="appupdater_download_notification_description">Downloading new version</string>
    <string name="appupdater_please_install">Please install</string>
    <string name="appupdater_or">or</string>
    <string name="appupdater_download_from_store">Download from store</string>
</resources>

Default icons

There are default icons of all stores included in the library. You can use them or use your own icons. Here is the list of icon names for each store:

Market NameIcon name
Google PlayR.drawable.appupdater_ic_google_play
Huawei App GalleryR.drawable.appupdater_ic_app_gallery
Samsung Galaxy StoreR.drawable.appupdater_ic_galaxy_store
Amazon App StoreR.drawable.appupdater_ic_amazon_app_store
Xiaomi GetApp StoreR.drawable.appupdater_ic_get_app_store
Oppo App MarketR.drawable.appupdater_ic_oppo_app_market
F-Droid App StoreR.drawable.appupdater_ic_fdroid
Aptoide App StoreR.drawable.appupdater_ic_aptoide
OneStore App MarketR.drawable.appupdater_ic_one_store
Vivo V-AppStoreR.drawable.appupdater_ic_v_app_store
9-Apps MarketR.drawable.appupdater_ic_nine_apps
ZTE App CenterR.drawable.appupdater_ic_zte_app_center
Lenovo App CenterR.drawable.appupdater_ic_lenovo_app_center
Tencent App StoreR.drawable.appupdater_ic_tencent_app_store
Cafe Bazaar StoreR.drawable.appupdater_ic_bazar
Myket App StoreR.drawable.appupdater_ic_myket

Note: Don't forget to add import for drawables <import com.pouyaheydari.appupdater.R.*>

Using library in Kotlin DSL style

This library also supports DSL.

Adding Stores in DSL

val list = listOf(
    store {
        store = Store.GOOGLE_PLAY
        title = "Store Title"
        icon = R.drawable.appupdater_ic_google_play
        url = "https://url/to/your/website"
        packageName = "YOUR_APPS_PACKAGE_NAME"
    })

Showing UpdateDialog in DSL

 updateDialogBuilder {
    title = "New Update !"
    description = "Lots of new features! Update right now"
    isForceUpdate = false
    typeface = Typeface.createFromAsset(assets, FONT_PATH)
    theme = Theme.DARK
    list = list
}.show(supportFragmentManager, TAG)

Check the demo application to see it in your IDE.

Download

Adding the dependency

Add this to your root build.gradle file:

allprojects {
    repositories {
        maven("https://jitpack.io")
    }
}

Then add these dependencies to your app build.gradle file:


// To use the library in Kotlin, Kotlin DSL or Java
implementation("com.github.SirLordPouya.AndroidAppUpdater:main:latest_version")

//To use the library with Jetpack Compose
implementation("com.github.SirLordPouya.AndroidAppUpdater:compose:latest_version")

License

Android App Updater is released under the Apache License 2.0. See LICENSE for details.
Copyright (c) 2018 Pouya Heydari

<div>Library's icon and style is designed by <a href="https://dribbble.com/Amirgk" title="Amir Gerdakane">Amir Gerdakane</a>