diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java b/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java index 5f6fd68a73..b8f6f2ccb8 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java @@ -51,6 +51,8 @@ import androidx.preference.PreferenceManager; import org.json.JSONObject; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Locale; @@ -58,6 +60,14 @@ import javax.mail.Address; import javax.mail.internet.InternetAddress; public class FragmentDialogJunk extends FragmentDialogBase { + private static final List COMMON_DOMAINS = Collections.unmodifiableList(Arrays.asList( + "amazon\\.com", + "facebook\\.com", + "google\\.com", + "microsoft\\.com", + "twitter\\.com" + )); + @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { @@ -330,9 +340,15 @@ public class FragmentDialogJunk extends FragmentDialogBase { domains.add(domain); - for (String d : EmailProvider.getDomainNames(context)) - if (domain.matches(d)) + List regex = new ArrayList<>(); + regex.addAll(COMMON_DOMAINS); + regex.addAll(EmailProvider.getDomainNames(context)); + + for (String r : regex) + if (domain.matches(r)) { common = true; + break; + } } // Initialize