mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-16 22:17:28 +01:00
Fix WebView crash introduced in v0.19.2 (#2649)
This commit is contained in:
@@ -11,6 +11,8 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
|||||||
- `Other` - for technical stuff.
|
- `Other` - for technical stuff.
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
### Fixed
|
||||||
|
- Fix WebView crash introduced in 0.19.2 ([@bapeey](https://github.com/bapeey)) ([#2649](https://github.com/mihonapp/mihon/pull/2649))
|
||||||
|
|
||||||
## [v0.19.2] - 2025-11-02
|
## [v0.19.2] - 2025-11-02
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -133,21 +133,20 @@ fun WebViewScreenContent(
|
|||||||
view: WebView?,
|
view: WebView?,
|
||||||
request: WebResourceRequest?,
|
request: WebResourceRequest?,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
request?.let {
|
val url = request?.url?.toString() ?: return false
|
||||||
// Don't attempt to open blobs as webpages
|
|
||||||
if (it.url.toString().startsWith("blob:http")) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ignore intents urls
|
// Ignore intents urls
|
||||||
if (it.url.toString().startsWith("intent://")) {
|
if (url.startsWith("intent://")) return true
|
||||||
|
|
||||||
|
// Only open valid web urls
|
||||||
|
if (url.startsWith("http") || url.startsWith("https")) {
|
||||||
|
if (url != view?.url) {
|
||||||
|
view?.loadUrl(url, headers)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Continue with request, but with custom headers
|
|
||||||
view?.loadUrl(it.url.toString(), headers)
|
|
||||||
}
|
}
|
||||||
return super.shouldOverrideUrlLoading(view, request)
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user