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

Commit 1d869bd4 authored by João Henrique's avatar João Henrique
Browse files

feat: Annotate HTML strings in DisplayHtml.kt

This commit adds `@Language("HTML")` annotations to string literals and variables containing HTML code in the `DisplayHtml.kt` file. This helps IDEs provide better syntax highlighting and code analysis for these HTML snippets.
parent 1dc76926
Loading
Loading
Loading
Loading
+11 −2
Original line number Original line Diff line number Diff line
package com.fsck.k9.message.html
package com.fsck.k9.message.html


import app.k9mail.html.cleaner.HtmlHeadProvider
import app.k9mail.html.cleaner.HtmlHeadProvider
import org.intellij.lang.annotations.Language


class DisplayHtml(private val settings: HtmlSettings) : HtmlHeadProvider {
class DisplayHtml(private val settings: HtmlSettings) : HtmlHeadProvider {
    override val headHtml: String
    override val headHtml: String
        get() {
        get() {
            return """
            @Language("HTML")
            val html = """
                <meta name="viewport" content="width=device-width"/>
                <meta name="viewport" content="width=device-width"/>
                ${cssStyleGlobal()}
                ${cssStyleGlobal()}
                ${cssStylePre()}
                ${cssStylePre()}
                ${cssStyleSignature()}
                ${cssStyleSignature()}
            """.trimIndent()
            """.trimIndent()

            return html
        }
        }


    fun wrapStatusMessage(status: CharSequence): String {
    fun wrapStatusMessage(status: CharSequence): String {
        @Language("HTML")
        val html = """
        val html = """
            <div style=\"text-align:center; color: grey;\">$status</div>
            <div style="text-align:center; color: grey;">$status</div>
        """.trimIndent()
        """.trimIndent()


        return wrapMessageContent(html)
        return wrapMessageContent(html)
    }
    }


    @Language("HTML")
    fun wrapMessageContent(messageContent: CharSequence): String {
    fun wrapMessageContent(messageContent: CharSequence): String {
        // Include a meta tag so the WebView will not use a fixed viewport width of 980 px
        // Include a meta tag so the WebView will not use a fixed viewport width of 980 px
        return """
        return """
@@ -44,6 +50,7 @@ class DisplayHtml(private val settings: HtmlSettings) : HtmlHeadProvider {
     * @return A `<style>` element string that can be dynamically injected into the HTML `<head>`
     * @return A `<style>` element string that can be dynamically injected into the HTML `<head>`
     * to apply these global styles when rendering messages.
     * to apply these global styles when rendering messages.
     */
     */
    @Language("HTML")
    private fun cssStyleGlobal(): String {
    private fun cssStyleGlobal(): String {
        return """
        return """
            <style type="text/css">
            <style type="text/css">
@@ -63,6 +70,7 @@ class DisplayHtml(private val settings: HtmlSettings) : HtmlHeadProvider {
     * @return A `<style>` element that can be dynamically included in the HTML `<head>` element when messages are
     * @return A `<style>` element that can be dynamically included in the HTML `<head>` element when messages are
     * displayed.
     * displayed.
     */
     */
    @Language("HTML")
    private fun cssStylePre(): String {
    private fun cssStylePre(): String {
        val font = if (settings.useFixedWidthFont) "monospace" else "sans-serif"
        val font = if (settings.useFixedWidthFont) "monospace" else "sans-serif"


@@ -78,6 +86,7 @@ class DisplayHtml(private val settings: HtmlSettings) : HtmlHeadProvider {
        """.trimIndent()
        """.trimIndent()
    }
    }


    @Language("HTML")
    private fun cssStyleSignature(): String {
    private fun cssStyleSignature(): String {
        return """
        return """
            <style type="text/css">
            <style type="text/css">