Added version code check.
This commit is contained in:
parent
2a18eacf62
commit
e7abeb5ad9
|
@ -209,7 +209,10 @@ public class App extends Application {
|
|||
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.createNotificationChannel(mChannel);
|
||||
|
||||
// Set up notification channel for app update
|
||||
// Set up notification channel for app update only if it's a github apk.
|
||||
|
||||
if (!BuildConfig.FLAVOR.equals(getString(R.string.app_flavor_github))) {
|
||||
|
||||
final String appUpdateId
|
||||
= getString(R.string.app_update_notification_channel_id);
|
||||
final CharSequence appUpdateName
|
||||
|
@ -225,6 +228,7 @@ public class App extends Application {
|
|||
= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
appUpdateNotificationManager.createNotificationChannel(appUpdateChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static RefWatcher getRefWatcher(Context context) {
|
||||
|
|
|
@ -112,10 +112,10 @@ public class CheckForNewAppVersionTask extends AsyncTask<Void, Void, String> {
|
|||
JSONObject githubStableObject = githubObject.getJSONObject("stable");
|
||||
|
||||
String versionName = githubStableObject.getString("version");
|
||||
// String versionCode = githubStableObject.getString("version_code");
|
||||
String versionCode = githubStableObject.getString("version_code");
|
||||
String apkLocationUrl = githubStableObject.getString("apk");
|
||||
|
||||
compareAppVersionAndShowNotification(versionName, apkLocationUrl);
|
||||
compareAppVersionAndShowNotification(versionName, apkLocationUrl, versionCode);
|
||||
|
||||
} catch (JSONException ex) {
|
||||
ex.printStackTrace();
|
||||
|
@ -129,11 +129,13 @@ public class CheckForNewAppVersionTask extends AsyncTask<Void, Void, String> {
|
|||
* @param versionName
|
||||
* @param apkLocationUrl
|
||||
*/
|
||||
private void compareAppVersionAndShowNotification(String versionName, String apkLocationUrl) {
|
||||
private void compareAppVersionAndShowNotification(String versionName,
|
||||
String apkLocationUrl,
|
||||
String versionCode) {
|
||||
|
||||
int NOTIFICATION_ID = 2000;
|
||||
|
||||
if (!BuildConfig.VERSION_NAME.equals(versionName.replace("v", ""))) {
|
||||
if (BuildConfig.VERSION_CODE < Integer.valueOf(versionCode)) {
|
||||
|
||||
// A pending intent to open the apk location url in the browser.
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(apkLocationUrl));
|
||||
|
|
Loading…
Reference in New Issue