mirror of https://github.com/M66B/NetGuard.git
Added settings to disable access notifications per application
Fixes #268
This commit is contained in:
parent
b77efa6291
commit
477c3a604a
|
@ -649,6 +649,8 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
|||
return intent;
|
||||
}
|
||||
|
||||
// TODO translate uid to package name for notify.<uid> setting
|
||||
|
||||
private void handleExport(final Intent data) {
|
||||
new AsyncTask<Object, Object, Throwable>() {
|
||||
@Override
|
||||
|
|
|
@ -22,9 +22,7 @@ package eu.faircode.netguard;
|
|||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
|
@ -122,6 +120,7 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
|
||||
public ListView lvAccess;
|
||||
public TextView tvNolog;
|
||||
public CheckBox cbNotify;
|
||||
public ImageButton btnClearAccess;
|
||||
public TextView tvStatistics;
|
||||
|
||||
|
@ -165,6 +164,7 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
|
||||
lvAccess = (ListView) itemView.findViewById(R.id.lvAccess);
|
||||
tvNolog = (TextView) itemView.findViewById(R.id.tvNolog);
|
||||
cbNotify = (CheckBox) itemView.findViewById(R.id.cbNotify);
|
||||
btnClearAccess = (ImageButton) itemView.findViewById(R.id.btnClearAccess);
|
||||
tvStatistics = (TextView) itemView.findViewById(R.id.tvStatistics);
|
||||
|
||||
|
@ -562,7 +562,7 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
holder.lvAccess.setOnItemClickListener(null);
|
||||
}
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean log_app = prefs.getBoolean("log_app", false);
|
||||
holder.tvNolog.setVisibility(log_app ? View.GONE : View.VISIBLE);
|
||||
holder.tvNolog.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -572,6 +572,17 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
}
|
||||
});
|
||||
|
||||
boolean notify = prefs.getBoolean("notify_access", false);
|
||||
final String key = "notify." + rule.info.applicationInfo.uid;
|
||||
holder.cbNotify.setEnabled(notify);
|
||||
holder.cbNotify.setChecked(prefs.getBoolean(key, true));
|
||||
holder.cbNotify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
|
||||
prefs.edit().putBoolean(key, isChecked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
holder.btnClearAccess.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
|
|
@ -691,9 +691,9 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
|||
}
|
||||
|
||||
if (dh.updateAccess(packet, dname, -1))
|
||||
if (notify && (system || !Util.isSystem(packet.uid, SinkholeService.this)))
|
||||
if (notify && prefs.getBoolean("notify." + packet.uid, true) &&
|
||||
(system || !Util.isSystem(packet.uid, SinkholeService.this)))
|
||||
showAccessNotification(packet.uid);
|
||||
|
||||
}
|
||||
|
||||
if (packet.uid < 0 && packet.dport != 53)
|
||||
|
|
|
@ -315,7 +315,16 @@
|
|||
android:layout_marginTop="4dp"
|
||||
android:text="@string/title_no_log"
|
||||
android:textAppearance="@style/TextSmall"
|
||||
android:textStyle="bold" />
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbNotify"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="@string/title_notify"
|
||||
android:textAppearance="@style/TextSmall" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -135,6 +135,7 @@ Since NetGuard has no internet permission, you know your internet traffic is not
|
|||
<string name="title_allow">Allow</string>
|
||||
<string name="title_block">Block</string>
|
||||
<string name="title_root">root</string>
|
||||
<string name="title_notify">Notify internet access attempts</string>
|
||||
|
||||
<string name="title_log_whois">Whois %1$s</string>
|
||||
<string name="title_log_port">Port %1$d</string>
|
||||
|
|
Loading…
Reference in New Issue