From e1b1963f86719f336c613e167de430f63d3d6c90 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 8 Apr 2016 08:12:46 +0200 Subject: [PATCH] Added setting to disable new app installed notification Fixes #402 --- .../main/java/eu/faircode/netguard/ActivitySettings.java | 7 +++++++ app/src/main/java/eu/faircode/netguard/Receiver.java | 5 +++-- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml-v14/preferences.xml | 5 +++++ app/src/main/res/xml-v21/preferences.xml | 5 +++++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java index 461a0f64..7eb208e6 100644 --- a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java +++ b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java @@ -463,6 +463,13 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere startActivity(new Intent(this, ActivityPro.class)); return; } + } else if ("install".equals(name)) { + if (prefs.getBoolean(name, false) && !IAB.isPurchased(ActivityPro.SKU_NOTIFY, this)) { + prefs.edit().putBoolean(name, false).apply(); + ((TwoStatePreference) getPreferenceScreen().findPreference(name)).setChecked(false); + startActivity(new Intent(this, ActivityPro.class)); + return; + } } Object value = prefs.getAll().get(name); diff --git a/app/src/main/java/eu/faircode/netguard/Receiver.java b/app/src/main/java/eu/faircode/netguard/Receiver.java index 5ddb9757..fa9c27a9 100644 --- a/app/src/main/java/eu/faircode/netguard/Receiver.java +++ b/app/src/main/java/eu/faircode/netguard/Receiver.java @@ -44,11 +44,13 @@ public class Receiver extends BroadcastReceiver { Log.i(TAG, "Received " + intent); Util.logExtras(intent); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { // Application added if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { // Show notification - if (IAB.isPurchased(ActivityPro.SKU_NOTIFY, context)) { + if (IAB.isPurchased(ActivityPro.SKU_NOTIFY, context) && prefs.getBoolean("install", true)) { int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); notifyNewApplication(uid, context); } @@ -82,7 +84,6 @@ public class Receiver extends BroadcastReceiver { upgrade(true, context); // Start service - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); try { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false) || prefs.getBoolean("show_stats", false)) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4cc939a8..ce260f07 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -59,6 +59,7 @@ however it is impossible to guarantee NetGuard will work correctly on every devi Options Theme: %1$s Use dark theme + Notify on new install Auto enable after %1$s minutes Delay screen off %1$s minutes Check for updates @@ -108,6 +109,7 @@ however it is impossible to guarantee NetGuard will work correctly on every devi Networks Subscriptions + Show status bar notification to directly configure newly installed applications (pro feature) 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 diff --git a/app/src/main/res/xml-v14/preferences.xml b/app/src/main/res/xml-v14/preferences.xml index 8b41728d..335f51ef 100644 --- a/app/src/main/res/xml-v14/preferences.xml +++ b/app/src/main/res/xml-v14/preferences.xml @@ -37,6 +37,11 @@ android:defaultValue="false" android:key="dark_theme" android:title="@string/setting_dark" /> + +