1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Issue 235

Added dialog box for confirmation for "Mark all messages as read"
This commit is contained in:
Daniel Applebaum 2009-04-06 01:37:35 +00:00
parent d39739f884
commit f307bfc1eb
2 changed files with 74 additions and 16 deletions

View File

@ -52,6 +52,9 @@
<string name="send_alternate_action">Forward (alternate)</string> <string name="send_alternate_action">Forward (alternate)</string>
<string name="send_alternate_chooser_title">Choose sender</string> <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?</string>
<string name="flag_action">Flag</string> <string name="flag_action">Flag</string>
<string name="unflag_action">Unflag</string> <string name="unflag_action">Unflag</string>
<string name="move_action">Move</string> <string name="move_action">Move</string>

View File

@ -12,9 +12,12 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ExpandableListActivity; import android.app.ExpandableListActivity;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -48,6 +51,7 @@ import com.android.email.MessagingListener;
import com.android.email.R; import com.android.email.R;
import com.android.email.Utility; import com.android.email.Utility;
import com.android.email.Preferences; import com.android.email.Preferences;
import com.android.email.activity.Accounts;
import com.android.email.activity.FolderMessageList.FolderMessageListAdapter.FolderInfoHolder; import com.android.email.activity.FolderMessageList.FolderMessageListAdapter.FolderInfoHolder;
import com.android.email.activity.FolderMessageList.FolderMessageListAdapter.MessageInfoHolder; import com.android.email.activity.FolderMessageList.FolderMessageListAdapter.MessageInfoHolder;
import com.android.email.activity.setup.AccountSettings; import com.android.email.activity.setup.AccountSettings;
@ -86,6 +90,7 @@ public class FolderMessageList extends ExpandableListActivity
{ {
private static final String INTENT_DATA_PATH_SUFFIX = "/accounts"; private static final String INTENT_DATA_PATH_SUFFIX = "/accounts";
private static final int DIALOG_MARK_ALL_AS_READ = 1;
private static final int ACTIVITY_CHOOSE_FOLDER_MOVE = 1; private static final int ACTIVITY_CHOOSE_FOLDER_MOVE = 1;
@ -1063,19 +1068,69 @@ public class FolderMessageList extends ExpandableListActivity
MessageCompose.actionForward(this, mAccount, holder.message); MessageCompose.actionForward(this, mAccount, holder.message);
} }
private void onMarkAllAsRead(Account account, FolderInfoHolder folder)
{
MessagingController.getInstance(getApplication()).markAllMessagesRead(mAccount,
folder.name);
for (MessageInfoHolder holder : folder.messages){ private Account mSelectedContextAccount = null;
holder.read = true; private FolderInfoHolder mSelectedContextFolder = null;
} private void onMarkAllAsRead(final Account account, final FolderInfoHolder folder)
folder.unreadMessageCount = 0; {
mHandler.dataChanged(); mSelectedContextAccount = account;
mSelectedContextFolder = folder;
showDialog(DIALOG_MARK_ALL_AS_READ);
}
//onRefresh(false); @Override
} public Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_MARK_ALL_AS_READ:
return createMarkAllAsReadDialog();
}
return super.onCreateDialog(id);
}
public void onPrepareDialog(int id, Dialog dialog)
{
switch (id) {
case DIALOG_MARK_ALL_AS_READ:
((AlertDialog)dialog).setMessage(getString(R.string.mark_all_as_read_dlg_instructions_fmt,
mSelectedContextFolder.displayName));
break;
default:
super.onPrepareDialog(id, dialog);
}
}
private Dialog createMarkAllAsReadDialog()
{
return new AlertDialog.Builder(this)
.setTitle(R.string.mark_all_as_read_dlg_title)
.setMessage(getString(R.string.mark_all_as_read_dlg_instructions_fmt,
mSelectedContextFolder.displayName))
.setPositiveButton(R.string.okay_action, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dismissDialog(DIALOG_MARK_ALL_AS_READ);
try {
MessagingController.getInstance(getApplication()).markAllMessagesRead(mSelectedContextAccount, mSelectedContextFolder.name);
for (MessageInfoHolder holder : mSelectedContextFolder.messages){
holder.read = true;
}
mSelectedContextFolder.unreadMessageCount = 0;
mHandler.dataChanged();
} catch (Exception e) {
// Ignore
}
}
})
.setNegativeButton(R.string.cancel_action, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dismissDialog(DIALOG_MARK_ALL_AS_READ);
}
})
.create();
}
private void onEmptyTrash(final Account account) private void onEmptyTrash(final Account account)
{ {