Skip to content

Commit

Permalink
Use user agent of DownloaderImpl also in ReCapthaActivity
Browse files Browse the repository at this point in the history
Does not contain device info and should also fix some issues about recaptchas not showing up
  • Loading branch information
Stypox committed Dec 18, 2020
1 parent 96862cb commit aacb1f4
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ protected void onCreate(final Bundle savedInstanceState) {
// 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)
Expand Down Expand Up @@ -120,8 +121,7 @@ public void onPageFinished(final WebView view, final String url) {
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();
}
Expand Down Expand Up @@ -150,14 +150,11 @@ public void onBackPressed() {

@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() {
Expand Down

0 comments on commit aacb1f4

Please sign in to comment.