From 46ad2f4fa061d706c3a0aa053902143c7e2a52f3 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 1 Jan 2022 14:50:36 +0100 Subject: [PATCH] Default block sender for multiple selected messages --- .../main/java/eu/faircode/email/FragmentMessages.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 586ca6d2f4..9450cc93bd 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -9073,22 +9073,27 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. Bundle args = getArguments(); int count = args.getInt("count"); + final Context context = getContext(); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + + boolean block_sender = prefs.getBoolean("block_sender", true); String text = getResources().getQuantityString(R.plurals.title_ask_spam, count, count); - final Context context = getContext(); View dview = LayoutInflater.from(context).inflate(R.layout.dialog_ask_spam, null); TextView tvMessage = dview.findViewById(R.id.tvMessage); CheckBox cbBlockSender = dview.findViewById(R.id.cbBlockSender); tvMessage.setText(text); - cbBlockSender.setChecked(true); + cbBlockSender.setChecked(block_sender); return new AlertDialog.Builder(context) .setView(dview) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - getArguments().putBoolean("block", cbBlockSender.isChecked()); + boolean block = cbBlockSender.isChecked(); + prefs.edit().putBoolean("block_sender", block).apply(); + getArguments().putBoolean("block", block); sendResult(Activity.RESULT_OK); } })