Plain text only warning

This commit is contained in:
M66B 2020-06-22 18:52:19 +02:00
parent f36760b2cd
commit f3c29788e2
2 changed files with 23 additions and 14 deletions

View File

@ -215,6 +215,7 @@ public class FragmentCompose extends FragmentBase {
private ImageButton ibCcBcc; private ImageButton ibCcBcc;
private RecyclerView rvAttachment; private RecyclerView rvAttachment;
private TextView tvNoInternetAttachments; private TextView tvNoInternetAttachments;
private TextView tvPlainTextOnly;
private EditTextCompose etBody; private EditTextCompose etBody;
private TextView tvNoInternet; private TextView tvNoInternet;
private TextView tvSignature; private TextView tvSignature;
@ -315,6 +316,7 @@ public class FragmentCompose extends FragmentBase {
ibCcBcc = view.findViewById(R.id.ivCcBcc); ibCcBcc = view.findViewById(R.id.ivCcBcc);
rvAttachment = view.findViewById(R.id.rvAttachment); rvAttachment = view.findViewById(R.id.rvAttachment);
tvNoInternetAttachments = view.findViewById(R.id.tvNoInternetAttachments); tvNoInternetAttachments = view.findViewById(R.id.tvNoInternetAttachments);
tvPlainTextOnly = view.findViewById(R.id.tvPlainTextOnly);
etBody = view.findViewById(R.id.etBody); etBody = view.findViewById(R.id.etBody);
tvNoInternet = view.findViewById(R.id.tvNoInternet); tvNoInternet = view.findViewById(R.id.tvNoInternet);
tvSignature = view.findViewById(R.id.tvSignature); tvSignature = view.findViewById(R.id.tvSignature);
@ -672,6 +674,7 @@ public class FragmentCompose extends FragmentBase {
etExtra.setHint(""); etExtra.setHint("");
tvDomain.setText(null); tvDomain.setText(null);
tvPlainTextOnly.setVisibility(View.GONE);
etBody.setText(null); etBody.setText(null);
grpHeader.setVisibility(View.GONE); grpHeader.setVisibility(View.GONE);
@ -3819,6 +3822,9 @@ public class FragmentCompose extends FragmentBase {
} }
}); });
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
final boolean plain_only = prefs.getBoolean("plain_only", false);
db.message().liveMessage(data.draft.id).observe(getViewLifecycleOwner(), new Observer<EntityMessage>() { db.message().liveMessage(data.draft.id).observe(getViewLifecycleOwner(), new Observer<EntityMessage>() {
@Override @Override
public void onChanged(EntityMessage draft) { public void onChanged(EntityMessage draft) {
@ -3833,6 +3839,9 @@ public class FragmentCompose extends FragmentBase {
if (draft.content && state == State.NONE) if (draft.content && state == State.NONE)
showDraft(draft, false); showDraft(draft, false);
tvPlainTextOnly.setVisibility(
draft.plain_only != null && draft.plain_only && !plain_only ? View.VISIBLE : View.GONE);
tvNoInternet.setTag(draft.content); tvNoInternet.setTag(draft.content);
checkInternet(); checkInternet();
} }
@ -4232,9 +4241,6 @@ public class FragmentCompose extends FragmentBase {
if (empty && d.select("div[fairemail=reference]").isEmpty()) if (empty && d.select("div[fairemail=reference]").isEmpty())
args.putBoolean("remind_text", true); args.putBoolean("remind_text", true);
if (draft.plain_only != null && draft.plain_only)
args.putBoolean("remind_plain", true);
int attached = 0; int attached = 0;
for (EntityAttachment attachment : attachments) for (EntityAttachment attachment : attachments)
if (!attachment.available) if (!attachment.available)
@ -4421,14 +4427,13 @@ public class FragmentCompose extends FragmentBase {
boolean remind_pgp = args.getBoolean("remind_pgp", false); boolean remind_pgp = args.getBoolean("remind_pgp", false);
boolean remind_subject = args.getBoolean("remind_subject", false); boolean remind_subject = args.getBoolean("remind_subject", false);
boolean remind_text = args.getBoolean("remind_text", false); boolean remind_text = args.getBoolean("remind_text", false);
boolean remind_plain = args.getBoolean("remind_plain", false);
boolean remind_attachment = args.getBoolean("remind_attachment", false); boolean remind_attachment = args.getBoolean("remind_attachment", false);
int recipients = (draft.to == null ? 0 : draft.to.length) + int recipients = (draft.to == null ? 0 : draft.to.length) +
(draft.cc == null ? 0 : draft.cc.length) + (draft.cc == null ? 0 : draft.cc.length) +
(draft.bcc == null ? 0 : draft.bcc.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 || (send_reminders &&
(remind_to || remind_extra || remind_pgp || remind_subject || remind_text || remind_plain || remind_attachment))) { (remind_to || remind_extra || remind_pgp || remind_subject || remind_text || remind_attachment))) {
setBusy(false); setBusy(false);
FragmentDialogSend fragment = new FragmentDialogSend(); FragmentDialogSend fragment = new FragmentDialogSend();
@ -5106,7 +5111,6 @@ public class FragmentCompose extends FragmentBase {
final boolean remind_pgp = args.getBoolean("remind_pgp", false); final boolean remind_pgp = args.getBoolean("remind_pgp", false);
final boolean remind_subject = args.getBoolean("remind_subject", false); final boolean remind_subject = args.getBoolean("remind_subject", false);
final boolean remind_text = args.getBoolean("remind_text", false); final boolean remind_text = args.getBoolean("remind_text", false);
final boolean remind_plain = args.getBoolean("remind_plain", false);
final boolean remind_attachment = args.getBoolean("remind_attachment", false); final boolean remind_attachment = args.getBoolean("remind_attachment", false);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
@ -5163,7 +5167,7 @@ public class FragmentCompose extends FragmentBase {
Helper.setViewsEnabled(dview, false); Helper.setViewsEnabled(dview, false);
boolean reminder = (remind_to || remind_extra || remind_pgp || remind_subject || remind_text || remind_plain || remind_attachment); boolean reminder = (remind_to || remind_extra || remind_pgp || remind_subject || remind_text || remind_attachment);
swSendReminders.setChecked(send_reminders); swSendReminders.setChecked(send_reminders);
swSendReminders.setVisibility(send_reminders && reminder ? View.VISIBLE : View.GONE); swSendReminders.setVisibility(send_reminders && reminder ? View.VISIBLE : View.GONE);
tvSendRemindersHint.setVisibility(View.GONE); tvSendRemindersHint.setVisibility(View.GONE);
@ -5178,9 +5182,6 @@ public class FragmentCompose extends FragmentBase {
tvRemindText.setVisibility(checked && remind_text ? View.VISIBLE : View.GONE); tvRemindText.setVisibility(checked && remind_text ? View.VISIBLE : View.GONE);
tvRemindAttachment.setVisibility(checked && remind_attachment ? View.VISIBLE : View.GONE); tvRemindAttachment.setVisibility(checked && remind_attachment ? View.VISIBLE : View.GONE);
tvSendRemindersHint.setVisibility(checked ? View.GONE : View.VISIBLE); tvSendRemindersHint.setVisibility(checked ? View.GONE : View.VISIBLE);
cbPlainOnly.setTextColor(Helper.resolveColor(getContext(),
checked && cbPlainOnly.isChecked() ? R.attr.colorWarning : android.R.attr.textColorSecondary));
} }
}); });
@ -5195,9 +5196,6 @@ public class FragmentCompose extends FragmentBase {
cbPlainOnly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbPlainOnly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
cbPlainOnly.setTextColor(Helper.resolveColor(getContext(),
checked ? R.attr.colorWarning : android.R.attr.textColorSecondary));
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", id); args.putLong("id", id);
args.putBoolean("plain_only", checked); args.putBoolean("plain_only", checked);

View File

@ -245,6 +245,17 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvNoInternetAttachments" /> app:layout_constraintTop_toBottomOf="@+id/tvNoInternetAttachments" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvPlainTextOnly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_send_plain_text"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="bold|italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparator" />
<eu.faircode.email.EditTextCompose <eu.faircode.email.EditTextCompose
android:id="@+id/etBody" android:id="@+id/etBody"
android:layout_width="0dp" android:layout_width="0dp"
@ -262,7 +273,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparator" /> app:layout_constraintTop_toBottomOf="@id/tvPlainTextOnly" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvNoInternet" android:id="@+id/tvNoInternet"