Skip to content

Commit

Permalink
Use WebSettingsCompat.setSafeBrowsingEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Stypox committed Feb 4, 2025
1 parent 87317c6 commit b62a09b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ dependencies {
implementation "androidx.work:work-runtime-ktx:${androidxWorkVersion}"
implementation "androidx.work:work-rxjava3:${androidxWorkVersion}"
implementation 'com.google.android.material:material:1.11.0'
implementation "androidx.webkit:webkit:1.9.0"

/** Third-party libraries **/
// Instance state boilerplate elimination
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.schabi.newpipe.util.potoken

import android.content.Context
import android.os.Build
import android.os.Handler
import android.os.Looper
import android.util.Log
Expand All @@ -10,6 +9,8 @@ import android.webkit.JavascriptInterface
import android.webkit.WebChromeClient
import android.webkit.WebView
import androidx.annotation.MainThread
import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebViewFeature
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.core.SingleEmitter
Expand All @@ -31,14 +32,14 @@ class PoTokenWebView private constructor(

//region Initialization
init {
val webviewSettings = webView.settings
val webViewSettings = webView.settings
//noinspection SetJavaScriptEnabled we want to use JavaScript!
webviewSettings.javaScriptEnabled = true
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
webviewSettings.safeBrowsingEnabled = false
webViewSettings.javaScriptEnabled = true
if (WebViewFeature.isFeatureSupported(WebViewFeature.SAFE_BROWSING_ENABLE)) {
WebSettingsCompat.setSafeBrowsingEnabled(webViewSettings, false)
}
webviewSettings.userAgentString = USER_AGENT
webviewSettings.blockNetworkLoads = true // the WebView does not need internet access
webViewSettings.userAgentString = USER_AGENT
webViewSettings.blockNetworkLoads = true // the WebView does not need internet access

// so that we can run async functions and get back the result
webView.addJavascriptInterface(this, JS_INTERFACE)
Expand Down

0 comments on commit b62a09b

Please sign in to comment.