Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58371be6 authored by cketti's avatar cketti
Browse files

Properly support different themes for message viewing and composing

Previously the quoted HTML in the compose screen was formatted using
the message view theme.
parent 0b097d2a
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -322,10 +322,6 @@ object K9 : KoinComponent {
    @JvmStatic
    var pgpSignOnlyDialogCounter: Int = 0

    @JvmStatic
    val k9MessageViewTheme: Theme
        get() = if (k9MessageViewThemeSetting == Theme.USE_GLOBAL) k9Theme else k9MessageViewThemeSetting

    val isQuietTime: Boolean
        get() {
            if (!isQuietTimeEnabled) {
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ import org.koin.dsl.module.applicationContext

val mailStoreModule = applicationContext {
    bean { FolderRepositoryManager(get(), get()) }
    bean { MessageViewInfoExtractor(get(), get(), get()) }
    bean { MessageViewInfoExtractorFactory(get(), get(), get()) }
    bean { StorageManager.getInstance(get()) }
    bean { SearchStatusManager() }
    bean { SpecialFolderSelectionStrategy() }
+17 −0
Original line number Diff line number Diff line
package com.fsck.k9.mailstore

import com.fsck.k9.CoreResourceProvider
import com.fsck.k9.message.extractors.AttachmentInfoExtractor
import com.fsck.k9.message.html.HtmlProcessorFactory
import com.fsck.k9.message.html.HtmlSettings

class MessageViewInfoExtractorFactory(
        private val attachmentInfoExtractor: AttachmentInfoExtractor,
        private val htmlProcessorFactory: HtmlProcessorFactory,
        private val resourceProvider: CoreResourceProvider
) {
    fun create(settings: HtmlSettings): MessageViewInfoExtractor {
        val htmlProcessor = htmlProcessorFactory.create(settings)
        return MessageViewInfoExtractor(attachmentInfoExtractor, htmlProcessor, resourceProvider)
    }
}
+2 −11
Original line number Diff line number Diff line
package com.fsck.k9.message.html

import com.fsck.k9.K9

class DisplayHtmlFactory {
    fun create(): DisplayHtml {
        return DisplayHtml(createHtmlSettings())
    }

    private fun createHtmlSettings(): HtmlSettings {
        return HtmlSettings(
                useDarkMode = K9.k9MessageViewTheme == K9.Theme.DARK,
                useFixedWidthFont = K9.isUseMessageViewFixedWidthFont
        )
    fun create(settings: HtmlSettings): DisplayHtml {
        return DisplayHtml(settings)
    }
}
+3 −5
Original line number Diff line number Diff line
@@ -6,12 +6,12 @@ import org.jsoup.nodes.Document;

public class HtmlProcessor {
    private final HtmlSanitizer htmlSanitizer;
    private final DisplayHtmlFactory displayHtmlFactory;
    private final DisplayHtml displayHtml;


    HtmlProcessor(HtmlSanitizer htmlSanitizer, DisplayHtmlFactory displayHtmlFactory) {
    HtmlProcessor(HtmlSanitizer htmlSanitizer, DisplayHtml displayHtml) {
        this.htmlSanitizer = htmlSanitizer;
        this.displayHtmlFactory = displayHtmlFactory;
        this.displayHtml = displayHtml;
    }

    public String processForDisplay(String html) {
@@ -22,8 +22,6 @@ public class HtmlProcessor {
    }

    private void addCustomHeadContents(Document document) {
        DisplayHtml displayHtml = displayHtmlFactory.create();

        document.head().append("<meta name=\"viewport\" content=\"width=device-width\"/>" +
                displayHtml.cssStyleTheme() +
                displayHtml.cssStylePre());
Loading