From 850a120cd5aa1b3a7c024fb33ccefbce53f611c1 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 7 Jan 2022 18:48:59 +0100 Subject: [PATCH] Refactoring --- .../main/java/eu/faircode/email/FragmentDialogAsk.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogAsk.java b/app/src/main/java/eu/faircode/email/FragmentDialogAsk.java index 781480c482..3fb9070b32 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogAsk.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogAsk.java @@ -55,6 +55,8 @@ public class FragmentDialogAsk extends FragmentDialogBase { final Context context = getContext(); final int colorError = Helper.resolveColor(context, R.attr.colorError); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + View dview = LayoutInflater.from(context).inflate(R.layout.dialog_ask_again, null); TextView tvMessage = dview.findViewById(R.id.tvMessage); TextView tvRemark = dview.findViewById(R.id.tvRemark); @@ -85,10 +87,8 @@ public class FragmentDialogAsk extends FragmentDialogBase { cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if (accept == null) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + if (accept == null) prefs.edit().putBoolean(notagain, isChecked).apply(); - } tvAccept.setVisibility(isChecked && accept != null ? View.VISIBLE : View.GONE); } }); @@ -111,10 +111,8 @@ public class FragmentDialogAsk extends FragmentDialogBase { boolean confirmed = (confirm == null || cbConfirm.isChecked()); EntityLog.log(context, "Ask confirmed=" + confirmed); if (confirmed) { - if (notagain != null && accept != null) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + if (notagain != null && accept != null) prefs.edit().putBoolean(notagain, cbNotAgain.isChecked()).apply(); - } sendResult(Activity.RESULT_OK); } else sendResult(Activity.RESULT_CANCELED);