From e4d94b1a4e4fbfdaeb1336f9a416e23dec60cb02 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sat, 19 Dec 2020 04:25:42 +0530 Subject: [PATCH 1/2] Add AndroidX Webkit. --- app/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/app/build.gradle b/app/build.gradle index 4acff01bf..15561b2d2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -203,6 +203,7 @@ dependencies { implementation 'androidx.core:core-ktx:1.3.2' implementation 'androidx.documentfile:documentfile:1.0.1' implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' + implementation 'androidx.webkit:webkit:1.4.0' implementation "androidx.lifecycle:lifecycle-livedata:${androidxLifecycleVersion}" implementation "androidx.lifecycle:lifecycle-viewmodel:${androidxLifecycleVersion}" From 173150591dcb91cb2e8e3f5c42c709087a9ec3bc Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sat, 19 Dec 2020 04:41:01 +0530 Subject: [PATCH 2/2] Use WebViewClientCompat in ReCaptchaActivity. --- .../org/schabi/newpipe/ReCaptchaActivity.java | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java b/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java index dfe062a16..463fc24ac 100644 --- a/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java +++ b/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java @@ -8,18 +8,16 @@ import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.webkit.CookieManager; -import android.webkit.WebResourceRequest; import android.webkit.WebSettings; import android.webkit.WebView; -import android.webkit.WebViewClient; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.annotation.RequiresApi; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.NavUtils; import androidx.preference.PreferenceManager; +import androidx.webkit.WebViewClientCompat; import org.schabi.newpipe.databinding.ActivityRecaptchaBinding; import org.schabi.newpipe.util.ThemeHelper; @@ -83,20 +81,7 @@ public class ReCaptchaActivity extends AppCompatActivity { webSettings.setJavaScriptEnabled(true); webSettings.setUserAgentString(DownloaderImpl.USER_AGENT); - recaptchaBinding.reCaptchaWebView.setWebViewClient(new WebViewClient() { - @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) - @Override - public boolean shouldOverrideUrlLoading(final WebView view, - final WebResourceRequest request) { - final String url = request.getUrl().toString(); - if (MainActivity.DEBUG) { - Log.d(TAG, "shouldOverrideUrlLoading: request.url=" + url); - } - - handleCookiesFromUrl(url); - return false; - } - + recaptchaBinding.reCaptchaWebView.setWebViewClient(new WebViewClientCompat() { @Override public boolean shouldOverrideUrlLoading(final WebView view, final String url) { if (MainActivity.DEBUG) {