mirror of https://github.com/M66B/FairEmail.git
Web view max height = recycler view height
This commit is contained in:
parent
28c550f90f
commit
3cb480d72f
|
@ -2406,7 +2406,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
webView.setMinimumHeight(height);
|
webView.setMinimumHeight(height);
|
||||||
|
|
||||||
webView.init(height, size, position, force_light,
|
int maxHeight = rv.getHeight() - rv.getPaddingTop();
|
||||||
|
webView.init(height, maxHeight, size, position, force_light,
|
||||||
new WebViewEx.IWebView() {
|
new WebViewEx.IWebView() {
|
||||||
@Override
|
@Override
|
||||||
public void onSizeChanged(int w, int h, int ow, int oh) {
|
public void onSizeChanged(int w, int h, int ow, int oh) {
|
||||||
|
|
|
@ -47,8 +47,10 @@ import static androidx.webkit.WebSettingsCompat.FORCE_DARK_ON;
|
||||||
|
|
||||||
public class WebViewEx extends WebView implements DownloadListener, View.OnLongClickListener {
|
public class WebViewEx extends WebView implements DownloadListener, View.OnLongClickListener {
|
||||||
private int height;
|
private int height;
|
||||||
|
private int maxHeight;
|
||||||
private IWebView intf;
|
private IWebView intf;
|
||||||
private Runnable onPageLoaded;
|
private Runnable onPageLoaded;
|
||||||
|
|
||||||
private static String userAgent = null;
|
private static String userAgent = null;
|
||||||
|
|
||||||
private static final long PAGE_LOADED_FALLBACK_DELAY = 1500L; // milliseconds
|
private static final long PAGE_LOADED_FALLBACK_DELAY = 1500L; // milliseconds
|
||||||
|
@ -85,10 +87,16 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
|
||||||
WebSettingsCompat.setSafeBrowsingEnabled(settings, safe_browsing);
|
WebSettingsCompat.setSafeBrowsingEnabled(settings, safe_browsing);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(int height, float size, Pair<Integer, Integer> position, boolean force_light, IWebView intf) {
|
void init(int height, int maxHeight, float size, Pair<Integer, Integer> position, boolean force_light, IWebView intf) {
|
||||||
Log.i("Init height=" + height + " size=" + size);
|
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.height = (height == 0 ? getMinimumHeight() : height);
|
||||||
|
this.maxHeight = maxHeight;
|
||||||
|
|
||||||
setInitialScale(size == 0 ? 0 : Math.round(size * 100));
|
setInitialScale(size == 0 ? 0 : Math.round(size * 100));
|
||||||
|
|
||||||
|
@ -208,14 +216,12 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
if (height > getMinimumHeight())
|
if (height > getMinimumHeight())
|
||||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
|
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Math.min(height, maxHeight), MeasureSpec.AT_MOST));
|
||||||
else {
|
else
|
||||||
int max = getResources().getDisplayMetrics().heightPixels;
|
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST));
|
||||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(max, MeasureSpec.AT_MOST));
|
|
||||||
}
|
|
||||||
|
|
||||||
int mh = getMeasuredHeight();
|
int mh = getMeasuredHeight();
|
||||||
Log.i("Measured height=" + mh + " last=" + height);
|
Log.i("Measured height=" + mh + " last=" + height + "/" + maxHeight + " ch=" + getContentHeight());
|
||||||
if (mh == 0)
|
if (mh == 0)
|
||||||
setMeasuredDimension(getMeasuredWidth(), height);
|
setMeasuredDimension(getMeasuredWidth(), height);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue