Browse Source

Use custom tabs to open links in original message

main
M66B 5 years ago
parent
commit
f6291f8d7a
1 changed files with 18 additions and 3 deletions
  1. +18
    -3
      app/src/main/java/eu/faircode/email/FragmentWebView.java

+ 18
- 3
app/src/main/java/eu/faircode/email/FragmentWebView.java View File

@ -19,7 +19,10 @@ package eu.faircode.email;
Copyright 2018 by Marcel Bokhorst (M66B)
*/
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -31,6 +34,7 @@ import android.widget.ProgressBar;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.browser.customtabs.CustomTabsIntent;
// https://developer.android.com/reference/android/webkit/WebView
@ -50,11 +54,22 @@ public class FragmentWebView extends FragmentEx {
settings.setJavaScriptEnabled(true);
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
webview.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
setSubtitle(url);
return false;
if (prefs.getBoolean("webview", false)) {
view.loadUrl(url);
setSubtitle(url);
return false;
} else {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(Helper.resolveColor(getContext(), R.attr.colorPrimary));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(getContext(), Uri.parse(url));
return true;
}
}
});


Loading…
Cancel
Save