From aacb1f46a80d9dce55ab4d216279f4dbc205cbc0 Mon Sep 17 00:00:00 2001 From: Stypox Date: Fri, 18 Dec 2020 18:36:40 +0100 Subject: [PATCH] Use user agent of DownloaderImpl also in ReCapthaActivity Does not contain device info and should also fix some issues about recaptchas not showing up --- .../org/schabi/newpipe/ReCaptchaActivity.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java b/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java index 03c9ae4af..b6f65c355 100644 --- a/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java +++ b/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java @@ -83,6 +83,7 @@ public class ReCaptchaActivity extends AppCompatActivity { // enable Javascript final WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); + webSettings.setUserAgentString(DownloaderImpl.USER_AGENT); webView.setWebViewClient(new WebViewClient() { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @@ -120,8 +121,7 @@ public class ReCaptchaActivity extends AppCompatActivity { webView.clearHistory(); final android.webkit.CookieManager cookieManager = CookieManager.getInstance(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - cookieManager.removeAllCookies(aBoolean -> { - }); + cookieManager.removeAllCookies(value -> { }); } else { cookieManager.removeAllCookie(); } @@ -150,14 +150,11 @@ public class ReCaptchaActivity extends AppCompatActivity { @Override public boolean onOptionsItemSelected(final MenuItem item) { - final int id = item.getItemId(); - switch (id) { - case R.id.menu_item_done: - saveCookiesAndFinish(); - return true; - default: - return false; + if (item.getItemId() == R.id.menu_item_done) { + saveCookiesAndFinish(); + return true; } + return false; } private void saveCookiesAndFinish() {