Make webview background follow app theme

This commit is contained in:
NekoInverter committed 2020-12-18 14:16:06 +08:00
1 parent f0df64c32b
commit a5a12e030a
2 files changed
+5

No files matched your search

@@ -13,6 +13,7 @@ import android.webkit.WebViewClient;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.hippo.android.resource.AttrResources;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.client.EhCookieStore;
@@ -36,6 +37,7 @@ public class MyTagsFragment extends BaseFragment {
View view = inflater.inflate(R.layout.activity_webview, container, false);
setTitle(R.string.my_tags);
webView = view.findViewById(R.id.webview);
webView.setBackgroundColor(AttrResources.getAttrColor(requireActivity(), android.R.attr.colorBackground));
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new MyTagsWebViewClient());
webView.setWebChromeClient(new DialogWebChromeClient(requireContext()));
@@ -16,6 +16,7 @@ import android.webkit.WebViewClient;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.hippo.android.resource.AttrResources;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.client.EhCookieStore;
@@ -41,6 +42,7 @@ public class UConfigFragment extends BaseFragment {
View view = inflater.inflate(R.layout.activity_webview, container, false);
setTitle(R.string.u_config);
webView = view.findViewById(R.id.webview);
webView.setBackgroundColor(AttrResources.getAttrColor(requireActivity(), android.R.attr.colorBackground));
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new UConfigWebViewClient());
webView.setWebChromeClient(new DialogWebChromeClient(requireContext()));
@@ -144,6 +146,7 @@ public class UConfigFragment extends BaseFragment {
}
private class UConfigWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// Never load other urls