Skip to content
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

fix: dirty fix SystemWebViewEngine by using history.back instead of g… #1321

Open
wants to merge 1 commit into
base: ci/connectedAndroidTest
Choose a base branch
from
Open
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
fix: dirty fix SystemWebViewEngine by using history.back instead of g…
…oBack for SDK30
  • Loading branch information
knight9999 committed Aug 12, 2021
commit d88b61033e132dd5f2c90f256eed11c18f97f3c1
18 changes: 14 additions & 4 deletions framework/src/org/apache/cordova/engine/SystemWebViewEngine.java
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ Licensed to the Apache Software Foundation (ASF) under one
import android.os.Build;
import android.view.View;
import android.webkit.ValueCallback;
import android.webkit.WebBackForwardList;
import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebView;
@@ -278,11 +279,20 @@ public boolean canGoBack() {
public boolean goBack() {
// Check webview first to see if there is a history
// This is needed to support curPage#diffLink, since they are added to parentEngine's history, but not our history url array (JQMobile behavior)
if (webView.canGoBack()) {
webView.goBack();
return true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
WebBackForwardList list = webView.copyBackForwardList();
if (list.getCurrentIndex() > 0) {
parentWebView.sendJavascript("history.back();");
return true;
}
return false;
} else {
if (webView.canGoBack()) {
webView.goBack();
return true;
}
return false;
}
return false;
}

@Override