From fd165e5106f59f8bba1c15324d68da0c25682a52 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 6 Oct 2018 14:59:23 +0200 Subject: [PATCH] add confirmation dialog for deleting files fixes #3202, closes #3193, closes #3214 --- .../ui/ConversationFragment.java | 22 +++++++++++++------ src/main/res/values/strings.xml | 5 +++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 904ecf673..6b63ac0f2 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -1467,7 +1467,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke final CheckBox endConversationCheckBox = dialogView.findViewById(R.id.end_conversation_checkbox); builder.setView(dialogView); builder.setNegativeButton(getString(R.string.cancel), null); - builder.setPositiveButton(getString(R.string.delete_messages), (dialog, which) -> { + builder.setPositiveButton(getString(R.string.confirm), (dialog, which) -> { this.activity.xmppConnectionService.clearConversationHistory(conversation); if (endConversationCheckBox.isChecked()) { this.activity.xmppConnectionService.archiveConversation(conversation); @@ -1647,12 +1647,20 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } - private void deleteFile(Message message) { - if (activity.xmppConnectionService.getFileBackend().deleteFile(message)) { - message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED)); - activity.onConversationsListItemUpdated(); - refresh(); - } + private void deleteFile(final Message message) { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setNegativeButton(R.string.cancel, null); + builder.setTitle(R.string.delete_file_dialog); + builder.setMessage(R.string.delete_file_dialog_msg); + builder.setPositiveButton(R.string.confirm, (dialog, which) -> { + if (activity.xmppConnectionService.getFileBackend().deleteFile(message)) { + message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED)); + activity.onConversationsListItemUpdated(); + refresh(); + } + }); + builder.create().show(); + } private void resendMessage(final Message message) { diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index fdcbf0752..a72a5d3db 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -77,8 +77,9 @@ Sharing files. Please wait… Clear history Clear Conversation History - Do you want to delete all messages within this Conversation?\n\nWarning: This will not influence messages stored on other devices or servers. - Delete messages + Are you sure you want to delete all messages within this conversation?\n\nWarning: This will not delete copies of those messages that are stored on other devices or servers. + Delete file + Are you sure you want to delete this file?\n\nWarning: This will not delete copies of this file that are stored on other devices or servers. End this conversation afterwards Choose device Send unencrypted message