File tree 2 files changed +9
-9
lines changed
app/src/main/java/com/infomaniak/mail
2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import android.print.PrintManager
29
29
import android.webkit.WebView
30
30
import androidx.lifecycle.ViewModel
31
31
import androidx.lifecycle.viewModelScope
32
+ import com.infomaniak.mail.utils.extensions.formatSubject
32
33
import kotlinx.coroutines.Dispatchers
33
34
import kotlinx.coroutines.launch
34
35
@@ -40,11 +41,10 @@ class PrintMailViewModel : ViewModel() {
40
41
webView : WebView ,
41
42
onFinish : () -> Unit ,
42
43
) = viewModelScope.launch(Dispatchers .Main ) {
43
- subject?.let { subject ->
44
- val webViewPrintAdapter = PrintAdapterWrapper (webView.createPrintDocumentAdapter(subject), onFinish)
45
- val printManager = activityContext.getSystemService(Context .PRINT_SERVICE ) as PrintManager
46
- printManager.print (subject, webViewPrintAdapter, null )
47
- }
44
+ val protectedSubject = activityContext.formatSubject(subject)
45
+ val webViewPrintAdapter = PrintAdapterWrapper (webView.createPrintDocumentAdapter(protectedSubject), onFinish)
46
+ val printManager = activityContext.getSystemService(Context .PRINT_SERVICE ) as PrintManager
47
+ printManager.print (protectedSubject, webViewPrintAdapter, null )
48
48
}
49
49
50
50
private class PrintAdapterWrapper (
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import com.infomaniak.mail.R
22
22
import com.infomaniak.mail.data.models.correspondent.Recipient
23
23
import com.infomaniak.mail.data.models.message.Message
24
24
import com.infomaniak.mail.utils.MailDateFormatUtils.formatForHeader
25
+ import com.infomaniak.mail.utils.extensions.formatSubject
25
26
import com.infomaniak.mail.utils.extensions.toDate
26
27
import org.jsoup.nodes.Element
27
28
import java.util.Date
@@ -40,10 +41,9 @@ object PrintHeaderUtils {
40
41
elementsToInsert.add(iconElement)
41
42
elementsToInsert.add(firstSeparator)
42
43
43
- message.subject?.let { subject ->
44
- val subjectElement = Element (" b" ).appendText(subject)
45
- elementsToInsert.add(subjectElement)
46
- }
44
+ val subject = context.formatSubject(message.subject)
45
+ val subjectElement = Element (" b" ).appendText(subject)
46
+ elementsToInsert.add(subjectElement)
47
47
48
48
elementsToInsert.add(secondSeparator)
49
49
You can’t perform that action at this time.
0 commit comments