|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|