Added setting to disable downloading while roaming

pull/155/head
M66B 6 years ago
parent a095d645fb
commit bc9259d042

@ -71,6 +71,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private TextView tvConnectionRoaming;
private SwitchCompat swMetered;
private Spinner spDownload;
private SwitchCompat swRoaming;
private Spinner spStartup;
private SwitchCompat swDate;
@ -126,7 +127,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private final static String[] ADVANCED_OPTIONS = new String[]{
"enabled", "schedule_start", "schedule_end",
"metered", "download",
"metered", "download", "roaming",
"startup", "date", "threading", "avatars", "identicons", "name_email", "subject_italic", "flags", "preview",
"addresses", "monospaced", "autohtml", "autoimages", "actionbar",
"pull", "swipenav", "autoexpand", "autoclose", "autonext", "collapse", "autoread", "automove",
@ -155,6 +156,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
tvConnectionRoaming = view.findViewById(R.id.tvConnectionRoaming);
swMetered = view.findViewById(R.id.swMetered);
spDownload = view.findViewById(R.id.spDownload);
swRoaming = view.findViewById(R.id.swRoaming);
spStartup = view.findViewById(R.id.spStartup);
swDate = view.findViewById(R.id.swDate);
@ -281,6 +283,14 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
}
});
swRoaming.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("roaming", checked).apply();
ServiceSynchronize.reload(getContext(), "roaming=" + checked);
}
});
spStartup.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
@ -652,6 +662,8 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
break;
}
swRoaming.setChecked(prefs.getBoolean("roaming", true));
boolean compact = prefs.getBoolean("compact", false);
String startup = prefs.getString("startup", "unified");

@ -808,6 +808,7 @@ public class Helper {
static NetworkState getNetworkState(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean metered = prefs.getBoolean("metered", true);
boolean roaming = prefs.getBoolean("roaming", true);
NetworkState state = new NetworkState();
Boolean isMetered = isMetered(context);
@ -815,7 +816,7 @@ public class Helper {
state.unmetered = (isMetered != null && !isMetered);
state.suitable = (isMetered != null && (metered || !isMetered));
if (state.connected) {
if (state.connected && !roaming) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
NetworkInfo ani = cm.getActiveNetworkInfo();

@ -225,19 +225,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDownload" />
<TextView
android:id="@+id/tvRoamingHint"
android:layout_width="0dp"
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swRoaming"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="60dp"
android:text="@string/title_advanced_roaming_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_roaming"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spDownload" />
app:layout_constraintTop_toBottomOf="@id/spDownload"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvSectionDisplay"
@ -248,7 +246,7 @@
android:text="@string/title_advanced_section_display"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRoamingHint" />
app:layout_constraintTop_toBottomOf="@id/swRoaming" />
<View
android:id="@+id/vSeparatorDisplay"

@ -161,6 +161,7 @@
<string name="title_advanced_metered">Use metered connections</string>
<string name="title_advanced_download">Automatically download messages and attachments on a metered connection up to</string>
<string name="title_advanced_roaming">Download messages and attachments while roaming</string>
<string name="title_advanced_browse">Browse messages on the server</string>
<string name="title_advanced_startup">Show on start screen</string>
@ -206,7 +207,6 @@
<string name="title_advanced_enabled_hint">Globally disable or enable receiving and sending of messages</string>
<string name="title_advanced_metered_hint">Metered connections are generally mobile connections or paid Wi-Fi hotspots</string>
<string name="title_advanced_metered_warning">Disabling this option will disable receiving and sending messages on mobile internet connections</string>
<string name="title_advanced_roaming_hint">Message texts and attachments will never be downloaded when roaming</string>
<string name="title_advanced_browse_hint">Fetch more messages when scrolling down</string>
<string name="title_advanced_threading_hint">Group messages related to each other</string>
<string name="title_advanced_name_email_hint">When disabled only names will be shown when available</string>

Loading…
Cancel
Save