1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-02-11 20:50:19 -05:00

Add a confirmation dialog for the empty trash action, as this is fairly destructive.

This commit is contained in:
Kris Wong 2012-01-22 16:54:51 -05:00
parent 0d368c916a
commit 8bc656fe89
2 changed files with 49 additions and 48 deletions

View File

@ -95,8 +95,11 @@
<string name="send_alternate_chooser_title">Choose sender</string>
<string name="mark_all_as_read_dlg_title">Mark all messages as read</string>
<string name="mark_all_as_read_dlg_instructions_fmt">Mark all messages in \'<xliff:g id="folder">%s</xliff:g>\' as read? (including
messages in the folder that are not displayed in K-9)</string>
<string name="mark_all_as_read_dlg_instructions_fmt">Mark all messages in \'<xliff:g id="folder">%s</xliff:g>\' as read (including
messages in the folder that are not displayed in K-9)?</string>
<string name="empty_trash_dlg_title">Empty trash</string>
<string name="empty_trash_dlg_instructions">Caution: this will delete all messages in the trash folder on the server, including messages that are not displayed in K-9.</string>
<string name="flag_action">Add star</string>
<string name="unflag_action">Remove star</string>

View File

@ -52,6 +52,7 @@ import java.util.List;
public class FolderList extends K9ListActivity {
private static final int DIALOG_MARK_ALL_AS_READ = 1;
private static final int DIALOG_EMPTY_TRASH = 2;
private static final String EXTRA_ACCOUNT = "account";
@ -413,11 +414,8 @@ public class FolderList extends K9ListActivity {
onRefresh(false);
}
private void onRefresh(final boolean forceRemote) {
MessagingController.getInstance(getApplication()).listFolders(mAccount, forceRemote, mAdapter.mListener);
}
/**
@ -481,17 +479,19 @@ public class FolderList extends K9ListActivity {
finish();
}
private void onEmptyTrash(final Account account) {
mHandler.dataChanged();
private void onEmptyTrash() {
showDialog(DIALOG_EMPTY_TRASH);
}
MessagingController.getInstance(getApplication()).emptyTrash(account, null);
private void emptyTrash() {
mHandler.dataChanged();
MessagingController.getInstance(getApplication()).emptyTrash(mAccount, null);
}
private void onExpunge(final Account account, String folderName) {
MessagingController.getInstance(getApplication()).expunge(account, folderName, null);
}
private void onClearFolder(Account account, String folderName) {
// There has to be a cheaper way to get at the localFolder object than this
LocalFolder localFolder = null;
@ -514,10 +514,6 @@ public class FolderList extends K9ListActivity {
onRefresh(!REFRESH_REMOTE);
}
private void sendMail(Account account) {
MessagingController.getInstance(getApplication()).sendPendingMessages(account, mAdapter.mListener);
}
@ -526,50 +522,42 @@ public class FolderList extends K9ListActivity {
switch (item.getItemId()) {
case R.id.compose:
MessageCompose.actionCompose(this, mAccount);
return true;
case R.id.check_mail:
MessagingController.getInstance(getApplication()).checkMail(this, mAccount, true, true, mAdapter.mListener);
return true;
case R.id.send_messages:
MessagingController.getInstance(getApplication()).sendPendingMessages(mAccount, null);
return true;
case R.id.accounts:
onAccounts();
return true;
case R.id.list_folders:
onRefresh(REFRESH_REMOTE);
return true;
case R.id.filter_folders:
onEnterFilter();
return true;
case R.id.account_settings:
onEditAccount();
return true;
case R.id.app_settings:
onEditPrefs();
return true;
case R.id.empty_trash:
onEmptyTrash(mAccount);
onEmptyTrash();
return true;
case R.id.compact:
onCompact(mAccount);
return true;
case R.id.display_1st_class: {
@ -621,31 +609,27 @@ public class FolderList extends K9ListActivity {
break;
case R.id.mark_all_as_read:
onMarkAllAsRead(mAccount, folder.name);
onMarkAllAsRead(folder.name);
break;
case R.id.send_messages:
sendMail(mAccount);
break;
case R.id.check_mail:
checkMail(folder);
break;
case R.id.folder_settings:
onEditFolder(mAccount, folder.name);
break;
case R.id.empty_trash:
onEmptyTrash(mAccount);
onEmptyTrash();
break;
case R.id.expunge:
onExpunge(mAccount, folder.name);
break;
case R.id.clear_local_folder:
@ -659,7 +643,7 @@ public class FolderList extends K9ListActivity {
private FolderInfoHolder mSelectedContextFolder = null;
private void onMarkAllAsRead(final Account account, final String folder) {
private void onMarkAllAsRead(final String folder) {
mSelectedContextFolder = mAdapter.getFolder(folder);
if (K9.confirmMarkAllAsRead()) {
showDialog(DIALOG_MARK_ALL_AS_READ);
@ -670,8 +654,7 @@ public class FolderList extends K9ListActivity {
private void markAllAsRead() {
try {
MessagingController.getInstance(getApplication())
.markAllMessagesRead(mAccount, mSelectedContextFolder.name);
MessagingController.getInstance(getApplication()).markAllMessagesRead(mAccount, mSelectedContextFolder.name);
mSelectedContextFolder.unreadMessageCount = 0;
mHandler.dataChanged();
} catch (Exception e) {
@ -683,7 +666,8 @@ public class FolderList extends K9ListActivity {
public Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_MARK_ALL_AS_READ:
return ConfirmationDialog.create(this, id,
return ConfirmationDialog.create(this,
id,
R.string.mark_all_as_read_dlg_title,
getString(R.string.mark_all_as_read_dlg_instructions_fmt,
mSelectedContextFolder.displayName),
@ -695,6 +679,19 @@ public class FolderList extends K9ListActivity {
markAllAsRead();
}
});
case DIALOG_EMPTY_TRASH:
return ConfirmationDialog.create(this,
id,
R.string.empty_trash_dlg_title,
R.string.empty_trash_dlg_instructions,
R.string.okay_action,
R.string.cancel_action,
new Runnable() {
@Override
public void run() {
emptyTrash();
}
});
}
return super.onCreateDialog(id);
@ -706,9 +703,10 @@ public class FolderList extends K9ListActivity {
case DIALOG_MARK_ALL_AS_READ:
((AlertDialog)dialog).setMessage(getString(R.string.mark_all_as_read_dlg_instructions_fmt,
mSelectedContextFolder.displayName));
break;
case DIALOG_EMPTY_TRASH:
((AlertDialog)dialog).setMessage(getString(R.string.empty_trash_dlg_instructions));
break;
default:
super.onPrepareDialog(id, dialog);
}