mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 17:18:50 -05:00
Add support for delete confirmation in message list
Fixes issue 6260
This commit is contained in:
parent
95f33c38fe
commit
082e13df26
@ -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_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_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_delete_starred">Delete Starred (in message view)</string>
|
||||||
<string name="global_settings_confirm_action_spam">Spam</string>
|
<string name="global_settings_confirm_action_spam">Spam</string>
|
||||||
<string name="global_settings_confirm_action_delete_notif">Delete (from notification)</string>
|
<string name="global_settings_confirm_action_delete_notif">Delete (from notification)</string>
|
||||||
|
@ -85,7 +85,6 @@ import com.fsck.k9.helper.Utility;
|
|||||||
import com.fsck.k9.mail.Address;
|
import com.fsck.k9.mail.Address;
|
||||||
import com.fsck.k9.mail.Flag;
|
import com.fsck.k9.mail.Flag;
|
||||||
import com.fsck.k9.mail.Folder;
|
import com.fsck.k9.mail.Folder;
|
||||||
|
|
||||||
import com.fsck.k9.mail.Message;
|
import com.fsck.k9.mail.Message;
|
||||||
import com.fsck.k9.mail.MessagingException;
|
import com.fsck.k9.mail.MessagingException;
|
||||||
import com.fsck.k9.mail.store.LocalStore;
|
import com.fsck.k9.mail.store.LocalStore;
|
||||||
@ -1313,6 +1312,16 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onDelete(List<Message> messages) {
|
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) {
|
if (mThreadedList) {
|
||||||
mController.deleteThreads(messages);
|
mController.deleteThreads(messages);
|
||||||
} else {
|
} else {
|
||||||
@ -1388,6 +1397,21 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
confirmText, cancelText);
|
confirmText, cancelText);
|
||||||
break;
|
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: {
|
default: {
|
||||||
throw new RuntimeException("Called showDialog(int) with unknown dialog id.");
|
throw new RuntimeException("Called showDialog(int) with unknown dialog id.");
|
||||||
}
|
}
|
||||||
@ -2902,13 +2926,19 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
mActiveMessages = null;
|
mActiveMessages = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case R.id.dialog_confirm_delete: {
|
||||||
|
onDeleteConfirmed(mActiveMessages);
|
||||||
|
mActiveMessage = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doNegativeClick(int dialogId) {
|
public void doNegativeClick(int dialogId) {
|
||||||
switch (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
|
// No further need for this reference
|
||||||
mActiveMessages = null;
|
mActiveMessages = null;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user