Merge branch 'dev' into saf-workarround
This commit is contained in:
commit
c01609b858
5 changed files with 35 additions and 16 deletions
|
@ -57,7 +57,7 @@ dependencies {
|
||||||
exclude module: 'support-annotations'
|
exclude module: 'support-annotations'
|
||||||
})
|
})
|
||||||
|
|
||||||
implementation 'com.github.TeamNewPipe:NewPipeExtractor:5f65788a2f89e'
|
implementation 'com.github.Stypox:NewPipeExtractor:06689a2f27edfe83bd4605a1cceed86c06a5ebf8'
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
testImplementation 'org.mockito:mockito-core:2.23.0'
|
testImplementation 'org.mockito:mockito-core:2.23.0'
|
||||||
|
|
|
@ -164,7 +164,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
||||||
final ResponseBody body = response.body();
|
final ResponseBody body = response.body();
|
||||||
|
|
||||||
if (response.code() == 429) {
|
if (response.code() == 429) {
|
||||||
throw new ReCaptchaException("reCaptcha Challenge requested");
|
throw new ReCaptchaException("reCaptcha Challenge requested", siteUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
|
@ -214,7 +214,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
||||||
final ResponseBody body = response.body();
|
final ResponseBody body = response.body();
|
||||||
|
|
||||||
if (response.code() == 429) {
|
if (response.code() == 429) {
|
||||||
throw new ReCaptchaException("reCaptcha Challenge requested");
|
throw new ReCaptchaException("reCaptcha Challenge requested", siteUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
|
@ -268,7 +268,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
||||||
final ResponseBody body = response.body();
|
final ResponseBody body = response.body();
|
||||||
|
|
||||||
if (response.code() == 429) {
|
if (response.code() == 429) {
|
||||||
throw new ReCaptchaException("reCaptcha Challenge requested");
|
throw new ReCaptchaException("reCaptcha Challenge requested", siteUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
|
|
|
@ -37,15 +37,24 @@ import android.webkit.WebViewClient;
|
||||||
*/
|
*/
|
||||||
public class ReCaptchaActivity extends AppCompatActivity {
|
public class ReCaptchaActivity extends AppCompatActivity {
|
||||||
public static final int RECAPTCHA_REQUEST = 10;
|
public static final int RECAPTCHA_REQUEST = 10;
|
||||||
|
public static final String RECAPTCHA_URL_EXTRA = "recaptcha_url_extra";
|
||||||
|
|
||||||
public static final String TAG = ReCaptchaActivity.class.toString();
|
public static final String TAG = ReCaptchaActivity.class.toString();
|
||||||
public static final String YT_URL = "https://www.youtube.com";
|
public static final String YT_URL = "https://www.youtube.com";
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_recaptcha);
|
setContentView(R.layout.activity_recaptcha);
|
||||||
|
|
||||||
|
url = getIntent().getStringExtra(RECAPTCHA_URL_EXTRA);
|
||||||
|
if (url == null || url.isEmpty()) {
|
||||||
|
url = YT_URL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set return to Cancel by default
|
// Set return to Cancel by default
|
||||||
setResult(RESULT_CANCELED);
|
setResult(RESULT_CANCELED);
|
||||||
|
|
||||||
|
@ -73,15 +82,12 @@ public class ReCaptchaActivity extends AppCompatActivity {
|
||||||
myWebView.clearHistory();
|
myWebView.clearHistory();
|
||||||
android.webkit.CookieManager cookieManager = CookieManager.getInstance();
|
android.webkit.CookieManager cookieManager = CookieManager.getInstance();
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
cookieManager.removeAllCookies(new ValueCallback<Boolean>() {
|
cookieManager.removeAllCookies(aBoolean -> {});
|
||||||
@Override
|
|
||||||
public void onReceiveValue(Boolean aBoolean) {}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
cookieManager.removeAllCookie();
|
cookieManager.removeAllCookie();
|
||||||
}
|
}
|
||||||
|
|
||||||
myWebView.loadUrl(YT_URL);
|
myWebView.loadUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ReCaptchaWebViewClient extends WebViewClient {
|
private class ReCaptchaWebViewClient extends WebViewClient {
|
||||||
|
|
|
@ -180,7 +180,7 @@ public abstract class BaseStateFragment<I> extends BaseFragment implements ViewC
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exception instanceof ReCaptchaException) {
|
if (exception instanceof ReCaptchaException) {
|
||||||
onReCaptchaException();
|
onReCaptchaException((ReCaptchaException) exception);
|
||||||
return true;
|
return true;
|
||||||
} else if (exception instanceof IOException) {
|
} else if (exception instanceof IOException) {
|
||||||
showError(getString(R.string.network_error), true);
|
showError(getString(R.string.network_error), true);
|
||||||
|
@ -190,11 +190,13 @@ public abstract class BaseStateFragment<I> extends BaseFragment implements ViewC
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReCaptchaException() {
|
public void onReCaptchaException(ReCaptchaException exception) {
|
||||||
if (DEBUG) Log.d(TAG, "onReCaptchaException() called");
|
if (DEBUG) Log.d(TAG, "onReCaptchaException() called");
|
||||||
Toast.makeText(activity, R.string.recaptcha_request_toast, Toast.LENGTH_LONG).show();
|
Toast.makeText(activity, R.string.recaptcha_request_toast, Toast.LENGTH_LONG).show();
|
||||||
// Starting ReCaptcha Challenge Activity
|
// Starting ReCaptcha Challenge Activity
|
||||||
startActivityForResult(new Intent(activity, ReCaptchaActivity.class), ReCaptchaActivity.RECAPTCHA_REQUEST);
|
Intent intent = new Intent(activity, ReCaptchaActivity.class);
|
||||||
|
intent.putExtra(ReCaptchaActivity.RECAPTCHA_URL_EXTRA, exception.getUrl());
|
||||||
|
startActivityForResult(intent, ReCaptchaActivity.RECAPTCHA_REQUEST);
|
||||||
|
|
||||||
showError(getString(R.string.recaptcha_request_toast), false);
|
showError(getString(R.string.recaptcha_request_toast), false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,27 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="?attr/actionBarSize"
|
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
|
||||||
|
app:popupTheme="@style/ThemeOverlay.AppCompat.ActionBar"
|
||||||
|
app:titleTextAppearance="@style/Toolbar.Title">
|
||||||
|
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
<WebView
|
<WebView
|
||||||
android:id="@+id/reCaptchaWebView"
|
android:id="@+id/reCaptchaWebView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="?attr/actionBarSize"/>
|
android:layout_marginTop="?attr/actionBarSize"/>
|
||||||
|
|
||||||
<include layout="@layout/toolbar_layout"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
Loading…
Reference in a new issue