From 24d7416e61b8210e2110e9c998aa641c18aea6b0 Mon Sep 17 00:00:00 2001 From: Sander Bogaert Date: Fri, 20 Jul 2012 10:13:35 -0400 Subject: [PATCH] Implemented the (Un)start and (Un)read toggles. --- res/menu/message_list_context.xml | 8 +-- res/values/strings.xml | 2 + src/com/fsck/k9/activity/MessageList.java | 67 +++++++++++++++-------- 3 files changed, 51 insertions(+), 26 deletions(-) diff --git a/res/menu/message_list_context.xml b/res/menu/message_list_context.xml index 7e16dbbce..90f6829c8 100644 --- a/res/menu/message_list_context.xml +++ b/res/menu/message_list_context.xml @@ -6,8 +6,8 @@ android:showAsAction="always" /> Accounts Mark as read + (un)read Share Choose sender @@ -152,6 +153,7 @@ http://k9mail.googlecode.com/ messages in the folder that are not displayed in K-9) Add star + (Un)star Remove star Copy Show full header diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 564859477..6da82554c 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -1,6 +1,7 @@ package com.fsck.k9.activity; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.EnumMap; @@ -1395,24 +1396,46 @@ public class MessageList extends K9ListActivity implements } } - private void onToggleRead(MessageInfoHolder holder) { - LocalMessage message = holder.message; - Folder folder = message.getFolder(); - Account account = folder.getAccount(); - String folderName = folder.getName(); - mController.setFlag(account, folderName, new Message[] { message }, Flag.SEEN, !holder.read); - holder.read = !holder.read; - mAdapter.sortMessages(); + private void onToggleRead(final List holders) { + LocalMessage message; + Folder folder; + Account account; + String folderName; + + int i = 0; + for (final Iterator iterator = holders.iterator(); iterator.hasNext(); i++) { + final MessageInfoHolder h = iterator.next(); + message = h.message; + folder = message.getFolder(); + account = folder.getAccount(); + folderName = message.getFolder().getName(); + + mController.setFlag(account, folderName, new Message[]{message}, Flag.SEEN, !h.read); + + h.read = !h.read; + mAdapter.sortMessages(); + } } - private void onToggleFlag(MessageInfoHolder holder) { - LocalMessage message = holder.message; - Folder folder = message.getFolder(); - Account account = folder.getAccount(); - String folderName = folder.getName(); - mController.setFlag(account, folderName, new Message[] { message }, Flag.FLAGGED, !holder.flagged); - holder.flagged = !holder.flagged; - mAdapter.sortMessages(); + private void onToggleFlag(final List holders) { + LocalMessage message; + Folder folder; + Account account; + String folderName; + + int i = 0; + for (final Iterator iterator = holders.iterator(); iterator.hasNext(); i++) { + final MessageInfoHolder h = iterator.next(); + message = h.message; + folder = message.getFolder(); + account = folder.getAccount(); + folderName = message.getFolder().getName(); + + mController.setFlag(account, folderName, new Message[]{message}, Flag.FLAGGED, !h.flagged); + + h.flagged = !h.flagged; + mAdapter.sortMessages(); + } } private void checkMail(Account account, String folderName) { @@ -1960,7 +1983,7 @@ public class MessageList extends K9ListActivity implements public void onClick(View v) { // Perform action on clicks MessageInfoHolder message = (MessageInfoHolder) getItem((Integer)v.getTag()); - onToggleFlag(message); + onToggleFlag(Arrays.asList(new MessageInfoHolder[]{message})); } }; @@ -2695,14 +2718,14 @@ public class MessageList extends K9ListActivity implements mSelectedCount = 0; break; } - /*case R.id.mark_as_read: { - onToggleRead(holder); + case R.id.read_toggle: { + onToggleRead(selection); break; } - case R.id.flag: { - onToggleFlag(holder); + case R.id.flag_toggle: { + onToggleFlag(selection); break; - }*/ + } case R.id.archive: { onArchive(selection); mSelectedCount = 0;