Simplified showing full messages images

pull/184/head
M66B 4 years ago
parent c8b6ece9af
commit a41559bdbe

@ -1869,7 +1869,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
webView.init(
height, size, position,
textSize, monospaced,
show_images, inline,
new WebViewEx.IWebView() {
@Override
public void onSizeChanged(int w, int h, int ow, int oh) {
@ -1896,6 +1895,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return ViewHolder.this.onOpenLink(uri, null);
}
});
webView.setImages(show_images, inline);
webView.setOnTouchListener(ViewHolder.this);
tvBody.setVisibility(View.GONE);
@ -3564,7 +3564,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void onShowImagesConfirmed(TupleMessageEx message) {
bindBody(message, false);
boolean show_full = properties.getValue("full", message.id);
boolean show_images = properties.getValue("images", message.id);
if (show_full && show_images && wvBody != null)
((WebViewEx) wvBody).setImages(show_images, inline);
else
bindBody(message, false);
}
private void onActionUnsubscribe(TupleMessageEx message) {

@ -69,7 +69,6 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
void init(
int height, float size, Pair<Integer, Integer> position,
float textSize, boolean monospaced,
boolean show_images, boolean inline,
IWebView intf) {
Log.i("Init height=" + height + " size=" + size);
@ -91,10 +90,6 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
if (monospaced)
settings.setStandardFontFamily("monospace");
settings.setLoadsImagesAutomatically(show_images || inline);
settings.setBlockNetworkLoads(!show_images);
settings.setBlockNetworkImage(!show_images);
this.intf = intf;
setWebViewClient(new WebViewClient() {
@ -120,6 +115,13 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
});
}
void setImages(boolean show_images, boolean inline) {
WebSettings settings = getSettings();
settings.setLoadsImagesAutomatically(show_images || inline);
settings.setBlockNetworkLoads(!show_images);
settings.setBlockNetworkImage(!show_images);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (height > getMinimumHeight())

Loading…
Cancel
Save