From cf63219eafdc15feac56a68f1e6ae9ced04a63a1 Mon Sep 17 00:00:00 2001 From: Jonny Reading Date: Thu, 12 Sep 2024 18:58:19 +0100 Subject: [PATCH] skip automatic update check notification for beta releases --- .../java/eu/faircode/netguard/ActivitySettings.java | 4 +++- .../java/eu/faircode/netguard/ReceiverAutostart.java | 1 + .../java/eu/faircode/netguard/ServiceSinkhole.java | 11 ++++++++--- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml-v14/preferences.xml | 6 ++++++ app/src/main/res/xml-v21/preferences.xml | 6 ++++++ 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java index 55b5dcee..f8d41df5 100644 --- a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java +++ b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java @@ -319,8 +319,10 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere pref_rcode.setTitle(getString(R.string.setting_rcode, prefs.getString("rcode", "3"))); - if (Util.isPlayStoreInstall(this) || !Util.hasValidFingerprint(this)) + if (Util.isPlayStoreInstall(this) || !Util.hasValidFingerprint(this)) { cat_options.removePreference(screen.findPreference("update_check")); + cat_options.removePreference(screen.findPreference("beta_release")); + } if (Util.isPlayStoreInstall(this)) { Log.i(TAG, "Play store install"); diff --git a/app/src/main/java/eu/faircode/netguard/ReceiverAutostart.java b/app/src/main/java/eu/faircode/netguard/ReceiverAutostart.java index 3831a4ef..91e10b2e 100644 --- a/app/src/main/java/eu/faircode/netguard/ReceiverAutostart.java +++ b/app/src/main/java/eu/faircode/netguard/ReceiverAutostart.java @@ -118,6 +118,7 @@ public class ReceiverAutostart extends BroadcastReceiver { if (Util.isPlayStoreInstall(context)) { editor.remove("update_check"); + editor.remove("beta_release"); editor.remove("use_hosts"); editor.remove("hosts_url"); } diff --git a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java index c37db24e..8ae5c69a 100644 --- a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java +++ b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java @@ -671,7 +671,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS if (!Util.isPlayStoreInstall(ServiceSinkhole.this) && Util.hasValidFingerprint(ServiceSinkhole.this) && prefs.getBoolean("update_check", true)) - checkUpdate(); + checkUpdate(prefs.getBoolean("beta_release", false)); } private void watchdog(Intent intent) { @@ -684,7 +684,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS } } - private void checkUpdate() { + private void checkUpdate(boolean notifyForBetaReleases) { StringBuilder json = new StringBuilder(); HttpsURLConnection urlConnection = null; try { @@ -705,7 +705,12 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS try { JSONObject jroot = new JSONObject(json.toString()); - if (jroot.has("tag_name") && jroot.has("html_url") && jroot.has("assets")) { + if (jroot.has("tag_name") && jroot.has("html_url") && jroot.has("assets") && jroot.has("name")) { + String releaseName = jroot.getString("name"); + if (!notifyForBetaReleases && releaseName.contains("beta")) { + Log.i(TAG, "Skipping beta release '" + releaseName + "' due to update preferences"); + return; + } String url = jroot.getString("html_url"); JSONArray jassets = jroot.getJSONArray("assets"); if (jassets.length() > 0) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7ce7c003..269d0e05 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -84,6 +84,7 @@ Auto enable after %1$s minutes Delay screen off %1$s minutes Check for updates + Beta releases Network options Subnet routing @@ -155,6 +156,7 @@ After disabling using the widget, automatically enable NetGuard again after the selected number of minutes (enter zero to disable this option) After turning the screen off, keep screen on rules active for the selected number of minutes (enter zero to disable this option) Check for new releases on GitHub twice daily + Notify for beta releases Depending on the Android version, tethering may work or may not work. Tethered traffic cannot be filtered. Enable subnet routing; might enable Wi-Fi calling, but might also trigger bugs in Android and increase battery usage diff --git a/app/src/main/res/xml-v14/preferences.xml b/app/src/main/res/xml-v14/preferences.xml index 7278b291..dafd366d 100644 --- a/app/src/main/res/xml-v14/preferences.xml +++ b/app/src/main/res/xml-v14/preferences.xml @@ -70,6 +70,12 @@ android:key="update_check" android:summary="@string/summary_update" android:title="@string/setting_update" /> + diff --git a/app/src/main/res/xml-v21/preferences.xml b/app/src/main/res/xml-v21/preferences.xml index 59fdcb59..8ceb2f8c 100644 --- a/app/src/main/res/xml-v21/preferences.xml +++ b/app/src/main/res/xml-v21/preferences.xml @@ -70,6 +70,12 @@ android:key="update_check" android:summary="@string/summary_update" android:title="@string/setting_update" /> +