Open vsxed opened 3 years ago
But it's not actually a browser, its the WebView component inside the Android application. It doesn't have the concept of tabs, it just loads a single URL. The web page itself would have to have "tabs" or some type of navigation system. You can add an additional dashboard in the settings.
Thanks for the correction, you are right about the WebView.
My intention was to load external webpages inside the default browser of the device (where tabs are implemented widely) to prevent WallPanel to load the external url inside its own WebView (where Home assistant is already loaded).
The advantage would be that the external Webpage would not force the user to reload home assistant when pressing back. Instead, the default browser would simply be closed, which is the default behavior of android.
Will see if i have some time to create a pull request.
If the webpage is external, in the device browser, then you are no longer in the wallpanel app, you are now in chrome or whatever, there is no way to go back to the default wallpanel app from external app (not from wallpanel). Am I missing something?
Whats happening when using WallPanel:
https://user-images.githubusercontent.com/1070998/131351058-340f0057-6515-4feb-9036-f0b95f49cd04.mp4
(WallPanel opens the external url inside the WebView, back button is not actually going backwards in the backstack, but closes WallPanel)
What should be happening (at least), a.k.a. how its handled in the official Home Assistant app):
https://user-images.githubusercontent.com/1070998/131351268-bad7ca83-4669-4110-a9f8-51f5e817cb9b.mp4
(Home Assistant opens the external URL in the default browser, making it possible to switch back to the origin)
Ah ok, so you want the WebView to open external links in the native device browser. I think we have code that directly overrides this and makes links open within the application.
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
isRedirect = true
view.loadUrl(url)
return true
}
But removing this would probably mess up the default behavior of the application. We use the "isRedirect" flag only on the first instance of the application load.
Maybe we could add a JavaScript Interface to communicate from the web pages to the WebView like a channel, then launch external links based on the JS interface method we call. Or we could look for certain link formats and launch external browser instead. Not sure, just spit balling.
The HA application adds an JS Interface to their WebView which has commands to do things like launch URL's, play videos, open the configuration. I have another ticket to add such an interface to play videos, open our settings, something like that.
I have not had time to handle this yet. But the button in HA could just call JS command on the page and the interface would callback to the WebView and launch an external URL.
You might also be able to call this using the REST API of wallpanel, and launch external url from a button click in HA by calling the appropriate JS command.
Thanks, will have a look into this
Your feature request. Please describe. Would it be possible to open external urls in a new tab of the default browser instead of the in-app browser?
e.g. a card like this
opens the desired url inside wallpanel, not in the default browser.
The official Home Assistant also uses this behavior.
NOTE We get many feature requests, each feature requires community support and also development time. Features that have no community support are not considered. If you are not contributing to the feature, then the feature may not happen.