-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fix beforeload for Android <= 7 #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Most of the work is thanks to @caioinova. They figured out solution in #386. |
|
Any update on merging this PR? Facing the same issue. @RGTK |
wvengen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this change! getWebViewClient() was indeed added in API level 26.
src/android/InAppBrowser.java
Outdated
| @Override | ||
| public void run() { | ||
| ((InAppBrowserClient)inAppWebView.getWebViewClient()).waitForBeforeload = false; | ||
| if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.N_MR1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O, since the Android docs mention "added in API level 26".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better indeed. Done.
| if(beforeload.equals("yes") | ||
| if (beforeload.equals("yes") && method == null) { | ||
| useBeforeload = true; | ||
| }else if(beforeload.equals("yes") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean method can be null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, For Android 6 and below shouldOverrideUrlLoading(WebView webView, String url) is called which calls shouldOverrideUrlLoading(String url, String method) with null as 2nd argument due to lack of possibility of deducing HTTP method from bare URL.
wvengen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
|
|
|
@digistorm This PR handles yes/no values and is tested. Feel free to create another PR if you'd find it valuable. |
|
@wvengen Could it be merged then? |
wvengen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, afaik this can be merged!
|
@purplecabbage Would you find time to merge it? |
Platforms affected
Android
Motivation and Context
On Android <= 7, using
beforeloadwould crash the application due to change of Android API.Fixes #386
Description
If device is running Android <= 7,
Testing
I ran it on Android 7 and 9, create
WebViewClientinstead of trying on relying onWebView#getWebViewClient()which is not available in these versions.Checklist
(platform)if this change only applies to one platform (e.g.(android)) Already made a commit without such prefix. Squashing it during merge should solve the issue.