Added option to limit unmetered data usage

This commit is contained in:
M66B
2023-12-13 13:32:02 +01:00
parent e90e84b562
commit e4831098cc
5 changed files with 46 additions and 12 deletions

View File

@@ -81,6 +81,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
private ImageButton ibHelp;
private SwitchCompat swMetered;
private Spinner spDownload;
private SwitchCompat swDownloadLimited;
private SwitchCompat swRoaming;
private SwitchCompat swRlah;
private SwitchCompat swDownloadHeaders;
@@ -118,7 +119,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
private Group grpValidated;
private final static String[] RESET_OPTIONS = new String[]{
"metered", "download", "roaming", "rlah",
"metered", "download", "download_limited", "roaming", "rlah",
"download_headers", "download_eml", "download_plain",
"require_validated", "require_validated_captive", "vpn_only",
"timeout", "prefer_ip4", "bind_socket", "standalone_vpn", "tcp_keep_alive",
@@ -139,6 +140,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
ibHelp = view.findViewById(R.id.ibHelp);
swMetered = view.findViewById(R.id.swMetered);
spDownload = view.findViewById(R.id.spDownload);
swDownloadLimited = view.findViewById(R.id.swDownloadLimited);
swRoaming = view.findViewById(R.id.swRoaming);
swRlah = view.findViewById(R.id.swRlah);
swDownloadHeaders = view.findViewById(R.id.swDownloadHeaders);
@@ -211,6 +213,13 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
}
});
swDownloadLimited.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("download_limited", checked).apply();
}
});
swRoaming.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -655,6 +664,8 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
break;
}
swDownloadLimited.setChecked(prefs.getBoolean("download_limited", false));
swRoaming.setChecked(prefs.getBoolean("roaming", true));
swRlah.setChecked(prefs.getBoolean("rlah", true));