Added message to large reminder

pull/183/head
M66B 4 years ago
parent 1c864c9e94
commit f0c07f4213

@ -264,6 +264,7 @@ public class FragmentCompose extends FragmentBase {
private static final int REDUCED_IMAGE_QUALITY = 90; // percent
private static final int RECIPIENTS_WARNING = 10;
private static final int HEADERS_SIZE = 10 * 1024; // bytes
private static final int REQUEST_CONTACT_TO = 1;
private static final int REQUEST_CONTACT_CC = 2;
@ -4273,6 +4274,20 @@ public class FragmentCompose extends FragmentBase {
break;
}
}
// Check size
if (identity != null && identity.max_size != null) {
long size = HEADERS_SIZE + body.length();
for (EntityAttachment attachment : attachments)
if (attachment.available)
size += attachment.size;
if (size > identity.max_size) {
args.putBoolean("remind_size", true);
args.putLong("size", size);
args.putLong("max_size", identity.max_size);
}
}
} else {
Handler handler = new Handler(context.getMainLooper());
handler.post(new Runnable() {
@ -4437,11 +4452,12 @@ public class FragmentCompose extends FragmentBase {
boolean remind_subject = args.getBoolean("remind_subject", false);
boolean remind_text = args.getBoolean("remind_text", false);
boolean remind_attachment = args.getBoolean("remind_attachment", false);
boolean remind_size = args.getBoolean("remind_size", false);
int recipients = (draft.to == null ? 0 : draft.to.length) +
(draft.cc == null ? 0 : draft.cc.length) +
(draft.bcc == null ? 0 : draft.bcc.length);
if (send_dialog || address_error != null || recipients > RECIPIENTS_WARNING || (send_reminders &&
if (send_dialog || address_error != null || recipients > RECIPIENTS_WARNING || remind_size || (send_reminders &&
(remind_to || remind_extra || remind_pgp || remind_subject || remind_text || remind_attachment))) {
setBusy(false);
@ -5122,6 +5138,9 @@ public class FragmentCompose extends FragmentBase {
final boolean remind_subject = args.getBoolean("remind_subject", false);
final boolean remind_text = args.getBoolean("remind_text", false);
final boolean remind_attachment = args.getBoolean("remind_attachment", false);
final boolean remind_size = args.getBoolean("remind_size", false);
final long size = args.getLong("size", -1);
final long max_size = args.getLong("max_size", -1);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean send_reminders = prefs.getBoolean("send_reminders", true);
@ -5140,6 +5159,7 @@ public class FragmentCompose extends FragmentBase {
final TextView tvRemindSubject = dview.findViewById(R.id.tvRemindSubject);
final TextView tvRemindText = dview.findViewById(R.id.tvRemindText);
final TextView tvRemindAttachment = dview.findViewById(R.id.tvRemindAttachment);
final TextView tvRemindSize = dview.findViewById(R.id.tvRemindSize);
final SwitchCompat swSendReminders = dview.findViewById(R.id.swSendReminders);
final TextView tvSendRemindersHint = dview.findViewById(R.id.tvSendRemindersHint);
final TextView tvTo = dview.findViewById(R.id.tvTo);
@ -5163,6 +5183,10 @@ public class FragmentCompose extends FragmentBase {
tvRemindSubject.setVisibility(send_reminders && remind_subject ? View.VISIBLE : View.GONE);
tvRemindText.setVisibility(send_reminders && remind_text ? View.VISIBLE : View.GONE);
tvRemindAttachment.setVisibility(send_reminders && remind_attachment ? View.VISIBLE : View.GONE);
tvRemindSize.setText(getString(R.string.title_size_reminder,
Helper.humanReadableByteCount(size, true), Helper.humanReadableByteCount(max_size, true)));
tvRemindSize.setVisibility(remind_size ? View.VISIBLE : View.GONE);
tvTo.setText(null);
tvVia.setText(null);
tvReceipt.setVisibility(View.GONE);
@ -5445,7 +5469,7 @@ public class FragmentCompose extends FragmentBase {
.setView(dview)
.setNegativeButton(android.R.string.cancel, null);
if (address_error == null && !remind_to) {
if (address_error == null && !remind_to && !remind_size) {
if (send_delayed != 0)
builder.setNeutralButton(R.string.title_send_now, new DialogInterface.OnClickListener() {
@Override

@ -26,7 +26,7 @@
android:layout_marginTop="12dp"
android:text="Invalid address"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?attr/colorWarning"
android:textColor="?attr/colorError"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMessage" />
@ -96,6 +96,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemindText" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvRemindSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_size_reminder"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?attr/colorError"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemindAttachment" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSendReminders"
android:layout_width="0dp"
@ -105,7 +116,7 @@
android:text="@string/title_advanced_send_reminders"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemindAttachment"
app:layout_constraintTop_toBottomOf="@id/tvRemindSize"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView

@ -922,6 +922,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_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