1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Remove reference to K9#hideTimeZone() + test

This commit is contained in:
Jan Berkel 2014-12-16 10:56:13 +01:00
parent 946565347a
commit 44f6a2479b
7 changed files with 39 additions and 12 deletions

View File

@ -1336,7 +1336,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
*/
private MimeMessage createMessage(boolean isDraft) throws MessagingException {
MimeMessage message = new MimeMessage();
message.addSentDate(new Date());
message.addSentDate(new Date(), K9.hideTimeZone());
Address from = new Address(mIdentity.getEmail(), mIdentity.getName());
message.setFrom(from);
message.setRecipients(RecipientType.TO, getAddresses(mToView));

View File

@ -2723,7 +2723,7 @@ public class MessagingController implements Runnable {
long nowTime = System.currentTimeMillis();
Date nowDate = new Date(nowTime);
message.setInternalDate(nowDate);
message.addSentDate(nowDate);
message.addSentDate(nowDate, K9.hideTimeZone());
message.setFrom(new Address(account.getEmail(), "K9mail internal"));
localFolder.appendMessages(Collections.singletonList(message));

View File

@ -87,7 +87,7 @@ public abstract class Message implements Part, CompositeBody {
public abstract Date getSentDate();
public abstract void setSentDate(Date sentDate) throws MessagingException;
public abstract void setSentDate(Date sentDate, boolean hideTimeZone) throws MessagingException;
public abstract Address[] getRecipients(RecipientType type) throws MessagingException;

View File

@ -33,7 +33,6 @@ import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Multipart;
import com.fsck.k9.mail.Part;
import com.fsck.k9.K9;
/**
* An implementation of Message that stores all of it's metadata in RFC 822 and
@ -137,12 +136,12 @@ public class MimeMessage extends Message {
* @param sentDate
* @throws com.fsck.k9.mail.MessagingException
*/
public void addSentDate(Date sentDate) throws MessagingException {
public void addSentDate(Date sentDate, boolean hideTimeZone) throws MessagingException {
if (mDateFormat == null) {
mDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
}
if (K9.hideTimeZone()) {
if (hideTimeZone) {
mDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
}
@ -151,9 +150,9 @@ public class MimeMessage extends Message {
}
@Override
public void setSentDate(Date sentDate) throws MessagingException {
public void setSentDate(Date sentDate, boolean hideTimeZone) throws MessagingException {
removeHeader("Date");
addSentDate(sentDate);
addSentDate(sentDate, hideTimeZone);
}
public void setInternalSentDate(Date sentDate) {

View File

@ -157,7 +157,7 @@ public class LocalMessage extends MimeMessage {
}
super.setReplyTo(mReplyTo);
super.setSentDate(this.getSentDate());
super.setSentDate(this.getSentDate(), K9.hideTimeZone());
super.setRecipients(RecipientType.TO, mTo);
super.setRecipients(RecipientType.CC, mCc);
super.setRecipients(RecipientType.BCC, mBcc);

View File

@ -5,6 +5,9 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.TimeZone;
import org.apache.commons.io.IOUtils;
import org.apache.james.mime4j.codec.Base64InputStream;
import org.apache.james.mime4j.util.MimeUtil;
@ -22,6 +25,11 @@ import com.fsck.k9.mail.internet.MimeMultipart;
import com.fsck.k9.mail.internet.TextBody;
public class MessageTest extends AndroidTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Tokyo"));
}
private static final String EIGHT_BIT_RESULT =
"From: from@example.com\r\n"
@ -263,6 +271,28 @@ public class MessageTest extends AndroidTestCase {
super();
}
public void testSetSendDateSetsSentDate() throws Exception {
Message message = sampleMessage();
final int milliseconds = 0;
Date date = new Date(milliseconds);
message.setSentDate(date, false);
Date sentDate = message.getSentDate();
assertNotNull(sentDate);
assertEquals(milliseconds, sentDate.getTime());
}
public void testSetSendDateFormatsHeaderCorrectlyWithCurrentTimeZone() throws Exception {
Message message = sampleMessage();
message.setSentDate(new Date(0), false);
assertEquals("Thu, 01 Jan 1970 09:00:00 +0900", message.getHeader("Date")[0]);
}
public void testSetSendDateFormatsHeaderCorrectlyWithoutTimeZone() throws Exception {
Message message = sampleMessage();
message.setSentDate(new Date(0), true);
assertEquals("Thu, 01 Jan 1970 00:00:00 +0000", message.getHeader("Date")[0]);
}
public void testMessage() throws MessagingException, IOException {
MimeMessage message;
ByteArrayOutputStream out;
@ -374,7 +404,5 @@ public class MessageTest extends AndroidTestCase {
sb.append(Integer.toString(mMimeBoundary++));
return sb.toString();
}
}
}

View File

@ -120,7 +120,7 @@ public class LocalMessageExtractorTest extends AndroidTestCase {
// Create message/rfc822 body
MimeMessage innerMessage = new MimeMessage();
innerMessage.addSentDate(new Date(112, 02, 17));
innerMessage.addSentDate(new Date(112, 02, 17), false);
innerMessage.setRecipients(RecipientType.TO, new Address[] { new Address("to@example.com") });
innerMessage.setSubject("Subject");
innerMessage.setFrom(new Address("from@example.com"));