mirror of
https://github.com/M66B/NetGuard.git
synced 2025-01-03 13:54:09 +00:00
Remove data usage (Android N)
This commit is contained in:
parent
7318c58f2f
commit
3f63c01953
4 changed files with 22 additions and 7 deletions
|
@ -843,14 +843,20 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
menu.findItem(R.id.menu_app_nointernet).setChecked(prefs.getBoolean("show_nointernet", true));
|
||||
menu.findItem(R.id.menu_app_disabled).setChecked(prefs.getBoolean("show_disabled", true));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
Menu submenu = menu.findItem(R.id.menu_sort).getSubMenu();
|
||||
submenu.removeItem(R.id.menu_sort_data);
|
||||
}
|
||||
|
||||
String sort = prefs.getString("sort", "name");
|
||||
if ("data".equals(sort))
|
||||
if ("data".equals(sort) && Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
|
||||
menu.findItem(R.id.menu_sort_data).setChecked(true);
|
||||
else if ("uid".equals(sort))
|
||||
menu.findItem(R.id.menu_sort_uid).setChecked(true);
|
||||
else
|
||||
menu.findItem(R.id.menu_sort_name).setChecked(true);
|
||||
|
||||
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
|
|
@ -401,6 +401,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
holder.tvDisabled.setVisibility(rule.enabled ? View.GONE : View.VISIBLE);
|
||||
|
||||
// Show traffic statistics
|
||||
holder.tvStatistics.setVisibility(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? View.GONE : View.VISIBLE);
|
||||
holder.tvStatistics.setText(context.getString(R.string.msg_mbday, rule.upspeed, rule.downspeed));
|
||||
|
||||
// Apply
|
||||
|
|
|
@ -239,8 +239,11 @@ public class Receiver extends BroadcastReceiver {
|
|||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
|
||||
editor.putBoolean("filter", true); // Mandatory
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
editor.remove("show_top");
|
||||
if ("data".equals(prefs.getString("sort", "name")))
|
||||
editor.remove("sort");
|
||||
}
|
||||
|
||||
if (Util.isPlayStoreInstall(context)) {
|
||||
editor.remove("update_check");
|
||||
|
|
|
@ -353,11 +353,16 @@ public class Rule {
|
|||
}
|
||||
rule.related = listPkg.toArray(new String[0]);
|
||||
|
||||
long up = TrafficStats.getUidTxBytes(rule.info.applicationInfo.uid);
|
||||
long down = TrafficStats.getUidRxBytes(rule.info.applicationInfo.uid);
|
||||
rule.totalbytes = up + down;
|
||||
rule.upspeed = (float) up * 24 * 3600 * 1000 / 1024f / 1024f / now;
|
||||
rule.downspeed = (float) down * 24 * 3600 * 1000 / 1024f / 1024f / now;
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||
long up = TrafficStats.getUidTxBytes(rule.info.applicationInfo.uid);
|
||||
long down = TrafficStats.getUidRxBytes(rule.info.applicationInfo.uid);
|
||||
rule.totalbytes = up + down;
|
||||
rule.upspeed = (float) up * 24 * 3600 * 1000 / 1024f / 1024f / now;
|
||||
rule.downspeed = (float) down * 24 * 3600 * 1000 / 1024f / 1024f / now;
|
||||
} else {
|
||||
rule.upspeed = 0;
|
||||
rule.downspeed = 0;
|
||||
}
|
||||
|
||||
rule.updateChanged(default_wifi, default_other, default_roaming);
|
||||
|
||||
|
|
Loading…
Reference in a new issue