mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-12 12:03:17 +02:00
Added options to always download headers and EML files
This commit is contained in:
@@ -3055,6 +3055,7 @@ class Core {
|
||||
List<EntityRule> rules, State state, SyncStats stats) throws MessagingException, IOException {
|
||||
DB db = DB.getInstance(context);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean download_headers = prefs.getBoolean("download_headers", false);
|
||||
boolean notify_known = prefs.getBoolean("notify_known", false);
|
||||
boolean perform_expunge = prefs.getBoolean("perform_expunge", true);
|
||||
boolean pro = ActivityBilling.isPro(context);
|
||||
@@ -3207,6 +3208,8 @@ class Core {
|
||||
message.list_post = helper.getListPost();
|
||||
message.unsubscribe = helper.getListUnsubscribe();
|
||||
message.autocrypt = helper.getAutocrypt();
|
||||
if (download_headers)
|
||||
message.headers = helper.getHeaders();
|
||||
message.subject = helper.getSubject();
|
||||
message.size = parts.getBodySize();
|
||||
message.total = helper.getSize();
|
||||
@@ -3706,6 +3709,7 @@ class Core {
|
||||
long maxSize = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE);
|
||||
if (maxSize == 0)
|
||||
maxSize = Long.MAX_VALUE;
|
||||
boolean download_eml = prefs.getBoolean("download_eml", false);
|
||||
|
||||
List<EntityAttachment> attachments = db.attachment().getAttachments(message.id);
|
||||
|
||||
@@ -3786,6 +3790,16 @@ class Core {
|
||||
}
|
||||
}
|
||||
|
||||
if (download_eml &&
|
||||
(state.getNetworkState().isUnmetered() || (message.total != null && message.total < maxSize))) {
|
||||
File file = message.getRawFile(context);
|
||||
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||
imessage.writeTo(os);
|
||||
}
|
||||
|
||||
db.message().setMessageRaw(message.id, true);
|
||||
}
|
||||
|
||||
return fetch;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
||||
private Spinner spDownload;
|
||||
private SwitchCompat swRoaming;
|
||||
private SwitchCompat swRlah;
|
||||
private SwitchCompat swDownloadHeaders;
|
||||
private SwitchCompat swDownloadEml;
|
||||
private SwitchCompat swValidated;
|
||||
private EditText etTimeout;
|
||||
private SwitchCompat swPreferIp4;
|
||||
@@ -75,6 +77,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
||||
|
||||
private final static String[] RESET_OPTIONS = new String[]{
|
||||
"metered", "download", "roaming", "rlah",
|
||||
"download_headers", "download_eml",
|
||||
"require_validated", "timeout", "prefer_ip4", "standalone_vpn", "tcp_keep_alive", "ssl_harden"
|
||||
};
|
||||
|
||||
@@ -92,6 +95,8 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
||||
spDownload = view.findViewById(R.id.spDownload);
|
||||
swRoaming = view.findViewById(R.id.swRoaming);
|
||||
swRlah = view.findViewById(R.id.swRlah);
|
||||
swDownloadHeaders = view.findViewById(R.id.swDownloadHeaders);
|
||||
swDownloadEml = view.findViewById(R.id.swDownloadEml);
|
||||
swValidated = view.findViewById(R.id.swValidated);
|
||||
etTimeout = view.findViewById(R.id.etTimeout);
|
||||
swPreferIp4 = view.findViewById(R.id.swPreferIp4);
|
||||
@@ -148,6 +153,20 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
||||
}
|
||||
});
|
||||
|
||||
swDownloadHeaders.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("download_headers", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swDownloadEml.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("download_eml", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
grpValidated.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.M ? View.GONE : View.VISIBLE);
|
||||
swValidated.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
@@ -313,6 +332,9 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
||||
swRoaming.setChecked(prefs.getBoolean("roaming", true));
|
||||
swRlah.setChecked(prefs.getBoolean("rlah", true));
|
||||
|
||||
swDownloadHeaders.setChecked(prefs.getBoolean("download_headers", false));
|
||||
swDownloadEml.setChecked(prefs.getBoolean("download_eml", false));
|
||||
|
||||
swValidated.setChecked(prefs.getBoolean("require_validated", false));
|
||||
|
||||
int timeout = prefs.getInt("timeout", 0);
|
||||
|
||||
Reference in New Issue
Block a user