From 3eaedb27a7d7385e8e37bce25b48053d7edd3751 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 10 Nov 2018 08:15:28 +0000 Subject: [PATCH] Ask before deleting answer --- .../eu/faircode/email/FragmentAnswer.java | 50 +++++++++++-------- app/src/main/res/values/strings.xml | 1 + 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentAnswer.java b/app/src/main/java/eu/faircode/email/FragmentAnswer.java index e3413a6ab6..977c66a90a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAnswer.java +++ b/app/src/main/java/eu/faircode/email/FragmentAnswer.java @@ -20,6 +20,7 @@ package eu.faircode.email; */ import android.content.Context; +import android.content.DialogInterface; import android.os.Bundle; import android.text.Html; import android.view.LayoutInflater; @@ -108,30 +109,39 @@ public class FragmentAnswer extends FragmentEx { } private void onActionTrash() { - Helper.setViewsEnabled(view, false); + new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner()) + .setMessage(R.string.title_ask_delete_answer) + .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Helper.setViewsEnabled(view, false); - Bundle args = new Bundle(); - args.putLong("id", id); + Bundle args = new Bundle(); + args.putLong("id", id); - new SimpleTask() { - @Override - protected Void onLoad(Context context, Bundle args) { - long id = args.getLong("id"); - DB.getInstance(context).answer().deleteAnswer(id); - return null; - } + new SimpleTask() { + @Override + protected Void onLoad(Context context, Bundle args) { + long id = args.getLong("id"); + DB.getInstance(context).answer().deleteAnswer(id); + return null; + } - @Override - protected void onLoaded(Bundle args, Void data) { - finish(); - } + @Override + protected void onLoaded(Bundle args, Void data) { + finish(); + } - @Override - protected void onException(Bundle args, Throwable ex) { - Helper.setViewsEnabled(view, true); - Helper.unexpectedError(getContext(), ex); - } - }.load(this, args); + @Override + protected void onException(Bundle args, Throwable ex) { + Helper.setViewsEnabled(view, true); + Helper.unexpectedError(getContext(), ex); + } + }.load(FragmentAnswer.this, args); + } + }) + .setNegativeButton(android.R.string.cancel, null) + .show(); } private void onActionSave() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6332df6bd0..465d3c7433 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -218,6 +218,7 @@ Some attachments are not downloaded and will not be forwarded, continue? Delete message permanently? Delete selected messages permanently? + Delete reply template permanently? Discard draft? Report message as spam? Fix