mirror of https://github.com/M66B/NetGuard.git
Added option to filter user/system applications
This commit is contained in:
parent
b33de15840
commit
4aebe4b50c
|
@ -351,11 +351,16 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
"whitelist_other".equals(name) ||
|
||||
"screen_other".equals(name) ||
|
||||
"whitelist_roaming".equals(name) ||
|
||||
"manage_system".equals(name) ||
|
||||
"show_user".equals(name) ||
|
||||
"show_system".equals(name) ||
|
||||
"imported".equals(name))
|
||||
updateApplicationList(null);
|
||||
|
||||
else if ("dark_theme".equals(name))
|
||||
else if ("manage_system".equals(name)) {
|
||||
invalidateOptionsMenu();
|
||||
updateApplicationList(null);
|
||||
|
||||
} else if ("dark_theme".equals(name))
|
||||
recreate();
|
||||
}
|
||||
|
||||
|
@ -475,10 +480,32 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if (prefs.getBoolean("manage_system", false)) {
|
||||
menu.findItem(R.id.menu_app_user).setChecked(prefs.getBoolean("show_user", true));
|
||||
menu.findItem(R.id.menu_app_system).setChecked(prefs.getBoolean("show_system", true));
|
||||
} else
|
||||
menu.removeItem(R.id.menu_filter);
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle item selection
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_app_user:
|
||||
item.setChecked(!item.isChecked());
|
||||
prefs.edit().putBoolean("show_user", item.isChecked()).apply();
|
||||
return true;
|
||||
|
||||
case R.id.menu_app_system:
|
||||
item.setChecked(!item.isChecked());
|
||||
prefs.edit().putBoolean("show_system", item.isChecked()).apply();
|
||||
return true;
|
||||
|
||||
case R.id.menu_settings:
|
||||
startActivity(new Intent(this, ActivitySettings.class));
|
||||
return true;
|
||||
|
|
|
@ -320,7 +320,10 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
|||
pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, "-"));
|
||||
SinkholeService.reload(null, "setting changed", this);
|
||||
|
||||
} else if ("unmetered_2g".equals(name) ||
|
||||
} else if ("use_metered".equals(name))
|
||||
SinkholeService.reload(null, "setting changed", this);
|
||||
|
||||
else if ("unmetered_2g".equals(name) ||
|
||||
"unmetered_3g".equals(name) ||
|
||||
"unmetered_4g".equals(name)) {
|
||||
if (prefs.getBoolean(name, false)) {
|
||||
|
@ -340,11 +343,19 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
|||
} else
|
||||
SinkholeService.reload("other", "setting changed", this);
|
||||
|
||||
} else if ("use_metered".equals(name) ||
|
||||
"manage_system".equals(name))
|
||||
} else if ("manage_system".equals(name)) {
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
if (prefs.getBoolean(name, false)) {
|
||||
editor.putBoolean("show_user", true);
|
||||
editor.putBoolean("show_system", true);
|
||||
} else {
|
||||
editor.putBoolean("show_user", true);
|
||||
editor.putBoolean("show_system", false);
|
||||
}
|
||||
editor.apply();
|
||||
SinkholeService.reload(null, "setting changed", this);
|
||||
|
||||
else if ("dark_theme".equals(name))
|
||||
} else if ("dark_theme".equals(name))
|
||||
recreate();
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,8 @@ public class Rule implements Comparable<Rule> {
|
|||
boolean default_screen_other = prefs.getBoolean("screen_other", true);
|
||||
boolean default_roaming = prefs.getBoolean("whitelist_roaming", true);
|
||||
boolean manage_system = prefs.getBoolean("manage_system", false);
|
||||
boolean show_user = prefs.getBoolean("show_user", true);
|
||||
boolean show_system = prefs.getBoolean("show_system", true);
|
||||
|
||||
// Get predefined rules
|
||||
Map<String, Boolean> pre_blocked = new HashMap<>();
|
||||
|
@ -144,7 +146,7 @@ public class Rule implements Comparable<Rule> {
|
|||
List<Rule> listRules = new ArrayList<>();
|
||||
for (PackageInfo info : context.getPackageManager().getInstalledPackages(0)) {
|
||||
boolean system = ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
|
||||
if (!system || manage_system || all) {
|
||||
if (all || (system ? manage_system && show_system : show_user)) {
|
||||
Rule rule = new Rule(info, context);
|
||||
|
||||
rule.system = system;
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 111 B |
Binary file not shown.
After Width: | Height: | Size: 90 B |
Binary file not shown.
After Width: | Height: | Size: 103 B |
Binary file not shown.
After Width: | Height: | Size: 107 B |
Binary file not shown.
After Width: | Height: | Size: 106 B |
|
@ -7,6 +7,22 @@
|
|||
android:title="@string/menu_search"
|
||||
netguard:actionViewClass="android.support.v7.widget.SearchView"
|
||||
netguard:showAsAction="always|collapseActionView" />
|
||||
<item
|
||||
android:id="@+id/menu_filter"
|
||||
android:icon="@drawable/ic_filter_list_white_24dp"
|
||||
android:title="@string/menu_filter"
|
||||
netguard:showAsAction="always|collapseActionView">
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/menu_app_user"
|
||||
android:checkable="true"
|
||||
android:title="@string/menu_app_user" />
|
||||
<item
|
||||
android:id="@+id/menu_app_system"
|
||||
android:checkable="true"
|
||||
android:title="@string/menu_app_system" />
|
||||
</menu>
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/menu_settings"
|
||||
android:title="@string/menu_settings" />
|
||||
|
|
|
@ -10,6 +10,9 @@ These issues are caused by bugs in Android, or in the software provided by the m
|
|||
\n\nBy using NetGuard, you agree to the <a href="http://www.gnu.org/licenses/gpl.txt">GNU General Public License version 3</a></string>
|
||||
|
||||
<string name="menu_search">Search for application</string>
|
||||
<string name="menu_filter">Filter applications</string>
|
||||
<string name="menu_app_user">Show user applications</string>
|
||||
<string name="menu_app_system">Show system applications</string>
|
||||
<string name="menu_settings">Settings</string>
|
||||
<string name="menu_invite">Invite</string>
|
||||
<string name="menu_support">Support</string>
|
||||
|
|
Loading…
Reference in New Issue