Merge pull request #4117 from ByteHamster/webview-min-height

Reduced probability for closing player accidentally
This commit is contained in:
H. Lehmann 2020-05-06 16:45:33 +02:00 committed by GitHub
commit 626c6aebe5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -47,6 +47,17 @@ public class ItemDescriptionFragment extends Fragment {
// Restoring the scroll position might not always work
webvDescription.postDelayed(ItemDescriptionFragment.this::restoreFromPreference, 50);
});
root.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right,
int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (root.getMeasuredHeight() != webvDescription.getMinimumHeight()) {
webvDescription.setMinimumHeight(root.getMeasuredHeight());
}
root.removeOnLayoutChangeListener(this);
}
});
registerForContextMenu(webvDescription);
return root;
}

View File

@ -165,4 +165,11 @@ public class ShownotesWebView extends WebView implements View.OnLongClickListene
public void setPageFinishedListener(Runnable pageFinishedListener) {
this.pageFinishedListener = pageFinishedListener;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
setMeasuredDimension(Math.max(getMeasuredWidth(), getMinimumWidth()),
Math.max(getMeasuredHeight(), getMinimumHeight()));
}
}