1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Add activity flags to browser view intent

This commit is contained in:
cketti 2015-04-04 01:06:14 +02:00
parent ba8cb6c85d
commit babd3a530f

View File

@ -60,6 +60,7 @@ public abstract class K9WebViewClient extends WebViewClient {
Context context = webView.getContext(); Context context = webView.getContext();
Intent intent = createBrowserViewIntent(uri, context); Intent intent = createBrowserViewIntent(uri, context);
addActivityFlags(intent);
boolean overridingUrlLoading = false; boolean overridingUrlLoading = false;
try { try {
@ -80,6 +81,8 @@ public abstract class K9WebViewClient extends WebViewClient {
return intent; return intent;
} }
protected abstract void addActivityFlags(Intent intent);
protected WebResourceResponse shouldInterceptRequest(WebView webView, Uri uri) { protected WebResourceResponse shouldInterceptRequest(WebView webView, Uri uri) {
if (!CID_SCHEME.equals(uri.getScheme())) { if (!CID_SCHEME.equals(uri.getScheme())) {
return RESULT_DO_NOT_INTERCEPT; return RESULT_DO_NOT_INTERCEPT;
@ -131,16 +134,21 @@ public abstract class K9WebViewClient extends WebViewClient {
} }
@SuppressWarnings("deprecation")
private static class PreLollipopWebViewClient extends K9WebViewClient { private static class PreLollipopWebViewClient extends K9WebViewClient {
protected PreLollipopWebViewClient(Part part) { protected PreLollipopWebViewClient(Part part) {
super(part); super(part);
} }
@SuppressWarnings("deprecation")
@Override @Override
public WebResourceResponse shouldInterceptRequest(WebView webView, String url) { public WebResourceResponse shouldInterceptRequest(WebView webView, String url) {
return shouldInterceptRequest(webView, Uri.parse(url)); return shouldInterceptRequest(webView, Uri.parse(url));
} }
@Override
protected void addActivityFlags(Intent intent) {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
}
} }
@TargetApi(VERSION_CODES.LOLLIPOP) @TargetApi(VERSION_CODES.LOLLIPOP)
@ -153,5 +161,10 @@ public abstract class K9WebViewClient extends WebViewClient {
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest request) { public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest request) {
return shouldInterceptRequest(webView, request.getUrl()); return shouldInterceptRequest(webView, request.getUrl());
} }
@Override
protected void addActivityFlags(Intent intent) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
}
} }
} }