AppUpdater


Source link: https://github.com/javiersantos/AppUpdater

AppUpdater

Android Library

Android Library that checks for updates on Google Play, GitHub, Amazon, F-Droid or your own server. This library notifies your apps' updates by showing a Material dialog, Snackbar or notification. Check out the wiki.

Sample Project

You can download the latest sample APK from Google Play:

How to include

Add the repository to your project build.gradle:

repositories {

  maven {

url "https://jitpack.io"
  
}
 
}

And add the library to your module build.gradle:

dependencies {
     compile 'com.github.javiersantos:AppUpdater:2.6.3' 
}

Usage

Add INTERNET and ACCESS_NETWORK_STATE permissions to your app's Manifest:

<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Activity / Fragment

By default, the basic usage will show a default dialog when a new version is found on the Play Store (otherwise nothing will be shown). By calling the .start() method, the library will work in background. You can cancel it at any time by calling .stop(). Other customizations are explained below.

Activity

AppUpdater appUpdater = new AppUpdater(this);
 appUpdater.start();

Fragment

AppUpdater appUpdater = new AppUpdater(getActivity());
 appUpdater.start();

Customizations ( Wiki)

Displaying a dialog, Snackbar or notification

The default usage is configured to display a dialog. However, there are other ways to show the update notice.

new AppUpdater(this)  .setDisplay(Display.SNACKBAR)  .setDisplay(Display.DIALOG)  .setDisplay(Display.NOTIFICATION)  ...

When using Display.DIALOG, you can make the dialog dismissable when touching outside by using .setCancelable(false) (enabled by default).

When using Display.SNACKBAR, you can change the duration by using .setDuration(Duration.NORMAL) (default) or .setDuration(Duration.INDEFINITE).

Providing a source for the updates

By default the library will check for updates on the Play Store. However, there are other alternatives, such as GitHub, Amazon, F-Droid or using your own server.

new AppUpdater(this)  .setUpdateFrom(UpdateFrom.GITHUB)  .setUpdateFrom(UpdateFrom.GOOGLE_PLAY)  .setUpdateFrom(UpdateFrom.AMAZON)  .setUpdateFrom(UpdateFrom.FDROID)  .setUpdateFrom(UpdateFrom.XML)  .setUpdateFrom(UpdateFrom.JSON)  ...

When using GitHub you must provide the repo where the library will check for updates: .setGitHubUserAndRepo("javiersantos", "AppUpdater"). Check out the wiki for more details.

When using the XML source you must upload a .xml file somewhere on the Internet following the structure explained in the wiki and add the URL as shown in this example: .setUpdateXML("https://raw.githubusercontent.com/javiersantos/AppUpdater/master/app/update-changelog.xml").

When using the JSON source you must upload a .json file somewhere on the Internet following the structure explained in the wiki and add the URL as shown in this example: .setUpdateJSON("https://github.com/javiersantos/AppUpdater/wiki/UpdateFrom.JSON").

A detailed description with examples is available at: https://github.com/javiersantos/AppUpdater/wiki

Setting the frequency to show updates

By default, a dialog/Snackbar/notification will be shown whenever a new version is found. However, this can be set to show only every X times that the app ascertains that a new update is available.

new AppUpdater(this)  .showEvery(5)  ...

You can also show the dialog, Snackbar or notification although there aren't updates by using .showAppUpdated(true) (disabled by default).

Customizing the title, description, buttons and more

new AppUpdater(this)  .setTitleOnUpdateAvailable("Update available")  .setContentOnUpdateAvailable("Check out the latest version available of my app!")  .setTitleOnUpdateNotAvailable("Update not available")  .setContentOnUpdateNotAvailable("No update available. Check for updates again later!")  .setButtonUpdate("Update now?")  .setButtonUpdateClickListener(...)  .setButtonDismiss("Maybe later")  .setButtonDismissClickListener(...)  .setButtonDoNotShowAgain("Huh, not interested")  .setButtonDoNotShowAgainClickListener(...)  .setIcon(R.drawable.ic_update) // Notification icon   .setCancelable(false) // Dialog could not be dismissable  ...

By default, the "Don't show again" button will be displayed. Use .setButtonDoNotShowAgain(null) to hide the button.

AppUpdaterUtils

The AppUpdaterUtils class works in the same way that the AppUpdater class does, but it won't display any dialog, Snackbar or notification. When using the AppUpdaterUtils class you must provide a custom callback that will be called when the latest version has been checked.

Using custom callbacks

Adding a callback to the builder allows you to customize what will happen when the latest update has been checked. Keep in mind that when using this method you must be aware of displaying any dialog, snackbar or whatever you want to let the user know that there is a new update available.

AppUpdaterUtils appUpdaterUtils = new AppUpdaterUtils(this)
  //.setUpdateFrom(UpdateFrom.AMAZON)
  //.setUpdateFrom(UpdateFrom.GITHUB)
  //.setGitHubUserAndRepo("javiersantos", "AppUpdater")
  //...
  .withListener(new AppUpdaterUtils.UpdateListener() {

@Override

public void onSuccess(Update update, Boolean isUpdateAvailable) {

 Log.d("Latest Version", update.getLatestVersion());

Log.d("Latest Version Code", update.getLatestVersionCode());

Log.d("Release notes", update.getReleaseNotes());

Log.d("URL", update.getUrlToDownload());

Log.d("Is update available?", Boolean.toString(isUpdateAvailable));

}

@Override

public void onFailed(AppUpdaterError error) {

 Log.d("AppUpdater Error", "Something went wrong");

}

}
);
 appUpdaterUtils.start();

License

Copyright 2016 Javier Santos  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

ShowTipsView let you highligth specific points of interest of your app.

The RecyclerView widget is a more advanced and flexible version of ListView. This widget is a container for displaying large data sets that can be scrolled very efficiently by maintaining a limited number of views. Use the RecyclerView widget when you have data collections whose elements change at runtime based on user action or network events.

This project is modified SwipeList to work with RecyclerView.

A robust, powerful, and very simple ORM android database library with annotation processing.

The library eliminates the need for writing most SQL statements, writing ContentValues for every table, converting cursors into models, and so much more.

Let DBFlow make SQL code flow like a steady stream so you can focus on your complex problem and not be hindered by repetitive code writing.

What sets this library apart: baked in support for multiple databases seamlessly, powerful and fluid builder logic in expressing SQL statements, annotation processing to enable blistering speed, ModelContainer classes that enable direct to database parsing for data such as JSON, and rich interface classes that enable powerful flexibility.

RoundedLetterView looks like the one in Android 5.0 Contacts app.

Attributes:

  • titleText - The text in the first row.
  • titleSize - The size of the first row text.
  • titleColor - The color of the first row text.
  • backgroundColorValue - the color between the circle and the stroke.

ObservableScrollView is an Android library to observe scroll events on scrollable views.

It's easy to interact with the Toolbar introduced in Android 5.0 Lollipop and may be helpful to implement look and feel of Material Design apps.

AutoFitTextView is a TextView that automatically fit its font and line count based on its available size and content.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes