From cb727e6c0f737069d85aa1cb27f207f1fa813fbd Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 23 Mar 2022 09:38:40 +0100 Subject: [PATCH] Added button to manage blocked senders --- .../java/eu/faircode/email/ActivitySetup.java | 8 +++++++- .../java/eu/faircode/email/FragmentContacts.java | 4 ++-- .../eu/faircode/email/FragmentOptionsSend.java | 11 +++++++++++ app/src/main/res/layout/fragment_options_send.xml | 15 ++++++++++++++- app/src/main/res/values/strings.xml | 1 + 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java index 12b298efe3..851ec26c22 100644 --- a/app/src/main/java/eu/faircode/email/ActivitySetup.java +++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java @@ -1645,8 +1645,14 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac } private void onManageLocalContacts(Intent intent) { + Bundle args = new Bundle(); + args.putBoolean("junk", intent.getBooleanExtra("junk", false)); + + FragmentContacts fragment = new FragmentContacts(); + fragment.setArguments(args); + FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); - fragmentTransaction.replace(R.id.content_frame, new FragmentContacts()).addToBackStack("contacts"); + fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("contacts"); fragmentTransaction.commit(); } diff --git a/app/src/main/java/eu/faircode/email/FragmentContacts.java b/app/src/main/java/eu/faircode/email/FragmentContacts.java index e1684953dc..3c3a9e0abd 100644 --- a/app/src/main/java/eu/faircode/email/FragmentContacts.java +++ b/app/src/main/java/eu/faircode/email/FragmentContacts.java @@ -96,7 +96,7 @@ public class FragmentContacts extends FragmentBase { @Override @Nullable public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - setSubtitle(junk ? R.string.title_block_sender : R.string.menu_contacts); + setSubtitle(junk ? R.string.title_blocked_senders : R.string.menu_contacts); setHasOptionsMenu(true); View view = inflater.inflate(R.layout.fragment_contacts, container, false); @@ -236,7 +236,7 @@ public class FragmentContacts extends FragmentBase { private void onMenuJunk(boolean junk) { this.junk = junk; - setSubtitle(junk ? R.string.title_block_sender : R.string.menu_contacts); + setSubtitle(junk ? R.string.title_blocked_senders : R.string.menu_contacts); adapter.filter(junk ? Arrays.asList(EntityContact.TYPE_JUNK, EntityContact.TYPE_NO_JUNK) : new ArrayList<>()); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java index 9de45f38f2..601c81bb91 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java @@ -61,6 +61,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private SwitchCompat swSuggestReceived; private SwitchCompat swSuggestFrequently; private Button btnLocalContacts; + private Button btnBlockedSenders; private SwitchCompat swPrefixOnce; private SwitchCompat swPrefixCount; private RadioGroup rgRe; @@ -128,6 +129,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc swSuggestReceived = view.findViewById(R.id.swSuggestReceived); swSuggestFrequently = view.findViewById(R.id.swSuggestFrequently); btnLocalContacts = view.findViewById(R.id.btnLocalContacts); + btnBlockedSenders = view.findViewById(R.id.btnBlockedSenders); swPrefixOnce = view.findViewById(R.id.swPrefixOnce); swPrefixCount = view.findViewById(R.id.swPrefixCount); rgRe = view.findViewById(R.id.rgRe); @@ -239,6 +241,15 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc } }); + btnBlockedSenders.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); + lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_MANAGE_LOCAL_CONTACTS) + .putExtra("junk", true)); + } + }); + swPrefixOnce.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { diff --git a/app/src/main/res/layout/fragment_options_send.xml b/app/src/main/res/layout/fragment_options_send.xml index 844c03021c..a6905f9271 100644 --- a/app/src/main/res/layout/fragment_options_send.xml +++ b/app/src/main/res/layout/fragment_options_send.xml @@ -183,6 +183,19 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swSuggestFrequently" /> +