Browse Source

Select identity by canonical address

main
M66B 6 years ago
parent
commit
9d1fcf8ebc
2 changed files with 11 additions and 2 deletions
  1. +3
    -2
      app/src/main/java/eu/faircode/email/FragmentCompose.java
  2. +8
    -0
      app/src/main/java/eu/faircode/email/Helper.java

+ 3
- 2
app/src/main/java/eu/faircode/email/FragmentCompose.java View File

@ -805,9 +805,10 @@ public class FragmentCompose extends FragmentEx {
// Select identity matching from address
if (!found && draft.from != null && draft.from.length > 0) {
String from = ((InternetAddress) draft.from[0]).getAddress();
String from = Helper.canonicalAddress(((InternetAddress) draft.from[0]).getAddress());
for (int pos = 0; pos < identities.size(); pos++) {
if (identities.get(pos).email.equals(from)) {
if (Helper.canonicalAddress(identities.get(pos).email).equals(from)) {
spFrom.setSelection(pos);
found = true;
break;


+ 8
- 0
app/src/main/java/eu/faircode/email/Helper.java View File

@ -21,6 +21,7 @@ package eu.faircode.email;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.View;
@ -129,4 +130,11 @@ public class Helper {
static Address myAddress() throws UnsupportedEncodingException {
return new InternetAddress("marcel+fairemail@faircode.eu", "FairCode");
}
static String canonicalAddress(String address) {
String[] a = address.split("\\@");
if (a.length > 0)
a[0] = a[0].split("\\+")[0];
return TextUtils.join("@", a);
}
}

Loading…
Cancel
Save