mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-14 13:03:13 +02:00
Refactoring
This commit is contained in:
@@ -62,15 +62,10 @@ public class DnsHelper {
|
||||
|
||||
for (Address address : addresses) {
|
||||
String email = ((InternetAddress) address).getAddress();
|
||||
if (email == null)
|
||||
String domain = UriHelper.getEmailDomain(email);
|
||||
if (domain == null)
|
||||
continue;
|
||||
|
||||
int d = email.lastIndexOf("@");
|
||||
if (d < 0)
|
||||
continue;
|
||||
|
||||
String domain = email.substring(d + 1);
|
||||
|
||||
boolean found = true;
|
||||
try {
|
||||
SimpleResolver resolver = new SimpleResolver(getDnsServer(context));
|
||||
|
||||
@@ -219,7 +219,7 @@ public class EmailProvider implements Parcelable {
|
||||
|
||||
@NonNull
|
||||
static EmailProvider fromEmail(Context context, String email, Discover discover) throws IOException {
|
||||
int at = email.indexOf("@");
|
||||
int at = email.indexOf('@');
|
||||
String domain = (at < 0 ? email : email.substring(at + 1));
|
||||
if (at < 0)
|
||||
email = "someone@" + domain;
|
||||
|
||||
@@ -4112,7 +4112,7 @@ public class FragmentCompose extends FragmentBase {
|
||||
}
|
||||
if (preferred != null) {
|
||||
String from = ((InternetAddress) preferred).getAddress();
|
||||
data.draft.extra = from.substring(0, from.indexOf("@"));
|
||||
data.draft.extra = UriHelper.getEmailUser(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5229,14 +5229,8 @@ public class FragmentCompose extends FragmentBase {
|
||||
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))
|
||||
String domain = UriHelper.getEmailDomain(email);
|
||||
if (domain == null)
|
||||
continue;
|
||||
|
||||
boolean found = false;
|
||||
|
||||
@@ -31,6 +31,17 @@ public class UriHelper {
|
||||
return host;
|
||||
}
|
||||
|
||||
static String getEmailUser(String address) {
|
||||
if (address == null)
|
||||
return null;
|
||||
|
||||
int at = address.indexOf('@');
|
||||
if (at > 0)
|
||||
return address.substring(0, at);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static String getEmailDomain(String address) {
|
||||
if (address == null)
|
||||
return null;
|
||||
@@ -39,6 +50,6 @@ public class UriHelper {
|
||||
if (at > 0)
|
||||
return address.substring(at + 1);
|
||||
|
||||
return address;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user