Small improvement

This commit is contained in:
M66B 2019-04-27 11:01:21 +02:00
parent 463dc7d36f
commit 3348995a5f
1 changed files with 22 additions and 20 deletions

View File

@ -1458,6 +1458,25 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
}); });
webView.setBackgroundColor(Color.TRANSPARENT);
WebSettings settings = webView.getSettings();
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
settings.setAllowFileAccess(false);
// Set default font
int px = Math.round(TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_PX, textSize,
context.getResources().getDisplayMetrics()));
settings.setDefaultFontSize(px);
if (monospaced)
settings.setStandardFontFamily("monospace");
webView.setId(vwBody.getId()); webView.setId(vwBody.getId());
webView.setVisibility(vwBody.getVisibility()); webView.setVisibility(vwBody.getVisibility());
@ -1469,29 +1488,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
final WebView webView = (WebView) vwBody; final WebView webView = (WebView) vwBody;
webView.loadUrl("about:blank"); webView.getSettings().setLoadsImagesAutomatically(show_images);
webView.setBackgroundColor(Color.TRANSPARENT);
WebSettings settings = webView.getSettings();
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
settings.setAllowFileAccess(false);
settings.setLoadsImagesAutomatically(show_images);
// Set default font
int px = Math.round(TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_PX, textSize,
context.getResources().getDisplayMetrics()));
settings.setDefaultFontSize(px);
if (monospaced)
settings.setStandardFontFamily("monospace");
String html = properties.getHtml(message.id); String html = properties.getHtml(message.id);
if (TextUtils.isEmpty(html)) { if (TextUtils.isEmpty(html)) {
webView.loadUrl("about:blank");
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", message.id); args.putLong("id", message.id);
args.putBoolean("dark", dark); args.putBoolean("dark", dark);