mirror of https://github.com/M66B/FairEmail.git
Added identity setting to send Unicode addresses
This commit is contained in:
parent
fa0ffd0c21
commit
fc33f471bb
File diff suppressed because it is too large
Load Diff
|
@ -60,7 +60,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
|
|||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 152,
|
||||
version = 153,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
|
@ -1444,6 +1444,13 @@ public abstract class DB extends RoomDatabase {
|
|||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `message` ADD COLUMN `hash` TEXT");
|
||||
}
|
||||
})
|
||||
.addMigrations(new Migration(152, 153) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `identity` ADD COLUMN `unicode` INTEGER NOT NULL DEFAULT 0");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -239,6 +239,10 @@ public class EmailService implements AutoCloseable {
|
|||
properties.put("mail." + protocol + ".rsetbeforequit", Boolean.toString(keep));
|
||||
}
|
||||
|
||||
void setUnicode(boolean value) {
|
||||
properties.put("mail.mime.allowutf8", Boolean.toString(value));
|
||||
}
|
||||
|
||||
void setListener(StoreListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
|
|
@ -95,6 +95,8 @@ public class EntityIdentity {
|
|||
public String cc;
|
||||
public String bcc;
|
||||
@NonNull
|
||||
public Boolean unicode = false;
|
||||
@NonNull
|
||||
public Boolean plain_only = false; // obsolete
|
||||
@NonNull
|
||||
public Boolean encrypt = false; // obsolete
|
||||
|
|
|
@ -111,6 +111,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
private EditText etReplyTo;
|
||||
private EditText etCc;
|
||||
private EditText etBcc;
|
||||
private CheckBox cbUnicode;
|
||||
|
||||
private Button btnSave;
|
||||
private ContentLoadingProgressBar pbSave;
|
||||
|
@ -200,6 +201,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
etReplyTo = view.findViewById(R.id.etReplyTo);
|
||||
etCc = view.findViewById(R.id.etCc);
|
||||
etBcc = view.findViewById(R.id.etBcc);
|
||||
cbUnicode = view.findViewById(R.id.cbUnicode);
|
||||
|
||||
btnSave = view.findViewById(R.id.btnSave);
|
||||
pbSave = view.findViewById(R.id.pbSave);
|
||||
|
@ -577,6 +579,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.putBoolean("unicode", cbUnicode.isChecked());
|
||||
args.putLong("account", account == null ? -1 : account.id);
|
||||
args.putString("host", etHost.getText().toString().trim());
|
||||
args.putBoolean("starttls", rgEncryption.getCheckedRadioButtonId() == R.id.radio_starttls);
|
||||
|
@ -648,6 +651,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
String replyto = args.getString("replyto");
|
||||
String cc = args.getString("cc");
|
||||
String bcc = args.getString("bcc");
|
||||
boolean unicode = args.getBoolean("unicode");
|
||||
|
||||
boolean should = args.getBoolean("should");
|
||||
|
||||
|
@ -773,6 +777,8 @@ public class FragmentIdentity extends FragmentBase {
|
|||
return true;
|
||||
if (!Objects.equals(identity.bcc, bcc))
|
||||
return true;
|
||||
if (!Objects.equals(identity.unicode, unicode))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -850,6 +856,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
identity.replyto = replyto;
|
||||
identity.cc = cc;
|
||||
identity.bcc = bcc;
|
||||
identity.unicode = unicode;
|
||||
identity.sent_folder = null;
|
||||
identity.sign_key = null;
|
||||
identity.sign_key_alias = null;
|
||||
|
@ -1057,6 +1064,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);
|
||||
cbUnicode.setChecked(identity != null && identity.unicode);
|
||||
|
||||
auth = (identity == null ? EmailService.AUTH_TYPE_PASSWORD : identity.auth_type);
|
||||
provider = (identity == null ? null : identity.provider);
|
||||
|
|
|
@ -188,13 +188,13 @@ public class MessageHelper {
|
|||
}
|
||||
|
||||
if (message.to != null && message.to.length > 0)
|
||||
imessage.setRecipients(Message.RecipientType.TO, convertAddress(message.to));
|
||||
imessage.setRecipients(Message.RecipientType.TO, convertAddress(message.to, identity));
|
||||
|
||||
if (message.cc != null && message.cc.length > 0)
|
||||
imessage.setRecipients(Message.RecipientType.CC, convertAddress(message.cc));
|
||||
imessage.setRecipients(Message.RecipientType.CC, convertAddress(message.cc, identity));
|
||||
|
||||
if (message.bcc != null && message.bcc.length > 0)
|
||||
imessage.setRecipients(Message.RecipientType.BCC, convertAddress(message.bcc));
|
||||
imessage.setRecipients(Message.RecipientType.BCC, convertAddress(message.bcc, identity));
|
||||
|
||||
if (message.subject != null)
|
||||
imessage.setSubject(message.subject);
|
||||
|
@ -203,15 +203,15 @@ public class MessageHelper {
|
|||
if (identity != null) {
|
||||
// Add reply to
|
||||
if (identity.replyto != null)
|
||||
imessage.setReplyTo(convertAddress(InternetAddress.parse(identity.replyto)));
|
||||
imessage.setReplyTo(convertAddress(InternetAddress.parse(identity.replyto), identity));
|
||||
|
||||
// Add extra cc
|
||||
if (identity.cc != null)
|
||||
addAddress(identity.cc, Message.RecipientType.CC, imessage);
|
||||
addAddress(identity.cc, Message.RecipientType.CC, imessage, identity);
|
||||
|
||||
// Add extra bcc
|
||||
if (identity.bcc != null)
|
||||
addAddress(identity.bcc, Message.RecipientType.BCC, imessage);
|
||||
addAddress(identity.bcc, Message.RecipientType.BCC, imessage, identity);
|
||||
|
||||
// Delivery/read request
|
||||
if (message.receipt_request != null && message.receipt_request) {
|
||||
|
@ -458,7 +458,7 @@ public class MessageHelper {
|
|||
return imessage;
|
||||
}
|
||||
|
||||
private static void addAddress(String email, Message.RecipientType type, MimeMessage imessage) throws MessagingException {
|
||||
private static void addAddress(String email, Message.RecipientType type, MimeMessage imessage, EntityIdentity identity) throws MessagingException {
|
||||
List<Address> result = new ArrayList<>();
|
||||
|
||||
Address[] existing = imessage.getRecipients(type);
|
||||
|
@ -466,7 +466,7 @@ public class MessageHelper {
|
|||
result.addAll(Arrays.asList(existing));
|
||||
|
||||
Address[] all = imessage.getAllRecipients();
|
||||
Address[] addresses = convertAddress(InternetAddress.parse(email));
|
||||
Address[] addresses = convertAddress(InternetAddress.parse(email), identity);
|
||||
for (Address address : addresses) {
|
||||
boolean found = false;
|
||||
if (all != null)
|
||||
|
@ -482,7 +482,10 @@ public class MessageHelper {
|
|||
imessage.setRecipients(type, result.toArray(new Address[0]));
|
||||
}
|
||||
|
||||
private static Address[] convertAddress(Address[] addresses) {
|
||||
private static Address[] convertAddress(Address[] addresses, EntityIdentity identity) {
|
||||
if (identity != null && identity.unicode)
|
||||
return addresses;
|
||||
|
||||
// https://en.wikipedia.org/wiki/International_email
|
||||
for (Address address : addresses) {
|
||||
String email = ((InternetAddress) address).getAddress();
|
||||
|
|
|
@ -388,6 +388,8 @@ public class ServiceSend extends ServiceBase {
|
|||
|
||||
// Create message
|
||||
Properties props = MessageHelper.getSessionProperties();
|
||||
if (ident.unicode)
|
||||
props.put("mail.mime.allowutf8", "true");
|
||||
Session isession = Session.getInstance(props, null);
|
||||
MimeMessage imessage = MessageHelper.from(this, message, ident, isession, true);
|
||||
|
||||
|
@ -465,6 +467,7 @@ public class ServiceSend extends ServiceBase {
|
|||
try (EmailService iservice = new EmailService(
|
||||
this, ident.getProtocol(), ident.realm, ident.insecure, debug)) {
|
||||
iservice.setUseIp(ident.use_ip);
|
||||
iservice.setUnicode(ident.unicode);
|
||||
|
||||
// Connect transport
|
||||
db.identity().setIdentityState(ident.id, "connecting");
|
||||
|
|
|
@ -630,6 +630,15 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etBcc" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbUnicode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_identity_unicode"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvBccHint" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSave"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -638,7 +647,7 @@
|
|||
android:tag="disable"
|
||||
android:text="@string/title_save"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvBccHint" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cbUnicode" />
|
||||
|
||||
<eu.faircode.email.ContentLoadingProgressBar
|
||||
android:id="@+id/pbSave"
|
||||
|
@ -751,7 +760,7 @@
|
|||
cbUseIp,tvUseIpHint,
|
||||
cbSynchronize,cbPrimary,
|
||||
cbSenderExtra,tvSenderExtra,etSenderExtra,tvSenderExtraHint,
|
||||
tvReplyTo,etReplyTo,tvCc,etCc,tvCcHint,tvBcc,etBcc,tvBccHint" />
|
||||
tvReplyTo,etReplyTo,tvCc,etCc,tvCcHint,tvBcc,etBcc,tvBccHint,cbUnicode" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpError"
|
||||
|
|
|
@ -534,6 +534,7 @@
|
|||
<string name="title_advanced_sender">Allow editing sender address</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_unicode">Allow Unicode in email addresses</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>
|
||||
|
|
Loading…
Reference in New Issue