Skip to content

webview: flush cookies & improve shouldOverrideUrlLoading #2424

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

Merged
merged 1 commit into from
Mar 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import android.webkit.WebViewClient;
import android.webkit.WebView;
import android.webkit.CookieManager;
import android.net.Uri;

import org.renpy.android.ResourceManager;
Expand Down Expand Up @@ -165,16 +166,21 @@ public void onClick(DialogInterface dialog,int id) {
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Uri u = Uri.parse(url);
if (mOpenExternalLinksInBrowser) {
if (!(url.startsWith("file:") || url.startsWith("http://127.0.0.1:"))) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
if (!(u.getScheme().equals("file") || u.getHost().equals("127.0.0.1"))) {
Intent i = new Intent(Intent.ACTION_VIEW, u);
startActivity(i);
return true;
}
}
view.loadUrl(url);
return false;
}

@Override
public void onPageFinished(WebView view, String url) {
CookieManager.getInstance().flush();
}
});
mLayout = new AbsoluteLayout(PythonActivity.mActivity);
mLayout.addView(mWebView);
Expand Down