From babd3a530f51e7f88d0414d2135200542c79f6d1 Mon Sep 17 00:00:00 2001 From: cketti Date: Sat, 4 Apr 2015 01:06:14 +0200 Subject: [PATCH] Add activity flags to browser view intent --- .../java/com/fsck/k9/view/K9WebViewClient.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/k9mail/src/main/java/com/fsck/k9/view/K9WebViewClient.java b/k9mail/src/main/java/com/fsck/k9/view/K9WebViewClient.java index 95566847d..548cf2a29 100644 --- a/k9mail/src/main/java/com/fsck/k9/view/K9WebViewClient.java +++ b/k9mail/src/main/java/com/fsck/k9/view/K9WebViewClient.java @@ -60,6 +60,7 @@ public abstract class K9WebViewClient extends WebViewClient { Context context = webView.getContext(); Intent intent = createBrowserViewIntent(uri, context); + addActivityFlags(intent); boolean overridingUrlLoading = false; try { @@ -80,6 +81,8 @@ public abstract class K9WebViewClient extends WebViewClient { return intent; } + protected abstract void addActivityFlags(Intent intent); + protected WebResourceResponse shouldInterceptRequest(WebView webView, Uri uri) { if (!CID_SCHEME.equals(uri.getScheme())) { return RESULT_DO_NOT_INTERCEPT; @@ -131,16 +134,21 @@ public abstract class K9WebViewClient extends WebViewClient { } + @SuppressWarnings("deprecation") private static class PreLollipopWebViewClient extends K9WebViewClient { protected PreLollipopWebViewClient(Part part) { super(part); } - @SuppressWarnings("deprecation") @Override public WebResourceResponse shouldInterceptRequest(WebView webView, String 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) @@ -153,5 +161,10 @@ public abstract class K9WebViewClient extends WebViewClient { public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest request) { return shouldInterceptRequest(webView, request.getUrl()); } + + @Override + protected void addActivityFlags(Intent intent) { + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); + } } }