@@ -22,7 +22,9 @@ import androidx.annotation.RawRes
22
22
import com.infomaniak.html.cleaner.HtmlSanitizer
23
23
import com.infomaniak.mail.R
24
24
import com.infomaniak.mail.data.models.message.Message
25
+ import com.infomaniak.mail.utils.Utils.PRIMARY_COLOR_CODE
25
26
import com.infomaniak.mail.utils.extensions.getAttributeColor
27
+ import com.infomaniak.mail.utils.extensions.loadCss
26
28
import com.infomaniak.mail.utils.extensions.readRawResource
27
29
import org.jsoup.Jsoup
28
30
import org.jsoup.nodes.Element
@@ -178,7 +180,6 @@ class HtmlFormatter(private val html: String) {
178
180
data class PrintData (val context : Context , val message : Message )
179
181
180
182
companion object {
181
- private const val PRIMARY_COLOR_CODE = " --kmail-primary-color"
182
183
private const val KMAIL_MESSAGE_ID = " kmail-message-content"
183
184
184
185
private const val WBR = " wbr"
@@ -189,22 +190,6 @@ class HtmlFormatter(private val html: String) {
189
190
private val DETECT_BUT_DO_NOT_BREAK = setOf (' ' )
190
191
private val BREAK_CHARACTERS = setOf (' :' , ' /' , ' ~' , ' .' , ' ,' , ' -' , ' _' , ' ?' , ' #' , ' %' , ' =' , ' &' )
191
192
192
- private fun Context.loadCss (@RawRes cssResId : Int , customColors : List <Pair <String , Int >> = emptyList()): String {
193
- var css = readRawResource(cssResId)
194
-
195
- if (customColors.isNotEmpty()) {
196
- var header = " :root {\n "
197
- customColors.forEach { (variableName, color) ->
198
- header + = formatCssVariable(variableName, color)
199
- }
200
- header + = " }\n\n "
201
-
202
- css = header + css
203
- }
204
-
205
- return css
206
- }
207
-
208
193
private fun Context.loadScript (
209
194
@RawRes scriptResId : Int ,
210
195
customVariablesDeclaration : List <Pair <String , Any >> = emptyList(),
@@ -225,11 +210,6 @@ class HtmlFormatter(private val html: String) {
225
210
}
226
211
}
227
212
228
- private fun formatCssVariable (variableName : String , color : Int ): String {
229
- val formattedColor = Utils .colorToHexRepresentation(color)
230
- return " $variableName : $formattedColor ;\n "
231
- }
232
-
233
213
fun Context.getCustomDarkMode (): String = loadCss(R .raw.custom_dark_mode)
234
214
235
215
fun Context.getImproveRenderingStyle (): String = loadCss(R .raw.improve_rendering)
0 commit comments