mirror of https://github.com/M66B/FairEmail.git
Added options to always download headers and EML files
This commit is contained in:
parent
4008dde31c
commit
9147dae4d2
|
@ -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);
|
||||
|
|
|
@ -161,7 +161,53 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvRlahHint" />
|
||||
app:layout_constraintTop_toBottomOf="@id/swRlah" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swDownloadHeaders"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_download_headers"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvAdvanced"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvDownloadHeadersHint"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="48dp"
|
||||
android:text="@string/title_advanced_usage_hint"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swDownloadHeaders" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swDownloadEml"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_download_eml"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDownloadHeadersHint"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvDownloadEmlHint"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="48dp"
|
||||
android:text="@string/title_advanced_usage_hint"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swDownloadEml" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swValidated"
|
||||
|
@ -171,7 +217,7 @@
|
|||
android:text="@string/title_advanced_validated"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvAdvanced"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDownloadEmlHint"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
|
|
|
@ -349,6 +349,8 @@
|
|||
<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_rlah">Roam like at home</string>
|
||||
<string name="title_advanced_download_headers">Download all message headers</string>
|
||||
<string name="title_advanced_download_eml">Download raw message files</string>
|
||||
<string name="title_advanced_validated">Require a validated (checked) connection</string>
|
||||
<string name="title_advanced_timeout">Connection timeout (seconds)</string>
|
||||
<string name="title_advanced_prefer_ip4">Prefer IPv4 over IPv6</string>
|
||||
|
@ -595,6 +597,7 @@
|
|||
<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_rlah_hint">Assuming no roaming within the EU</string>
|
||||
<string name="title_advanced_usage_hint">This will increase battery, data and storage space usage</string>
|
||||
<string name="title_advanced_tcp_keep_alive_hint">Enabling this can cause connection problems on some devices</string>
|
||||
<string name="title_advanced_validate_hint">This can result in not synchronizing messages, for example when using a VPN, but also in other situations</string>
|
||||
<string name="title_advanced_timeout_hint">The read/write timeout will be set to the double of the connection timeout. Higher values will result in more battery use.</string>
|
||||
|
|
Loading…
Reference in New Issue