Commit 6c7a5cf8 authored by Hussein's avatar Hussein

P4A-775 - Force wordbreak text is MessageWebView (Merge-commit)

commit c65d597469eebd1c9cd61191b40a32c3513355b7
Author: Francisco Cunha <fc@pep.security>
Date:   Wed May 13 15:45:44 2020 +0200

    P4A-775 - Force wordbreak text is MessageWebView
parent 14a27ee7
...@@ -21,6 +21,10 @@ import com.fsck.k9.pEp.ui.tools.FeedbackTools; ...@@ -21,6 +21,10 @@ import com.fsck.k9.pEp.ui.tools.FeedbackTools;
public class MessageWebView extends RigidWebView { public class MessageWebView extends RigidWebView {
private static final String WORDS_BREAK = "<body style=\"overflow-wrap: break-word; word-wrap: " +
"break-word; word-break: break-all; word-break: break-word; -webkit-hyphens: auto; hyphens: auto; ";
private static final String BODY_CLOSE = " </body>";
public MessageWebView(Context context) { public MessageWebView(Context context) {
super(context); super(context);
} }
...@@ -115,8 +119,10 @@ public class MessageWebView extends RigidWebView { ...@@ -115,8 +119,10 @@ public class MessageWebView extends RigidWebView {
getSettings().setDisplayZoomControls(!supportsMultiTouch); getSettings().setDisplayZoomControls(!supportsMultiTouch);
} }
public void displayHtmlContentWithInlineAttachments(@NonNull String htmlText, public void displayHtmlContentWithInlineAttachments(
@Nullable AttachmentResolver attachmentResolver, @Nullable OnPageFinishedListener onPageFinishedListener) { @NonNull String htmlText,
@Nullable AttachmentResolver attachmentResolver,
@Nullable OnPageFinishedListener onPageFinishedListener) {
setWebViewClient(attachmentResolver, onPageFinishedListener); setWebViewClient(attachmentResolver, onPageFinishedListener);
setHtmlContent(htmlText); setHtmlContent(htmlText);
} }
...@@ -130,8 +136,13 @@ public class MessageWebView extends RigidWebView { ...@@ -130,8 +136,13 @@ public class MessageWebView extends RigidWebView {
setWebViewClient(webViewClient); setWebViewClient(webViewClient);
} }
private String forceBreakWordsHeader(String htmlText) {
return WORDS_BREAK + htmlText + BODY_CLOSE;
}
private void setHtmlContent(@NonNull String htmlText) { private void setHtmlContent(@NonNull String htmlText) {
loadDataWithBaseURL("about:blank", htmlText, "text/html", "utf-8", null); String html = forceBreakWordsHeader(htmlText);
loadDataWithBaseURL("about:blank", html, "text/html", "utf-8", null);
resumeTimers(); resumeTimers();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment