Open mueller-ma opened 6 years ago
@resetnow Something for you?
Unfortunately, this can't be implemented easily due to how browsers work. In OpenHAB, webviews are rendered as iframe
. Cross-origin safety rules implemented in browsers prohibit any access from the "top" document to "child" document, including to such parameters as height and width. The only working solution involves willing interaction from the "child", which could send a message with its height to the parent. This requires inserting scripts into the page, dealing with HTTPS and so on.
This is already implement - by accident - in the openHAB app for Android.
This is correct — but in Android, the app has more access to webview inside it. In BasicUI, UI page itself and webview inside it are on more or less equal terms and are separated by browser safety policies.
I see. Is it possible to increase the default height? This way it's possible to have a working sitemap for both clients (Basic ui and Android app). Otherwise you can either have a fixed height and have a hardly usable webview in Android (because you cannot scroll and from a UX perspective it's hard to implement scolling) or you can omit the height attribute and have a unusable webview in basic ui.
Ideally, it would be good to have support for auto height with fallback to numeric value; for example height="auto,4"
. Clients could then do their best to get actual height and if that's not possible, use fallback. I don't know how intuitive it is though.
Is there any actuall usecase where a user wants to set a height and not see the complete website? Wouldn't it be better when Android app ignores the height attribute and always show the full page. And UIs that cannot auto-scale use the height?
Is there any actuall usecase where a user wants to set a height and not see the complete website?
I think for websites with dynamically loaded content or "feeds" it makes sense to have some fixed height, otherwise upon document load the height might be very small.
@kaikreuzer what do you think about height="auto,4"
?
Could we treat the "height" parameter as a "maxHeight"? I.e. always do auto-scale, but allow the user to limit the height, because the content might e.g. be a long news feed. This logic should be valid for Basic UI and native apps likewise, wdyt?
This perhaps depends on whether or not it's possible to do in Android's WebView in a "clean" way — without layout changing as page continues to load, which may be annoying.
Let's see what @mueller-ma says about that. But if I got him right, he wants to have auto-height, so that should just be fine.
I've done some research, but haven't found a clean way to limit the height of a webview. Maybe @maniac103 knows a smart way.
Max height should be totally doable in Android by creating a custom WebView subclass overriding onMeasure(), like seen here ... depending on how the page is laid out, this might cause layout changes after loading, but if the height attribute is omitted, that's the case as of now already.
Could we treat the "height" parameter as a "maxHeight"?
Should I start implementing this in the app?
I'm all for it 👍
I opened a PR. I guess the docs should be changed as well?
https://github.com/openhab/openhab-android/releases/tag/2.3.6-beta contains this change.
I guess the default hight of the webview in basic ui should be changed. The current default is too low.
I'd agree.
@resetnow Wdyt?
Yes, I guess default height can be changed so the widget has approximately 16:9 or 4:3 ratio
I had to revert the change in the app since some website (i.e. Grafana graphs) have no fixed height, but use the full available space. And if the webview is only as high as the website, grafana graphs won't be shown at all.
The default height has been changed lately (https://github.com/eclipse/smarthome/pull/6046/files#diff-5cd1999e439874019327a7f5c4c361cbR67), but IMO 4 is still too small.
If no height attribute for a webview item is set, a very small frame is shown in Basic UI:
It can be difficult to set the height, so the best solution would be IMO to set no height at all and let the UI maximize the webview. This is already implement - by accident - in the openHAB app for Android.