mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-25 07:01:50 -05:00
Remove reference to K9#hideTimeZone() + test
This commit is contained in:
parent
946565347a
commit
44f6a2479b
@ -1336,7 +1336,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
*/
|
*/
|
||||||
private MimeMessage createMessage(boolean isDraft) throws MessagingException {
|
private MimeMessage createMessage(boolean isDraft) throws MessagingException {
|
||||||
MimeMessage message = new MimeMessage();
|
MimeMessage message = new MimeMessage();
|
||||||
message.addSentDate(new Date());
|
message.addSentDate(new Date(), K9.hideTimeZone());
|
||||||
Address from = new Address(mIdentity.getEmail(), mIdentity.getName());
|
Address from = new Address(mIdentity.getEmail(), mIdentity.getName());
|
||||||
message.setFrom(from);
|
message.setFrom(from);
|
||||||
message.setRecipients(RecipientType.TO, getAddresses(mToView));
|
message.setRecipients(RecipientType.TO, getAddresses(mToView));
|
||||||
|
@ -2723,7 +2723,7 @@ public class MessagingController implements Runnable {
|
|||||||
long nowTime = System.currentTimeMillis();
|
long nowTime = System.currentTimeMillis();
|
||||||
Date nowDate = new Date(nowTime);
|
Date nowDate = new Date(nowTime);
|
||||||
message.setInternalDate(nowDate);
|
message.setInternalDate(nowDate);
|
||||||
message.addSentDate(nowDate);
|
message.addSentDate(nowDate, K9.hideTimeZone());
|
||||||
message.setFrom(new Address(account.getEmail(), "K9mail internal"));
|
message.setFrom(new Address(account.getEmail(), "K9mail internal"));
|
||||||
|
|
||||||
localFolder.appendMessages(Collections.singletonList(message));
|
localFolder.appendMessages(Collections.singletonList(message));
|
||||||
|
@ -87,7 +87,7 @@ public abstract class Message implements Part, CompositeBody {
|
|||||||
|
|
||||||
public abstract Date getSentDate();
|
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;
|
public abstract Address[] getRecipients(RecipientType type) throws MessagingException;
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ import com.fsck.k9.mail.Message;
|
|||||||
import com.fsck.k9.mail.MessagingException;
|
import com.fsck.k9.mail.MessagingException;
|
||||||
import com.fsck.k9.mail.Multipart;
|
import com.fsck.k9.mail.Multipart;
|
||||||
import com.fsck.k9.mail.Part;
|
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
|
* 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
|
* @param sentDate
|
||||||
* @throws com.fsck.k9.mail.MessagingException
|
* @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) {
|
if (mDateFormat == null) {
|
||||||
mDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
|
mDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (K9.hideTimeZone()) {
|
if (hideTimeZone) {
|
||||||
mDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
mDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,9 +150,9 @@ public class MimeMessage extends Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSentDate(Date sentDate) throws MessagingException {
|
public void setSentDate(Date sentDate, boolean hideTimeZone) throws MessagingException {
|
||||||
removeHeader("Date");
|
removeHeader("Date");
|
||||||
addSentDate(sentDate);
|
addSentDate(sentDate, hideTimeZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInternalSentDate(Date sentDate) {
|
public void setInternalSentDate(Date sentDate) {
|
||||||
|
@ -157,7 +157,7 @@ public class LocalMessage extends MimeMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
super.setReplyTo(mReplyTo);
|
super.setReplyTo(mReplyTo);
|
||||||
super.setSentDate(this.getSentDate());
|
super.setSentDate(this.getSentDate(), K9.hideTimeZone());
|
||||||
super.setRecipients(RecipientType.TO, mTo);
|
super.setRecipients(RecipientType.TO, mTo);
|
||||||
super.setRecipients(RecipientType.CC, mCc);
|
super.setRecipients(RecipientType.CC, mCc);
|
||||||
super.setRecipients(RecipientType.BCC, mBcc);
|
super.setRecipients(RecipientType.BCC, mBcc);
|
||||||
|
@ -5,6 +5,9 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.james.mime4j.codec.Base64InputStream;
|
import org.apache.james.mime4j.codec.Base64InputStream;
|
||||||
import org.apache.james.mime4j.util.MimeUtil;
|
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;
|
import com.fsck.k9.mail.internet.TextBody;
|
||||||
|
|
||||||
public class MessageTest extends AndroidTestCase {
|
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 =
|
private static final String EIGHT_BIT_RESULT =
|
||||||
"From: from@example.com\r\n"
|
"From: from@example.com\r\n"
|
||||||
@ -263,6 +271,28 @@ public class MessageTest extends AndroidTestCase {
|
|||||||
super();
|
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 {
|
public void testMessage() throws MessagingException, IOException {
|
||||||
MimeMessage message;
|
MimeMessage message;
|
||||||
ByteArrayOutputStream out;
|
ByteArrayOutputStream out;
|
||||||
@ -374,7 +404,5 @@ public class MessageTest extends AndroidTestCase {
|
|||||||
sb.append(Integer.toString(mMimeBoundary++));
|
sb.append(Integer.toString(mMimeBoundary++));
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ public class LocalMessageExtractorTest extends AndroidTestCase {
|
|||||||
|
|
||||||
// Create message/rfc822 body
|
// Create message/rfc822 body
|
||||||
MimeMessage innerMessage = new MimeMessage();
|
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.setRecipients(RecipientType.TO, new Address[] { new Address("to@example.com") });
|
||||||
innerMessage.setSubject("Subject");
|
innerMessage.setSubject("Subject");
|
||||||
innerMessage.setFrom(new Address("from@example.com"));
|
innerMessage.setFrom(new Address("from@example.com"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user