11package org.schabi.newpipe.util.potoken
22
33import android.content.Context
4- import android.os.Build
54import android.os.Handler
65import android.os.Looper
76import android.util.Log
@@ -10,6 +9,8 @@ import android.webkit.JavascriptInterface
109import android.webkit.WebChromeClient
1110import android.webkit.WebView
1211import androidx.annotation.MainThread
12+ import androidx.webkit.WebSettingsCompat
13+ import androidx.webkit.WebViewFeature
1314import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
1415import io.reactivex.rxjava3.core.Single
1516import io.reactivex.rxjava3.core.SingleEmitter
@@ -31,14 +32,14 @@ class PoTokenWebView private constructor(
3132
3233 // region Initialization
3334 init {
34- val webviewSettings = webView.settings
35+ val webViewSettings = webView.settings
3536 // noinspection SetJavaScriptEnabled we want to use JavaScript!
36- webviewSettings .javaScriptEnabled = true
37- if (Build . VERSION . SDK_INT >= Build . VERSION_CODES . O ) {
38- webviewSettings.safeBrowsingEnabled = false
37+ webViewSettings .javaScriptEnabled = true
38+ if (WebViewFeature .isFeatureSupported( WebViewFeature . SAFE_BROWSING_ENABLE ) ) {
39+ WebSettingsCompat .setSafeBrowsingEnabled(webViewSettings, false )
3940 }
40- webviewSettings .userAgentString = USER_AGENT
41- webviewSettings .blockNetworkLoads = true // the WebView does not need internet access
41+ webViewSettings .userAgentString = USER_AGENT
42+ webViewSettings .blockNetworkLoads = true // the WebView does not need internet access
4243
4344 // so that we can run async functions and get back the result
4445 webView.addJavascriptInterface(this , JS_INTERFACE )
0 commit comments