add confirmation dialog for deleting files

fixes #3202, closes #3193, closes #3214
This commit is contained in:
Daniel Gultsch 2018-10-06 14:59:23 +02:00
parent 7aa8aba5c0
commit fd165e5106
2 changed files with 18 additions and 9 deletions

View file

@ -1467,7 +1467,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
final CheckBox endConversationCheckBox = dialogView.findViewById(R.id.end_conversation_checkbox); final CheckBox endConversationCheckBox = dialogView.findViewById(R.id.end_conversation_checkbox);
builder.setView(dialogView); builder.setView(dialogView);
builder.setNegativeButton(getString(R.string.cancel), null); 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); this.activity.xmppConnectionService.clearConversationHistory(conversation);
if (endConversationCheckBox.isChecked()) { if (endConversationCheckBox.isChecked()) {
this.activity.xmppConnectionService.archiveConversation(conversation); this.activity.xmppConnectionService.archiveConversation(conversation);
@ -1647,12 +1647,20 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
private void deleteFile(Message message) { 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)) { if (activity.xmppConnectionService.getFileBackend().deleteFile(message)) {
message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED)); message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
activity.onConversationsListItemUpdated(); activity.onConversationsListItemUpdated();
refresh(); refresh();
} }
});
builder.create().show();
} }
private void resendMessage(final Message message) { private void resendMessage(final Message message) {

View file

@ -77,8 +77,9 @@
<string name="sharing_files_please_wait">Sharing files. Please wait…</string> <string name="sharing_files_please_wait">Sharing files. Please wait…</string>
<string name="action_clear_history">Clear history</string> <string name="action_clear_history">Clear history</string>
<string name="clear_conversation_history">Clear Conversation History</string> <string name="clear_conversation_history">Clear Conversation History</string>
<string name="clear_histor_msg">Do you want to delete all messages within this Conversation?\n\n<b>Warning:</b> This will not influence messages stored on other devices or servers.</string> <string name="clear_histor_msg">Are you sure you want to delete all messages within this conversation?\n\n<b>Warning:</b> This will not delete copies of those messages that are stored on other devices or servers.</string>
<string name="delete_messages">Delete messages</string> <string name="delete_file_dialog">Delete file</string>
<string name="delete_file_dialog_msg">Are you sure you want to delete this file?\n\n<b>Warning:</b> This will not delete copies of this file that are stored on other devices or servers. </string>
<string name="also_end_conversation">End this conversation afterwards</string> <string name="also_end_conversation">End this conversation afterwards</string>
<string name="choose_presence">Choose device</string> <string name="choose_presence">Choose device</string>
<string name="send_unencrypted_message">Send unencrypted message</string> <string name="send_unencrypted_message">Send unencrypted message</string>