From 2a18eacf622e71226aa7216183ab1096ff288153 Mon Sep 17 00:00:00 2001 From: Kartikey Kushwaha Date: Sun, 12 Aug 2018 20:57:30 +0530 Subject: [PATCH] More refactoring. --- .../org/schabi/newpipe/CheckForNewAppVersionTask.java | 11 ++++------- app/src/main/res/values/strings.xml | 4 ++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersionTask.java b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersionTask.java index 2be4712a7..134fb3406 100644 --- a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersionTask.java +++ b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersionTask.java @@ -25,13 +25,15 @@ import java.net.URL; */ public class CheckForNewAppVersionTask extends AsyncTask { + private Application app = App.getContext(); + private String newPipeApiUrl = "https://newpipe.schabi.org/api/data.json"; private int timeoutPeriod = 10000; @Override protected void onPreExecute() { // Continue with version check only if the build variant is of type "github". - if (!BuildConfig.FLAVOR.equals("github")) { + if (!BuildConfig.FLAVOR.equals(app.getString(R.string.app_flavor_github))) { this.cancel(true); } } @@ -63,8 +65,7 @@ public class CheckForNewAppVersionTask extends AsyncTask { case 200: case 201: - BufferedReader bufferedReader - = new BufferedReader( + BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(connection.getInputStream())); StringBuilder stringBuilder = new StringBuilder(); @@ -134,8 +135,6 @@ public class CheckForNewAppVersionTask extends AsyncTask { if (!BuildConfig.VERSION_NAME.equals(versionName.replace("v", ""))) { - Application app = App.getContext(); - // A pending intent to open the apk location url in the browser. Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(apkLocationUrl)); PendingIntent pendingIntent @@ -152,8 +151,6 @@ public class CheckForNewAppVersionTask extends AsyncTask { + " " + versionName); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(app); - - // notificationId is a unique int for each notification that you must define notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build()); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6ad772494..f83324845 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -512,4 +512,8 @@ NewPipe Update Available Tap to download + + github + fdroid +