1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 09:08:49 -05:00

Add support for delete confirmation in message list

Fixes issue 6260
This commit is contained in:
cketti 2014-05-18 02:05:52 +02:00
parent 95f33c38fe
commit 082e13df26
2 changed files with 33 additions and 3 deletions

View File

@ -326,7 +326,7 @@ Please submit bug reports, contribute new features and ask questions at
<string name="global_settings_confirm_actions_title">Confirm actions</string>
<string name="global_settings_confirm_actions_summary">Show a dialog whenever you perform selected actions</string>
<string name="global_settings_confirm_action_delete">Delete (in message view)</string>
<string name="global_settings_confirm_action_delete">Delete</string>
<string name="global_settings_confirm_action_delete_starred">Delete Starred (in message view)</string>
<string name="global_settings_confirm_action_spam">Spam</string>
<string name="global_settings_confirm_action_delete_notif">Delete (from notification)</string>

View File

@ -85,7 +85,6 @@ import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.store.LocalStore;
@ -1313,6 +1312,16 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
}
private void onDelete(List<Message> messages) {
if (K9.confirmDelete()) {
// remember the message selection for #onCreateDialog(int)
mActiveMessages = messages;
showDialog(R.id.dialog_confirm_delete);
} else {
onDeleteConfirmed(messages);
}
}
private void onDeleteConfirmed(List<Message> messages) {
if (mThreadedList) {
mController.deleteThreads(messages);
} else {
@ -1388,6 +1397,21 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
confirmText, cancelText);
break;
}
case R.id.dialog_confirm_delete: {
String title = getString(R.string.dialog_confirm_delete_title);
int selectionSize = mActiveMessages.size();
String message = getResources().getQuantityString(
R.plurals.dialog_confirm_delete_messages, selectionSize,
Integer.valueOf(selectionSize));
String confirmText = getString(R.string.dialog_confirm_delete_confirm_button);
String cancelText = getString(R.string.dialog_confirm_delete_cancel_button);
fragment = ConfirmationDialogFragment.newInstance(dialogId, title, message,
confirmText, cancelText);
break;
}
default: {
throw new RuntimeException("Called showDialog(int) with unknown dialog id.");
}
@ -2902,13 +2926,19 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
mActiveMessages = null;
break;
}
case R.id.dialog_confirm_delete: {
onDeleteConfirmed(mActiveMessages);
mActiveMessage = null;
break;
}
}
}
@Override
public void doNegativeClick(int dialogId) {
switch (dialogId) {
case R.id.dialog_confirm_spam: {
case R.id.dialog_confirm_spam:
case R.id.dialog_confirm_delete: {
// No further need for this reference
mActiveMessages = null;
break;