mirror of https://github.com/M66B/NetGuard.git
Added options to reset rules
This commit is contained in:
parent
993f51b985
commit
410ff7a42e
|
@ -3,6 +3,7 @@ package eu.faircode.netguard;
|
|||
import android.app.AlertDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -217,6 +218,32 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
BlackHoleService.reload("other", this);
|
||||
return true;
|
||||
|
||||
case R.id.menu_reset_wifi:
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(R.string.msg_sure)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
reset("wifi");
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
return true;
|
||||
|
||||
case R.id.menu_reset_other:
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(R.string.msg_sure)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
reset("other");
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
return true;
|
||||
|
||||
case R.id.menu_vpn_settings:
|
||||
// Open VPN settings
|
||||
Intent vpn = new Intent("android.net.vpn.SETTINGS");
|
||||
|
@ -252,6 +279,16 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
}
|
||||
}
|
||||
|
||||
private void reset(String name) {
|
||||
SharedPreferences other = getSharedPreferences(name, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor edit = other.edit();
|
||||
for (String key : other.getAll().keySet())
|
||||
edit.remove(key);
|
||||
edit.apply();
|
||||
fillApplicationList();
|
||||
BlackHoleService.reload(name, ActivityMain.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_VPN) {
|
||||
|
|
|
@ -15,6 +15,12 @@
|
|||
android:id="@+id/menu_whitelist_other"
|
||||
android:checkable="true"
|
||||
android:title="@string/menu_whitelist_other" />
|
||||
<item
|
||||
android:id="@+id/menu_reset_wifi"
|
||||
android:title="@string/menu_reset_wifi" />
|
||||
<item
|
||||
android:id="@+id/menu_reset_other"
|
||||
android:title="@string/menu_reset_other" />
|
||||
<item
|
||||
android:id="@+id/menu_vpn_settings"
|
||||
android:title="@string/menu_vpn_settings" />
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
<resources>
|
||||
<string name="app_name">NetGuard</string>
|
||||
<string name="app_copyright">Copyright \u00A9 2015 by M. Bokhorst (M66B)</string>
|
||||
|
||||
<string name="menu_search">Search applications</string>
|
||||
<string name="menu_whitelist_wifi">Default block Wi-Fi</string>
|
||||
<string name="menu_whitelist_other">Default block other</string>
|
||||
<string name="menu_whitelist_other">Default block mobile</string>
|
||||
<string name="menu_reset_wifi">Reset Wi-Fi rules</string>
|
||||
<string name="menu_reset_other">Reset mobile rules</string>
|
||||
<string name="menu_vpn_settings">Android VPN settings</string>
|
||||
<string name="menu_support">Support</string>
|
||||
<string name="menu_about">About</string>
|
||||
|
||||
<string name="msg_sure">Are you sure?</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue