Skip to content

Commit

Permalink
Merge pull request #5215 from Stypox/recaptcha-user-agent
Browse files Browse the repository at this point in the history
Use user agent of DownloaderImpl also in ReCapthaActivity
  • Loading branch information
TobiGr authored Dec 18, 2020
2 parents 96862cb + aacb1f4 commit a919a03
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 a919a03

Please sign in to comment.