From 9d2bb498a05bbfaff581044c0d3498d24b4ca8cb Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 8 Nov 2021 13:40:00 +0100 Subject: [PATCH] Show sender domain which will be blocked --- app/src/main/java/eu/faircode/email/FragmentDialogJunk.java | 5 ++++- app/src/main/res/layout/dialog_junk.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java b/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java index 912112650b..cc948608de 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java @@ -305,12 +305,13 @@ public class FragmentDialogJunk extends FragmentDialogBase { } }); + String domain = null; try { boolean common = false; Address[] froms = MessageHelper.parseAddresses(context, from); String email = (froms.length == 0 ? null : ((InternetAddress) froms[0]).getAddress()); int at = (email == null ? -1 : email.indexOf('@')); - String domain = (at > 0 ? email.substring(at + 1).toLowerCase(Locale.ROOT) : null); + domain = (at > 0 ? email.substring(at + 1).toLowerCase(Locale.ROOT) : null); if (domain != null) { List domains = EmailProvider.getDomainNames(context); @@ -341,6 +342,8 @@ public class FragmentDialogJunk extends FragmentDialogBase { cbBlockSender.setEnabled(canBlock); cbBlockDomain.setEnabled(false); cbBlockSender.setChecked(canBlock); + cbBlockDomain.setText(getString(R.string.title_block_sender_domain, domain)); + cbBlockDomain.setVisibility(domain == null ? View.GONE : View.VISIBLE); ibMore.setImageLevel(1); cbBlocklist.setChecked(check_blocklist && use_blocklist); tvBlocklist.setText(TextUtils.join(", ", DnsBlockList.getNamesEnabled(context))); diff --git a/app/src/main/res/layout/dialog_junk.xml b/app/src/main/res/layout/dialog_junk.xml index c36ea54d05..2d74fb7091 100644 --- a/app/src/main/res/layout/dialog_junk.xml +++ b/app/src/main/res/layout/dialog_junk.xml @@ -66,7 +66,7 @@ android:layout_height="wrap_content" android:layout_marginStart="12dp" android:layout_marginTop="12dp" - android:text="@string/title_block_domain" + android:text="@string/title_block_sender_domain" android:textAppearance="@style/TextAppearance.AppCompat.Small" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/cbBlockSender" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3c1469053a..463cb07705 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -92,7 +92,7 @@ Block %1$s Block sender - Block sender domain + Block domain \'%1$s\' Blocking a sender is a free feature. Blocking a sender domain uses filter rules, which is a pro feature.