mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
fix openOnlineUrl(), mailto/openpgp4fpr has to open externally (#3008)
* fix openOnlineUrl(), mailto/openpgp4fpr has to open externally * Update src/org/thoughtcrime/securesms/WebxdcActivity.java Co-authored-by: bjoern <r10s@b44t.com> * Update src/org/thoughtcrime/securesms/WebxdcActivity.java Co-authored-by: bjoern <r10s@b44t.com> --------- Co-authored-by: bjoern <r10s@b44t.com>
This commit is contained in:
committed by
GitHub
parent
217478e90b
commit
224201a77f
@@ -62,6 +62,7 @@ public class WebViewActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
webView = findViewById(R.id.webview);
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
// IMPORTANT: this is will likely not be called inside iframes.
|
||||
// `shouldOverrideUrlLoading()` is called when the user clicks a URL,
|
||||
// returning `true` causes the WebView to abort loading the URL,
|
||||
// returning `false` causes the WebView to continue loading the URL as usual.
|
||||
|
||||
@@ -266,18 +266,16 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
|
||||
}
|
||||
}
|
||||
|
||||
// This is usually only called when internetAccess == true or for mailto/openpgp4fpr scheme,
|
||||
// because when internetAccess == false, the page is loaded inside an iframe,
|
||||
// and WebViewClient.shouldOverrideUrlLoading is not called for HTTP(S) links inside the iframe
|
||||
@Override
|
||||
protected boolean openOnlineUrl(String url) {
|
||||
if (internetAccess) {
|
||||
// internet access enabled, continue loading in the WebView
|
||||
return false;
|
||||
}
|
||||
if (url.startsWith("mailto:")) {
|
||||
Log.i(TAG, "openOnlineUrl: " + url);
|
||||
if (url.startsWith("mailto:") || url.startsWith("openpgp4fpr:")) {
|
||||
return super.openOnlineUrl(url);
|
||||
}
|
||||
|
||||
Toast.makeText(this, "Please embed needed resources.", Toast.LENGTH_LONG).show();
|
||||
return true; // returning `true` causes the WebView to abort loading
|
||||
return !internetAccess; // returning `false` continues loading in WebView; returning `true` let WebView abort loading
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user