diff --git a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java
index 9c392be1e..7e5eb0f77 100644
--- a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java
+++ b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java
@@ -175,9 +175,8 @@ public final class CheckForNewAppVersion extends IntentService {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(app);
final NewVersionManager manager = new NewVersionManager();
- // Check if user has enabled/disabled update checking
- // and if the current apk is a github one or not.
- if (!prefs.getBoolean(app.getString(R.string.update_app_key), true) || !isGithubApk(app)) {
+ // Check if the current apk is a github one or not.
+ if (!isGithubApk(app)) {
return;
}
@@ -213,6 +212,7 @@ public final class CheckForNewAppVersion extends IntentService {
// Parse the json from the response.
try {
+
final JsonObject githubStableObject = JsonParser.object()
.from(response.responseBody()).getObject("flavors")
.getObject("github").getObject("stable");
diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java
index 1855d45cd..0a49e00e4 100644
--- a/app/src/main/java/org/schabi/newpipe/MainActivity.java
+++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java
@@ -169,10 +169,16 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onPostCreate(final Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
- // Start the service which is checking all conditions
- // and eventually searching for a new version.
- // The service searching for a new NewPipe version must not be started in background.
- startNewVersionCheckService();
+
+ final App app = App.getApp();
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(app);
+
+ if (prefs.getBoolean(app.getString(R.string.update_app_key), true)) {
+ // Start the service which is checking all conditions
+ // and eventually searching for a new version.
+ // The service searching for a new NewPipe version must not be started in background.
+ startNewVersionCheckService();
+ }
}
private void setupDrawer() throws ExtractionException {
diff --git a/app/src/main/java/org/schabi/newpipe/settings/MainSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/MainSettingsFragment.java
index 0eebfb5a2..4d847056e 100644
--- a/app/src/main/java/org/schabi/newpipe/settings/MainSettingsFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/settings/MainSettingsFragment.java
@@ -17,11 +17,9 @@ public class MainSettingsFragment extends BasePreferenceFragment {
addPreferencesFromResource(R.xml.main_settings);
if (!CheckForNewAppVersion.isGithubApk(App.getApp())) {
- if (!DEBUG) {
- final Preference update
- = findPreference(getString(R.string.update_pref_screen_key));
- getPreferenceScreen().removePreference(update);
- }
+ final Preference update
+ = findPreference(getString(R.string.update_pref_screen_key));
+ getPreferenceScreen().removePreference(update);
defaultPreferences.edit().putBoolean(getString(R.string.update_app_key), false).apply();
}
diff --git a/app/src/main/java/org/schabi/newpipe/settings/UpdateSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/UpdateSettingsFragment.java
index 0fdf96757..339f6571b 100644
--- a/app/src/main/java/org/schabi/newpipe/settings/UpdateSettingsFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/settings/UpdateSettingsFragment.java
@@ -1,8 +1,7 @@
package org.schabi.newpipe.settings;
-import android.content.Intent;
-import android.net.Uri;
import android.os.Bundle;
+import android.widget.Toast;
import androidx.preference.Preference;
@@ -11,30 +10,32 @@ import org.schabi.newpipe.R;
import static org.schabi.newpipe.CheckForNewAppVersion.startNewVersionCheckService;
public class UpdateSettingsFragment extends BasePreferenceFragment {
- private static final String RELEASES_URL = "https://github.com/TeamNewPipe/NewPipe/releases";
-
private final Preference.OnPreferenceChangeListener updatePreferenceChange
= (preference, checkForUpdates) -> {
defaultPreferences.edit()
.putBoolean(getString(R.string.update_app_key), (boolean) checkForUpdates).apply();
if ((boolean) checkForUpdates) {
- // Search for updates immediately when update checks are enabled.
- // Reset the expire time. This is necessary to check for an update immediately.
- defaultPreferences.edit()
- .putLong(getString(R.string.update_expiry_key), 0).apply();
- startNewVersionCheckService();
+ checkNewVersionNow();
}
return true;
};
private final Preference.OnPreferenceClickListener manualUpdateClick
= preference -> {
- final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(RELEASES_URL));
- startActivity(browserIntent);
+ Toast.makeText(getContext(), R.string.checking_updates_toast, Toast.LENGTH_SHORT).show();
+ checkNewVersionNow();
return true;
};
+ private void checkNewVersionNow() {
+ // Search for updates immediately when update checks are enabled.
+ // Reset the expire time. This is necessary to check for an update immediately.
+ defaultPreferences.edit()
+ .putLong(getString(R.string.update_expiry_key), 0).apply();
+ startNewVersionCheckService();
+ }
+
@Override
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
addPreferencesFromResource(R.xml.update_settings);
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9ab2d2643..2ad07b4c5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -549,6 +549,7 @@
recovering
Queue
Action denied by the system
+ Checking for updates…
Download failed