PrivacyPolicyActivity (opencloudApp/src/main/java/eu/opencloud/android/presentation/settings/privacypolicy/PrivacyPolicyActivity.kt) sets up its WebViewClient with only an onReceivedError override:
webViewClient = object : WebViewClient() {
override fun onReceivedError(view: WebView, errorCode: Int, description: String, failingUrl: String) {
showMessageInSnackbar(message = getString(R.string.privacy_policy_error) + description)
}
}
Because shouldOverrideUrlLoading is not overridden, every link the privacy policy page renders is loaded by the WebView itself. That has two visible effects:
- A
mailto: link in the policy text opens nothing. The WebView fails to load mailto:foo@example.com and the user sees a blank state.
- A non http(s) scheme that some other app on the device claims (
tel:, geo:, intent:, market:) is just swallowed by the WebView instead of handing it to that app.
This is a normal pre-API-24 default, but on a modern build the privacy policy view stops being a useful escape hatch into the system browser / mail app.
Suggested fix
Override shouldOverrideUrlLoading so http(s) navigations stay in the WebView and any other scheme is routed out via Intent.ACTION_VIEW, with a try/catch for ActivityNotFoundException so a missing handler does not crash the Activity:
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
val url = request?.url ?: return false
val scheme = url.scheme?.lowercase()
if (scheme == "http" || scheme == "https") return false
return try {
startActivity(Intent(Intent.ACTION_VIEW, url).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
})
true
} catch (e: ActivityNotFoundException) {
false
}
}
A PR with the change is at #165.
PrivacyPolicyActivity(opencloudApp/src/main/java/eu/opencloud/android/presentation/settings/privacypolicy/PrivacyPolicyActivity.kt) sets up itsWebViewClientwith only anonReceivedErroroverride:Because
shouldOverrideUrlLoadingis not overridden, every link the privacy policy page renders is loaded by the WebView itself. That has two visible effects:mailto:link in the policy text opens nothing. The WebView fails to loadmailto:foo@example.comand the user sees a blank state.tel:,geo:,intent:,market:) is just swallowed by the WebView instead of handing it to that app.This is a normal pre-API-24 default, but on a modern build the privacy policy view stops being a useful escape hatch into the system browser / mail app.
Suggested fix
Override
shouldOverrideUrlLoadingso http(s) navigations stay in the WebView and any other scheme is routed out viaIntent.ACTION_VIEW, with atry/catchforActivityNotFoundExceptionso a missing handler does not crash the Activity:A PR with the change is at #165.