From 3cb480d72f447dc77c4225896929eb471d6ee900 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 30 Dec 2021 19:40:40 +0100 Subject: [PATCH] Web view max height = recycler view height --- .../eu/faircode/email/AdapterMessage.java | 3 ++- .../java/eu/faircode/email/WebViewEx.java | 22 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index bc5f8c2c9d..6bec93ef1f 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -2406,7 +2406,8 @@ public class AdapterMessage extends RecyclerView.Adapter position, boolean force_light, IWebView intf) { - Log.i("Init height=" + height + " size=" + size); + void init(int height, int maxHeight, float size, Pair position, boolean force_light, IWebView intf) { + Log.i("Init height=" + height + "/" + maxHeight + " size=" + size); + + if (maxHeight == 0) { + Log.e("WebView max height zero"); + maxHeight = getResources().getDisplayMetrics().heightPixels; + } this.height = (height == 0 ? getMinimumHeight() : height); + this.maxHeight = maxHeight; setInitialScale(size == 0 ? 0 : Math.round(size * 100)); @@ -208,14 +216,12 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (height > getMinimumHeight()) - super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); - else { - int max = getResources().getDisplayMetrics().heightPixels; - super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(max, MeasureSpec.AT_MOST)); - } + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Math.min(height, maxHeight), MeasureSpec.AT_MOST)); + else + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST)); int mh = getMeasuredHeight(); - Log.i("Measured height=" + mh + " last=" + height); + Log.i("Measured height=" + mh + " last=" + height + "/" + maxHeight + " ch=" + getContentHeight()); if (mh == 0) setMeasuredDimension(getMeasuredWidth(), height); }