Added internal domain names option

pull/198/head
M66B 4 years ago
parent 20a592c14b
commit 535b1128d2

File diff suppressed because it is too large Load Diff

@ -65,7 +65,7 @@ import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 195,
version = 196,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2007,6 +2007,12 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `answer` ADD COLUMN `receipt` INTEGER NOT NULL DEFAULT 0");
}
}).addMigrations(new Migration(195, 196) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `identity` ADD COLUMN `internal` TEXT");
}
});
}

@ -101,6 +101,7 @@ public class EntityIdentity {
public String replyto;
public String cc;
public String bcc;
public String internal;
@NonNull
public Boolean unicode = false;
@NonNull

@ -4925,8 +4925,6 @@ public class FragmentCompose extends FragmentBase {
// identity != null && identity.sender_extra)
// args.putBoolean("remind_extra", true);
if (draft.ui_encrypt == null ||
EntityMessage.ENCRYPT_NONE.equals(draft.ui_encrypt)) {
List<Address> recipients = new ArrayList<>();
if (draft.to != null)
recipients.addAll(Arrays.asList(draft.to));
@ -4935,6 +4933,37 @@ public class FragmentCompose extends FragmentBase {
if (draft.bcc != null)
recipients.addAll(Arrays.asList(draft.bcc));
if (identity != null && !TextUtils.isEmpty(identity.internal)) {
boolean external = false;
String[] internals = identity.internal.split(",");
for (Address recipient : recipients) {
String email = ((InternetAddress) recipient).getAddress();
if (TextUtils.isEmpty(email))
continue;
int at = email.lastIndexOf('@');
if (at < 0)
continue;
String domain = email.substring(at + 1).trim();
if (TextUtils.isEmpty(domain))
continue;
boolean found = false;
for (String internal : internals)
if (internal.equalsIgnoreCase(domain)) {
found = true;
break;
}
if (!found) {
external = true;
break;
}
}
args.putBoolean("remind_external", external);
}
if (draft.ui_encrypt == null ||
EntityMessage.ENCRYPT_NONE.equals(draft.ui_encrypt)) {
if (recipients.size() > 0) {
if (pgpService != null && pgpService.isBound()) {
String[] userIds = new String[recipients.size()];
@ -5210,6 +5239,7 @@ public class FragmentCompose extends FragmentBase {
boolean remind_smime = args.getBoolean("remind_smime", false);
boolean remind_to = args.getBoolean("remind_to", false);
boolean remind_extra = args.getBoolean("remind_extra", false);
boolean remind_external = args.getBoolean("remind_external", false);
boolean remind_subject = args.getBoolean("remind_subject", false);
boolean remind_text = args.getBoolean("remind_text", false);
boolean remind_attachment = args.getBoolean("remind_attachment", false);
@ -5219,7 +5249,8 @@ public class FragmentCompose extends FragmentBase {
(draft.cc == null ? 0 : draft.cc.length) +
(draft.bcc == null ? 0 : draft.bcc.length);
if (send_dialog || force_dialog ||
address_error != null || mx_error != null || remind_dsn || remind_size || remind_pgp || remind_smime || remind_to ||
address_error != null || mx_error != null ||
remind_dsn || remind_size || remind_pgp || remind_smime || remind_to || remind_external ||
recipients > RECIPIENTS_WARNING ||
(formatted && (draft.plain_only != null && draft.plain_only)) ||
(send_reminders &&
@ -5889,6 +5920,7 @@ public class FragmentCompose extends FragmentBase {
final boolean remind_smime = args.getBoolean("remind_smime", false);
final boolean remind_to = args.getBoolean("remind_to", false);
final boolean remind_extra = args.getBoolean("remind_extra", false);
final boolean remind_external = args.getBoolean("remind_external", false);
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);
@ -5917,6 +5949,7 @@ public class FragmentCompose extends FragmentBase {
final TextView tvRemindSmime = dview.findViewById(R.id.tvRemindSmime);
final TextView tvRemindTo = dview.findViewById(R.id.tvRemindTo);
final TextView tvRemindExtra = dview.findViewById(R.id.tvRemindExtra);
final TextView tvRemindExternal = dview.findViewById(R.id.tvRemindExternal);
final TextView tvRemindSubject = dview.findViewById(R.id.tvRemindSubject);
final TextView tvRemindText = dview.findViewById(R.id.tvRemindText);
final TextView tvRemindAttachment = dview.findViewById(R.id.tvRemindAttachment);
@ -5954,6 +5987,7 @@ public class FragmentCompose extends FragmentBase {
tvRemindTo.setVisibility(remind_to ? View.VISIBLE : View.GONE);
tvRemindExtra.setVisibility(send_reminders && remind_extra ? View.VISIBLE : View.GONE);
tvRemindExternal.setVisibility(remind_external ? View.VISIBLE : View.GONE);
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);

@ -116,6 +116,7 @@ public class FragmentIdentity extends FragmentBase {
private EditText etReplyTo;
private EditText etCc;
private EditText etBcc;
private EditText etInternal;
private CheckBox cbSignDefault;
private CheckBox cbEncryptDefault;
private CheckBox cbUnicode;
@ -213,6 +214,7 @@ public class FragmentIdentity extends FragmentBase {
etReplyTo = view.findViewById(R.id.etReplyTo);
etCc = view.findViewById(R.id.etCc);
etBcc = view.findViewById(R.id.etBcc);
etInternal = view.findViewById(R.id.etInternal);
cbSignDefault = view.findViewById(R.id.cbSignDefault);
cbEncryptDefault = view.findViewById(R.id.cbEncryptDefault);
cbUnicode = view.findViewById(R.id.cbUnicode);
@ -635,6 +637,7 @@ public class FragmentIdentity extends FragmentBase {
args.putString("replyto", etReplyTo.getText().toString().trim());
args.putString("cc", etCc.getText().toString().trim());
args.putString("bcc", etBcc.getText().toString().trim());
args.putString("internal", etInternal.getText().toString().replaceAll(" ", ""));
args.putBoolean("sign_default", cbSignDefault.isChecked());
args.putBoolean("encrypt_default", cbEncryptDefault.isChecked());
args.putBoolean("unicode", cbUnicode.isChecked());
@ -720,6 +723,7 @@ public class FragmentIdentity extends FragmentBase {
String replyto = args.getString("replyto");
String cc = args.getString("cc");
String bcc = args.getString("bcc");
String internal = args.getString("internal");
boolean sign_default = args.getBoolean("sign_default");
boolean encrypt_default = args.getBoolean("encrypt_default");
boolean unicode = args.getBoolean("unicode");
@ -779,6 +783,9 @@ public class FragmentIdentity extends FragmentBase {
throw new IllegalArgumentException(context.getString(R.string.title_email_invalid, bcc));
}
if (TextUtils.isEmpty(internal))
internal = null;
if (TextUtils.isEmpty(display))
display = null;
@ -868,6 +875,8 @@ public class FragmentIdentity extends FragmentBase {
return true;
if (!Objects.equals(identity.bcc, bcc))
return true;
if (!Objects.equals(identity.internal, internal))
return true;
if (!Objects.equals(identity.sign_default, sign_default))
return true;
if (!Objects.equals(identity.encrypt_default, encrypt_default))
@ -965,6 +974,7 @@ public class FragmentIdentity extends FragmentBase {
identity.replyto = replyto;
identity.cc = cc;
identity.bcc = bcc;
identity.internal = internal;
identity.sign_default = sign_default;
identity.encrypt_default = encrypt_default;
identity.unicode = unicode;
@ -1145,6 +1155,7 @@ public class FragmentIdentity extends FragmentBase {
etReplyTo.setText(identity == null ? null : identity.replyto);
etCc.setText(identity == null ? null : identity.cc);
etBcc.setText(identity == null ? null : identity.bcc);
etInternal.setText(identity == null ? null : identity.internal);
cbSignDefault.setChecked(identity != null && identity.sign_default);
cbEncryptDefault.setChecked(identity != null && identity.encrypt_default);
cbUnicode.setChecked(identity != null && identity.unicode);

@ -103,6 +103,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemindTo" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvRemindExternal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_external_reminder"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?attr/colorWarning"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemindExtra" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvRemindSubject"
android:layout_width="wrap_content"
@ -112,7 +123,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?attr/colorWarning"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemindExtra" />
app:layout_constraintTop_toBottomOf="@id/tvRemindExternal" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvRemindText"

@ -730,6 +730,38 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etBcc" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvInternal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_identity_internal"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBccHint" />
<eu.faircode.email.EditTextPlain
android:id="@+id/etInternal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/title_optional"
android:importantForAutofill="no"
android:inputType="textNoSuggestions"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvInternal" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvInternalHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_advanced_internal_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etInternal" />
<CheckBox
android:id="@+id/cbSignDefault"
android:layout_width="wrap_content"
@ -737,7 +769,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_advanced_sign_default"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBccHint" />
app:layout_constraintTop_toBottomOf="@id/tvInternalHint" />
<CheckBox
android:id="@+id/cbEncryptDefault"
@ -911,6 +943,7 @@
cbSynchronize,cbPrimary,cbSelf,tvSelfHint,
cbSenderExtra,cbSenderExtraName,tvSenderExtra,etSenderExtra,ibSenderExtra,tvSenderExtraHint,
tvReplyTo,etReplyTo,tvCc,etCc,tvCcHint,tvBcc,etBcc,tvBccHint,
tvInternal,etInternal,tvInternalHint,
cbSignDefault,cbEncryptDefault,
cbUnicode,tvUnicodeHint,tvMaxSize,etMaxSize" />

@ -631,6 +631,7 @@
<string name="title_advanced_autoclose_hint">Automatically close conversations when all messages are archived, sent or trashed</string>
<string name="title_advanced_sender_hint">Most providers do not allow modified sender addresses</string>
<string name="title_advanced_bcc_hint">The address won\'t be shown, but will be added on sending</string>
<string name="title_advanced_internal_hint">There will be a warning when sending to another domain</string>
<string name="title_advanced_display_harmful_hint">Disabling this option might be harmful to your privacy</string>
<string name="title_advanced_display_hidden_hint">This can result in odd looking and double texts</string>
@ -673,6 +674,7 @@
<string name="title_advanced_sender_name">Use name when sender address has been edited</string>
<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_internal">Internal domain names (comma separated)</string>
<string name="title_identity_unicode">Use Unicode transport</string>
<string name="title_identity_unicode_remark">Most servers do not support this</string>
<string name="title_identity_max_size">Maximum message size (MB)</string>
@ -1114,10 +1116,11 @@
<string name="title_send_receipt_remark">Most providers and email clients ignore receipt requests</string>
<string name="title_from_missing">Sender missing</string>
<string name="title_extra_missing">Username missing</string>
<string name="title_to_missing">Recipient missing</string>
<string name="title_pgp_reminder">PGP keys available</string>
<string name="title_smime_reminder">S/MIME keys available</string>
<string name="title_to_missing">Recipient missing</string>
<string name="title_extra_missing">Username missing</string>
<string name="title_external_reminder">Sending to an external address</string>
<string name="title_subject_reminder">Subject is empty</string>
<string name="title_text_reminder">Message is empty</string>
<string name="title_attachment_keywords">attached,attachment,attachments,included</string>

Loading…
Cancel
Save