Added overriding/setting max message size

pull/183/head
M66B 5 years ago
parent f0c07f4213
commit 290af27780

@ -113,6 +113,7 @@ public class FragmentIdentity extends FragmentBase {
private EditText etCc;
private EditText etBcc;
private CheckBox cbUnicode;
private EditText etMaxSize;
private Button btnSave;
private ContentLoadingProgressBar pbSave;
@ -205,6 +206,7 @@ public class FragmentIdentity extends FragmentBase {
etCc = view.findViewById(R.id.etCc);
etBcc = view.findViewById(R.id.etBcc);
cbUnicode = view.findViewById(R.id.cbUnicode);
etMaxSize = view.findViewById(R.id.etMaxSize);
btnSave = view.findViewById(R.id.btnSave);
pbSave = view.findViewById(R.id.pbSave);
@ -586,6 +588,7 @@ public class FragmentIdentity extends FragmentBase {
args.putString("cc", etCc.getText().toString().trim());
args.putString("bcc", etBcc.getText().toString().trim());
args.putBoolean("unicode", cbUnicode.isChecked());
args.putString("max_size", etMaxSize.getText().toString());
args.putLong("account", account == null ? -1 : account.id);
args.putString("host", etHost.getText().toString().trim());
args.putBoolean("starttls", rgEncryption.getCheckedRadioButtonId() == R.id.radio_starttls);
@ -662,6 +665,7 @@ public class FragmentIdentity extends FragmentBase {
String cc = args.getString("cc");
String bcc = args.getString("bcc");
boolean unicode = args.getBoolean("unicode");
String max_size = args.getString("max_size");
boolean should = args.getBoolean("should");
@ -738,6 +742,8 @@ public class FragmentIdentity extends FragmentBase {
if (TextUtils.isEmpty(signature))
signature = null;
Long user_max_size = (TextUtils.isEmpty(max_size) ? null : Integer.parseInt(max_size) * 1000 * 1000L);
DB db = DB.getInstance(context);
EntityIdentity identity = db.identity().getIdentity(id);
@ -799,6 +805,8 @@ public class FragmentIdentity extends FragmentBase {
return true;
if (!Objects.equals(identity.unicode, unicode))
return true;
if (user_max_size != null && !Objects.equals(identity.max_size, user_max_size))
return true;
return false;
}
@ -818,6 +826,7 @@ public class FragmentIdentity extends FragmentBase {
!Objects.equals(fingerprint, identity.fingerprint) ||
use_ip != identity.use_ip ||
!Objects.equals(ehlo, identity.ehlo) ||
(user_max_size != null && !Objects.equals(user_max_size, identity.max_size)) ||
BuildConfig.DEBUG));
Log.i("Identity check=" + check);
@ -826,7 +835,7 @@ public class FragmentIdentity extends FragmentBase {
last_connected = identity.last_connected;
// Check SMTP server
Long max_size = null;
Long server_max_size = null;
if (check) {
// Create transport
String protocol = (starttls ? "smtp" : "smtps");
@ -838,7 +847,7 @@ public class FragmentIdentity extends FragmentBase {
auth, provider,
user, password,
certificate, fingerprint);
max_size = iservice.getMaxSize();
server_max_size = iservice.getMaxSize();
}
}
@ -891,8 +900,15 @@ public class FragmentIdentity extends FragmentBase {
identity.sign_key_alias = null;
identity.error = null;
identity.last_connected = last_connected;
if (max_size != null)
identity.max_size = max_size;
if (user_max_size == null)
identity.max_size = server_max_size;
else {
if (server_max_size == null)
identity.max_size = user_max_size;
else
identity.max_size = Math.min(user_max_size, server_max_size);
}
if (identity.primary)
db.identity().resetPrimary(account);

@ -685,6 +685,27 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBccHint" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvMaxSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_identity_max_size"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbUnicode" />
<eu.faircode.email.EditTextPlain
android:id="@+id/etMaxSize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="number"
android:maxLength="5"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMaxSize" />
<Button
android:id="@+id/btnSave"
android:layout_width="wrap_content"
@ -693,7 +714,7 @@
android:tag="disable"
android:text="@string/title_save"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbUnicode" />
app:layout_constraintTop_toBottomOf="@id/etMaxSize" />
<eu.faircode.email.ContentLoadingProgressBar
android:id="@+id/pbSave"
@ -806,7 +827,8 @@
cbUseIp,tvUseIpHint,tvEhlo,etEhlo,
cbSynchronize,cbPrimary,cbSelf,
cbSenderExtra,tvSenderExtra,etSenderExtra,tvSenderExtraHint,
tvReplyTo,etReplyTo,tvCc,etCc,tvCcHint,tvBcc,etBcc,tvBccHint,cbUnicode" />
tvReplyTo,etReplyTo,tvCc,etCc,tvCcHint,tvBcc,etBcc,tvBccHint,
cbUnicode,tvMaxSize,etMaxSize" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpError"

@ -562,6 +562,7 @@
<string name="title_advanced_sender_regex">Regex to match username of incoming email addresses</string>
<string name="title_identity_reply_to">Reply to address</string>
<string name="title_identity_unicode">Allow Unicode in email addresses</string>
<string name="title_identity_max_size">Maximum message size (MB)</string>
<string name="title_identity_receipt">Request delivery/read receipt by default</string>
<string name="title_identity_use_ip_hint">In case of \'invalid greeting\', \'requires valid address\' or a similar error, try to change this setting</string>
<string name="title_optional">Optional</string>
@ -922,7 +923,7 @@
<string name="title_text_reminder">Message is empty</string>
<string name="title_attachment_keywords">attached,attachment,attachments,included</string>
<string name="title_attachment_reminder">Did you intend to add an attachment?</string>
<string name="title_size_reminder">Message too large: %1$s of %2$s</string>
<string name="title_size_reminder">Message too large: %1$s &gt; %2$s</string>
<string name="title_attachments_missing">Not all attachments have been downloaded</string>
<string name="title_dialog_hint">This dialog can be enabled again via the three-dots menu in the top action bar</string>
<string name="title_draft_deleted">Draft discarded</string>

Loading…
Cancel
Save