Fixed use of \Recent flag
This commit is contained in:
@@ -4,6 +4,9 @@ import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.mail.Flags.Flag;
|
||||
import javax.mail.MessagingException;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.util.Log;
|
||||
import i2p.bote.I2PBote;
|
||||
@@ -413,6 +416,14 @@ public class EmailListFragment extends ListFragment implements
|
||||
|
||||
public void onLoadFinished(Loader<List<Email>> loader,
|
||||
List<Email> data) {
|
||||
// Clear recent flags
|
||||
for (Email email : data)
|
||||
try {
|
||||
email.setFlag(Flag.RECENT, false);
|
||||
} catch (MessagingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
mAdapter.setData(data);
|
||||
try {
|
||||
getActivity().setTitle(
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.security.GeneralSecurityException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
|
||||
import i2p.bote.android.util.BetterAsyncTaskLoader;
|
||||
import i2p.bote.android.util.BoteHelper;
|
||||
import i2p.bote.email.Email;
|
||||
@@ -62,12 +64,16 @@ public class ViewEmailActivity extends ActionBarActivity implements
|
||||
if (mMessageId != null) {
|
||||
try {
|
||||
mFolder.setNew(mMessageId, false);
|
||||
mFolder.setRecent(mMessageId, false);
|
||||
} catch (PasswordException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (GeneralSecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (MessagingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,12 +195,16 @@ public class ViewEmailActivity extends ActionBarActivity implements
|
||||
if (mMessageId != null) {
|
||||
try {
|
||||
mFolder.setNew(mMessageId, false);
|
||||
mFolder.setRecent(mMessageId, false);
|
||||
} catch (PasswordException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (GeneralSecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (MessagingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.security.GeneralSecurityException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Flags.Flag;
|
||||
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.RouterContext;
|
||||
@@ -88,20 +89,20 @@ public class BoteService extends Service implements FolderListener {
|
||||
|
||||
@Override
|
||||
public void elementAdded(String messageId) {
|
||||
notifyUnread();
|
||||
notifyUnread(messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementUpdated() {
|
||||
notifyUnread();
|
||||
// Noop
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementRemoved(String messageId) {
|
||||
notifyUnread();
|
||||
// Noop
|
||||
}
|
||||
|
||||
private void notifyUnread() {
|
||||
private void notifyUnread(String newMessageId) {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(
|
||||
Context.NOTIFICATION_SERVICE);
|
||||
|
||||
@@ -112,6 +113,11 @@ public class BoteService extends Service implements FolderListener {
|
||||
|
||||
try {
|
||||
EmailFolder inbox = I2PBote.getInstance().getInbox();
|
||||
|
||||
// Set the new email as \Recent
|
||||
inbox.setRecent(newMessageId, true);
|
||||
|
||||
// Now display/update notification with all \Recent emails
|
||||
List<Email> newEmails = BoteHelper.getRecentEmails(inbox);
|
||||
int numNew = newEmails.size();
|
||||
switch (numNew) {
|
||||
|
||||
@@ -215,9 +215,7 @@ public class BoteHelper extends GeneralHelper {
|
||||
Iterator<Email> iter = emails.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Email email = iter.next();
|
||||
if (email.isSet(Flag.RECENT))
|
||||
email.setFlag(Flag.RECENT, false);
|
||||
else
|
||||
if (!email.isSet(Flag.RECENT))
|
||||
iter.remove();
|
||||
}
|
||||
return emails;
|
||||
|
||||
Reference in New Issue
Block a user