Added setting to disable new app installed notification

Fixes #402
This commit is contained in:
M66B 2016-04-08 08:12:46 +02:00
parent 48640fa6a2
commit e1b1963f86
5 changed files with 22 additions and 2 deletions

View File

@ -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);

View File

@ -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))

View File

@ -59,6 +59,7 @@ however it is impossible to guarantee NetGuard will work correctly on every devi
<string name="setting_options">Options</string>
<string name="setting_theme">Theme: %1$s</string>
<string name="setting_dark">Use dark theme</string>
<string name="setting_install">Notify on new install</string>
<string name="setting_auto">Auto enable after %1$s minutes</string>
<string name="setting_delay">Delay screen off %1$s minutes</string>
<string name="setting_update">Check for updates</string>
@ -108,6 +109,7 @@ however it is impossible to guarantee NetGuard will work correctly on every devi
<string name="setting_technical_networks">Networks</string>
<string name="setting_technical_subscription">Subscriptions</string>
<string name="summary_install">Show status bar notification to directly configure newly installed applications (pro feature)</string>
<string name="summary_auto">After disabling using the widget, automatically enable NetGuard again after the selected number of minutes (enter zero to disable this option)</string>
<string name="summary_delay">After turning the screen off, keep screen on rules active for the selected number of minutes (enter zero to disable this option)</string>
<string name="summary_update">Check for new releases on GitHub twice daily</string>

View File

@ -37,6 +37,11 @@
android:defaultValue="false"
android:key="dark_theme"
android:title="@string/setting_dark" />
<CheckBoxPreference
android:defaultValue="true"
android:key="install"
android:summary="@string/summary_install"
android:title="@string/setting_install" />
<EditTextPreference
android:defaultValue="0"
android:inputType="number"

View File

@ -37,6 +37,11 @@
android:defaultValue="false"
android:key="dark_theme"
android:title="@string/setting_dark" />
<eu.faircode.netguard.SwitchPreference
android:defaultValue="true"
android:key="install"
android:summary="@string/summary_install"
android:title="@string/setting_install" />
<EditTextPreference
android:defaultValue="0"
android:inputType="number"