From 9006f0ffe955b55552d7893f16d9f1d02f2262d5 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 10 Feb 2019 19:47:46 +0000 Subject: [PATCH] Refactoring --- .../main/java/eu/faircode/email/MessageHelper.java | 14 ++++++++++++++ .../java/eu/faircode/email/ServiceSynchronize.java | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 3d564ed66e..f6fca39c9e 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -23,6 +23,8 @@ import android.content.Context; import android.text.TextUtils; import android.webkit.MimeTypeMap; +import com.sun.mail.imap.IMAPMessage; + import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; @@ -530,6 +532,18 @@ public class MessageHelper { return (size < 0 ? null : size); } + long getReceived() throws MessagingException { + if (imessage instanceof IMAPMessage) + return imessage.getReceivedDate().getTime(); + else + return new Date().getTime(); + } + + Long getSent() throws MessagingException { + Date date = imessage.getSentDate(); + return (date == null ? null : date.getTime()); + } + String getHeaders() throws MessagingException { StringBuilder sb = new StringBuilder(); Enumeration
headers = imessage.getAllHeaders(); diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index af6c5ad755..f6a01bf6f7 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -2406,8 +2406,8 @@ public class ServiceSynchronize extends LifecycleService { message.subject = helper.getSubject(); message.size = helper.getSize(); message.content = false; - message.received = new Date().getTime(); // TODO - message.sent = (imessage.getSentDate() == null ? null : imessage.getSentDate().getTime()); + message.received = helper.getReceived(); + message.sent = helper.getSent(); message.seen = false; message.answered = false; message.flagged = false; @@ -2824,8 +2824,8 @@ public class ServiceSynchronize extends LifecycleService { message.subject = helper.getSubject(); message.size = helper.getSize(); message.content = false; - message.received = imessage.getReceivedDate().getTime(); - message.sent = (imessage.getSentDate() == null ? null : imessage.getSentDate().getTime()); + message.received = helper.getReceived(); + message.sent = helper.getSent(); message.seen = seen; message.answered = answered; message.flagged = flagged;