Search in sources :

Example 1 with CoreResourceProvider

use of com.fsck.k9.CoreResourceProvider in project k-9 by k9mail.

the class PgpMessageBuilder method newInstance.

public static PgpMessageBuilder newInstance() {
    MessageIdGenerator messageIdGenerator = MessageIdGenerator.getInstance();
    BoundaryGenerator boundaryGenerator = BoundaryGenerator.getInstance();
    AutocryptOperations autocryptOperations = AutocryptOperations.getInstance();
    AutocryptOpenPgpApiInteractor autocryptOpenPgpApiInteractor = AutocryptOpenPgpApiInteractor.getInstance();
    CoreResourceProvider resourceProvider = DI.get(CoreResourceProvider.class);
    return new PgpMessageBuilder(messageIdGenerator, boundaryGenerator, autocryptOperations, autocryptOpenPgpApiInteractor, resourceProvider);
}
Also used : CoreResourceProvider(com.fsck.k9.CoreResourceProvider) AutocryptOperations(com.fsck.k9.autocrypt.AutocryptOperations) AutocryptOpenPgpApiInteractor(com.fsck.k9.autocrypt.AutocryptOpenPgpApiInteractor) MessageIdGenerator(com.fsck.k9.mail.internet.MessageIdGenerator) BoundaryGenerator(com.fsck.k9.mail.BoundaryGenerator)

Example 2 with CoreResourceProvider

use of com.fsck.k9.CoreResourceProvider in project k-9 by k9mail.

the class SimpleMessageBuilder method newInstance.

public static SimpleMessageBuilder newInstance() {
    MessageIdGenerator messageIdGenerator = MessageIdGenerator.getInstance();
    BoundaryGenerator boundaryGenerator = BoundaryGenerator.getInstance();
    CoreResourceProvider resourceProvider = DI.get(CoreResourceProvider.class);
    return new SimpleMessageBuilder(messageIdGenerator, boundaryGenerator, resourceProvider);
}
Also used : CoreResourceProvider(com.fsck.k9.CoreResourceProvider) MessageIdGenerator(com.fsck.k9.mail.internet.MessageIdGenerator) BoundaryGenerator(com.fsck.k9.mail.BoundaryGenerator)

Example 3 with CoreResourceProvider

use of com.fsck.k9.CoreResourceProvider in project k-9 by k9mail.

the class MessageHelper method getInstance.

public static synchronized MessageHelper getInstance(final Context context) {
    if (sInstance == null) {
        CoreResourceProvider resourceProvider = DI.get(CoreResourceProvider.class);
        sInstance = new MessageHelper(context, resourceProvider);
    }
    return sInstance;
}
Also used : CoreResourceProvider(com.fsck.k9.CoreResourceProvider)

Example 4 with CoreResourceProvider

use of com.fsck.k9.CoreResourceProvider in project k-9 by k9mail.

the class HtmlQuoteCreator method quoteOriginalHtmlMessage.

/**
 * Add quoting markup to a HTML message.
 * @param originalMessage Metadata for message being quoted.
 * @param messageBody Text of the message to be quoted.
 * @param quoteStyle Style of quoting.
 * @return Modified insertable message.
 */
public static InsertableHtmlContent quoteOriginalHtmlMessage(Message originalMessage, String messageBody, QuoteStyle quoteStyle) {
    CoreResourceProvider resourceProvider = DI.get(CoreResourceProvider.class);
    InsertableHtmlContent insertable = findInsertionPoints(messageBody);
    String sentDate = new QuoteDateFormatter().format(originalMessage.getSentDate());
    String fromAddress = Address.toString(originalMessage.getFrom());
    if (quoteStyle == QuoteStyle.PREFIX) {
        StringBuilder header = new StringBuilder();
        header.append("<div class=\"gmail_quote\">");
        if (sentDate.length() != 0) {
            String replyHeader = resourceProvider.replyHeader(fromAddress, sentDate);
            header.append(HtmlConverter.textToHtmlFragment(replyHeader));
        } else {
            String replyHeader = resourceProvider.replyHeader(fromAddress);
            header.append(HtmlConverter.textToHtmlFragment(replyHeader));
        }
        header.append("<blockquote class=\"gmail_quote\" " + "style=\"margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;\">\r\n");
        String footer = "</blockquote></div>";
        insertable.insertIntoQuotedHeader(header.toString());
        insertable.insertIntoQuotedFooter(footer);
    } else if (quoteStyle == QuoteStyle.HEADER) {
        StringBuilder header = new StringBuilder();
        header.append("<div style='font-size:10.0pt;font-family:\"Tahoma\",\"sans-serif\";padding:3.0pt 0in 0in 0in'>\r\n");
        // This gets converted into a horizontal line during html to text conversion.
        header.append("<hr style='border:none;border-top:solid #E1E1E1 1.0pt'>\r\n");
        if (originalMessage.getFrom() != null && fromAddress.length() != 0) {
            header.append("<b>").append(resourceProvider.messageHeaderFrom()).append("</b> ").append(HtmlConverter.textToHtmlFragment(fromAddress)).append("<br>\r\n");
        }
        if (sentDate.length() != 0) {
            header.append("<b>").append(resourceProvider.messageHeaderDate()).append("</b> ").append(sentDate).append("<br>\r\n");
        }
        if (originalMessage.getRecipients(RecipientType.TO) != null && originalMessage.getRecipients(RecipientType.TO).length != 0) {
            header.append("<b>").append(resourceProvider.messageHeaderTo()).append("</b> ").append(HtmlConverter.textToHtmlFragment(Address.toString(originalMessage.getRecipients(RecipientType.TO)))).append("<br>\r\n");
        }
        if (originalMessage.getRecipients(RecipientType.CC) != null && originalMessage.getRecipients(RecipientType.CC).length != 0) {
            header.append("<b>").append(resourceProvider.messageHeaderCc()).append("</b> ").append(HtmlConverter.textToHtmlFragment(Address.toString(originalMessage.getRecipients(RecipientType.CC)))).append("<br>\r\n");
        }
        if (originalMessage.getSubject() != null) {
            header.append("<b>").append(resourceProvider.messageHeaderSubject()).append("</b> ").append(HtmlConverter.textToHtmlFragment(originalMessage.getSubject())).append("<br>\r\n");
        }
        header.append("</div>\r\n");
        header.append("<br>\r\n");
        insertable.insertIntoQuotedHeader(header.toString());
    }
    return insertable;
}
Also used : CoreResourceProvider(com.fsck.k9.CoreResourceProvider)

Aggregations

CoreResourceProvider (com.fsck.k9.CoreResourceProvider)4 BoundaryGenerator (com.fsck.k9.mail.BoundaryGenerator)2 MessageIdGenerator (com.fsck.k9.mail.internet.MessageIdGenerator)2 AutocryptOpenPgpApiInteractor (com.fsck.k9.autocrypt.AutocryptOpenPgpApiInteractor)1 AutocryptOperations (com.fsck.k9.autocrypt.AutocryptOperations)1