Use WebSettingsCompat.setSafeBrowsingEnabled

This commit is contained in:
Stypox 2025-02-04 21:50:10 +01:00
parent 87317c6faf
commit b62a09b5b3
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23
2 changed files with 9 additions and 7 deletions

View file

@ -241,6 +241,7 @@ dependencies {
implementation "androidx.work:work-runtime-ktx:${androidxWorkVersion}" implementation "androidx.work:work-runtime-ktx:${androidxWorkVersion}"
implementation "androidx.work:work-rxjava3:${androidxWorkVersion}" implementation "androidx.work:work-rxjava3:${androidxWorkVersion}"
implementation 'com.google.android.material:material:1.11.0' implementation 'com.google.android.material:material:1.11.0'
implementation "androidx.webkit:webkit:1.9.0"
/** Third-party libraries **/ /** Third-party libraries **/
// Instance state boilerplate elimination // Instance state boilerplate elimination

View file

@ -1,7 +1,6 @@
package org.schabi.newpipe.util.potoken package org.schabi.newpipe.util.potoken
import android.content.Context import android.content.Context
import android.os.Build
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.util.Log import android.util.Log
@ -10,6 +9,8 @@ import android.webkit.JavascriptInterface
import android.webkit.WebChromeClient import android.webkit.WebChromeClient
import android.webkit.WebView import android.webkit.WebView
import androidx.annotation.MainThread import androidx.annotation.MainThread
import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebViewFeature
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.core.SingleEmitter import io.reactivex.rxjava3.core.SingleEmitter
@ -31,14 +32,14 @@ class PoTokenWebView private constructor(
//region Initialization //region Initialization
init { init {
val webviewSettings = webView.settings val webViewSettings = webView.settings
//noinspection SetJavaScriptEnabled we want to use JavaScript! //noinspection SetJavaScriptEnabled we want to use JavaScript!
webviewSettings.javaScriptEnabled = true webViewSettings.javaScriptEnabled = true
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (WebViewFeature.isFeatureSupported(WebViewFeature.SAFE_BROWSING_ENABLE)) {
webviewSettings.safeBrowsingEnabled = false WebSettingsCompat.setSafeBrowsingEnabled(webViewSettings, false)
} }
webviewSettings.userAgentString = USER_AGENT webViewSettings.userAgentString = USER_AGENT
webviewSettings.blockNetworkLoads = true // the WebView does not need internet access webViewSettings.blockNetworkLoads = true // the WebView does not need internet access
// so that we can run async functions and get back the result // so that we can run async functions and get back the result
webView.addJavascriptInterface(this, JS_INTERFACE) webView.addJavascriptInterface(this, JS_INTERFACE)