Ask before deleting answer

pull/146/head
M66B 7 years ago
parent 0963edffc4
commit 3eaedb27a7

@ -20,6 +20,7 @@ package eu.faircode.email;
*/ */
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.text.Html; import android.text.Html;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -108,30 +109,39 @@ public class FragmentAnswer extends FragmentEx {
} }
private void onActionTrash() { private void onActionTrash() {
Helper.setViewsEnabled(view, false); new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
.setMessage(R.string.title_ask_delete_answer)
Bundle args = new Bundle(); .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
args.putLong("id", id); @Override
public void onClick(DialogInterface dialog, int which) {
new SimpleTask<Void>() { Helper.setViewsEnabled(view, false);
@Override
protected Void onLoad(Context context, Bundle args) { Bundle args = new Bundle();
long id = args.getLong("id"); args.putLong("id", id);
DB.getInstance(context).answer().deleteAnswer(id);
return null; new SimpleTask<Void>() {
} @Override
protected Void onLoad(Context context, Bundle args) {
@Override long id = args.getLong("id");
protected void onLoaded(Bundle args, Void data) { DB.getInstance(context).answer().deleteAnswer(id);
finish(); return null;
} }
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onLoaded(Bundle args, Void data) {
Helper.setViewsEnabled(view, true); finish();
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() { private void onActionSave() {

@ -218,6 +218,7 @@
<string name="title_attachment_unavailable">Some attachments are not downloaded and will not be forwarded, continue?</string> <string name="title_attachment_unavailable">Some attachments are not downloaded and will not be forwarded, continue?</string>
<string name="title_ask_delete">Delete message permanently?</string> <string name="title_ask_delete">Delete message permanently?</string>
<string name="title_ask_delete_selected">Delete selected messages permanently?</string> <string name="title_ask_delete_selected">Delete selected messages permanently?</string>
<string name="title_ask_delete_answer">Delete reply template permanently?</string>
<string name="title_ask_discard">Discard draft?</string> <string name="title_ask_discard">Discard draft?</string>
<string name="title_ask_spam">Report message as spam?</string> <string name="title_ask_spam">Report message as spam?</string>
<string name="title_fix">Fix</string> <string name="title_fix">Fix</string>

Loading…
Cancel
Save