mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 09:52:16 -05:00
Restructure the code a bit
This commit is contained in:
parent
8bcf9b1d50
commit
09babb6e88
@ -53,21 +53,30 @@ public abstract class K9WebViewClient extends WebViewClient {
|
||||
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView webView, String url) {
|
||||
Context context = webView.getContext();
|
||||
Uri uri = Uri.parse(url);
|
||||
if (!CID_SCHEME.equals(uri.getScheme())) {
|
||||
if (CID_SCHEME.equals(uri.getScheme())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Context context = webView.getContext();
|
||||
Intent intent = createBrowserViewIntent(uri, context);
|
||||
|
||||
boolean overridingUrlLoading = false;
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
overridingUrlLoading = true;
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
// If no application can handle the URL, assume that the WebView can handle it.
|
||||
}
|
||||
|
||||
return overridingUrlLoading;
|
||||
}
|
||||
|
||||
private Intent createBrowserViewIntent(Uri uri, Context context) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
// If no application can handle the URL, assume that the
|
||||
// WebView can handle it.
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return intent;
|
||||
}
|
||||
|
||||
protected WebResourceResponse shouldInterceptRequest(WebView webView, Uri uri) {
|
||||
|
Loading…
Reference in New Issue
Block a user