Added input field for MAIL FROM

This commit is contained in:
M66B 2024-04-25 11:01:34 +02:00
parent a32d71273b
commit 8529e6c012
6 changed files with 3090 additions and 4 deletions

File diff suppressed because it is too large Load Diff

View File

@ -68,7 +68,7 @@ import javax.mail.internet.InternetAddress;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 291,
version = 292,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2950,6 +2950,12 @@ public abstract class DB extends RoomDatabase {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `last_view` INTEGER");
}
}).addMigrations(new Migration(291, 292) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `identity` ADD COLUMN `envelopeFrom` TEXT");
}
}).addMigrations(new Migration(998, 999) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {

View File

@ -63,8 +63,6 @@ public class EntityIdentity {
public String name;
@NonNull
public String email;
@Ignore
public String envelopeFrom;
@NonNull
public Long account;
public String display;
@ -114,6 +112,7 @@ public class EntityIdentity {
public String replyto;
public String cc;
public String bcc;
public String envelopeFrom;
public String internal;
public String uri; // linked contact
@NonNull

View File

@ -128,6 +128,7 @@ public class FragmentIdentity extends FragmentBase {
private EditText etReplyTo;
private EditText etCc;
private EditText etBcc;
private EditText etEnvelopeFrom;
private EditText etInternal;
private Button btnUri;
private TextView tvUriInfo;
@ -237,6 +238,7 @@ public class FragmentIdentity extends FragmentBase {
etReplyTo = view.findViewById(R.id.etReplyTo);
etCc = view.findViewById(R.id.etCc);
etBcc = view.findViewById(R.id.etBcc);
etEnvelopeFrom = view.findViewById(R.id.etEnvelopeFrom);
etInternal = view.findViewById(R.id.etInternal);
btnUri = view.findViewById(R.id.btnUri);
tvUriInfo = view.findViewById(R.id.tvUriInfo);
@ -778,6 +780,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("envelope_from", etEnvelopeFrom.getText().toString().trim());
args.putString("internal", etInternal.getText().toString().replaceAll(" ", ""));
args.putString("uri", (String) btnUri.getTag());
args.putBoolean("sign_default", cbSignDefault.isChecked());
@ -869,6 +872,7 @@ public class FragmentIdentity extends FragmentBase {
String replyto = args.getString("replyto");
String cc = args.getString("cc");
String bcc = args.getString("bcc");
String envelope_from = args.getString("envelope_from");
String internal = args.getString("internal");
String uri = args.getString("uri");
boolean sign_default = args.getBoolean("sign_default");
@ -932,6 +936,14 @@ public class FragmentIdentity extends FragmentBase {
throw new IllegalArgumentException(context.getString(R.string.title_email_invalid, bcc));
}
if (!TextUtils.isEmpty(envelope_from) && !should)
try {
for (InternetAddress address : InternetAddress.parse(envelope_from))
address.validate();
} catch (AddressException ex) {
throw new IllegalArgumentException(context.getString(R.string.title_email_invalid, envelope_from));
}
if (TextUtils.isEmpty(internal))
internal = null;
@ -959,6 +971,9 @@ public class FragmentIdentity extends FragmentBase {
if (TextUtils.isEmpty(bcc))
bcc = null;
if (TextUtils.isEmpty(envelope_from))
envelope_from = null;
if (color == Color.TRANSPARENT || !ActivityBilling.isPro(context))
color = null;
if (TextUtils.isEmpty(signature))
@ -1036,6 +1051,8 @@ public class FragmentIdentity extends FragmentBase {
return true;
if (!Objects.equals(identity.bcc, bcc))
return true;
if (!Objects.equals(identity.envelopeFrom, envelope_from))
return true;
if (!Objects.equals(identity.internal, internal))
return true;
if (!Objects.equals(identity.uri, uri))
@ -1150,6 +1167,7 @@ public class FragmentIdentity extends FragmentBase {
identity.replyto = replyto;
identity.cc = cc;
identity.bcc = bcc;
identity.envelopeFrom = envelope_from;
identity.internal = internal;
identity.uri = uri;
identity.sign_default = sign_default;
@ -1343,6 +1361,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);
etEnvelopeFrom.setText(identity == null ? null : identity.envelopeFrom);
etInternal.setText(identity == null ? null : identity.internal);
btnUri.setTag(identity == null ? null : identity.uri);
tvUriInfo.setText(identity == null ? null : getUriInfo(identity.uri));

View File

@ -833,6 +833,38 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etBcc" />
<TextView
android:id="@+id/tvEnvelopeFrom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_envelope_from"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBccHint" />
<eu.faircode.email.EditTextPlain
android:id="@+id/etEnvelopeFrom"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/title_optional"
android:importantForAutofill="no"
android:inputType="textEmailAddress"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvEnvelopeFrom" />
<TextView
android:id="@+id/tvEnvelopeFromHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_advanced_envelope_from_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etEnvelopeFrom" />
<TextView
android:id="@+id/tvInternal"
android:layout_width="wrap_content"
@ -841,7 +873,7 @@
android:text="@string/title_identity_internal"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBccHint" />
app:layout_constraintTop_toBottomOf="@id/tvEnvelopeFromHint" />
<eu.faircode.email.EditTextPlain
android:id="@+id/etInternal"
@ -1160,6 +1192,7 @@
cbSynchronize,cbPrimary,cbSelf,tvSelfHint,
cbSenderExtra,cbSenderExtraName,cbReplyExtraName,tvSenderExtra,etSenderExtra,ibSenderExtra,tvSenderExtraHint,
tvReplyTo,etReplyTo,tvCc,etCc,tvCcHint,tvBcc,etBcc,tvBccHint,
tvEnvelopeFrom,etEnvelopeFrom,tvEnvelopeFromHint,
tvInternal,etInternal,tvInternalHint,
btnUri,tvUriHint,tvUriInfo,tvUriPro,
tvE2Encryption,cbSignDefault,cbEncryptDefault,

View File

@ -1085,6 +1085,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_envelope_from_hint">This address will be used for SMTP MAIL FROM</string>
<string name="title_advanced_internal_hint">There will be a warning when sending to another domain</string>
<string name="title_advanced_uri">The details of the selected contact will be used for vCard attachments</string>
<string name="title_advanced_e2e_encryption">Options for end-to-end encryption</string>
@ -1662,6 +1663,7 @@
<string name="title_reply_to">Reply to:</string>
<string name="title_cc">CC:</string>
<string name="title_bcc">BCC:</string>
<string name="title_envelope_from">Envelope from:</string>
<string name="title_recipients">%1$d recipients</string>
<string name="title_via_identity">Via:</string>
<string name="title_sent">Sent:</string>