forked from github/cordova-android
CB-2198: Removing option to use our broken URL stack as a history as per deprecation policy.
This commit is contained in:
parent
fb81f3e77e
commit
5d68d5a246
@ -75,12 +75,8 @@ public class CordovaWebView extends WebView {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private CordovaChromeClient chromeClient;
|
private CordovaChromeClient chromeClient;
|
||||||
|
|
||||||
//This is for the polyfill history
|
|
||||||
private String url;
|
private String url;
|
||||||
String baseUrl;
|
String baseUrl;
|
||||||
private Stack<String> urls = new Stack<String>();
|
|
||||||
|
|
||||||
boolean useBrowserHistory = true;
|
|
||||||
|
|
||||||
// Flag to track that a loadUrl timeout occurred
|
// Flag to track that a loadUrl timeout occurred
|
||||||
int loadUrlTimeout = 0;
|
int loadUrlTimeout = 0;
|
||||||
@ -370,7 +366,7 @@ public class CordovaWebView extends WebView {
|
|||||||
String initUrl = this.getProperty("url", null);
|
String initUrl = this.getProperty("url", null);
|
||||||
|
|
||||||
// If first page of app, then set URL to load to be the one passed in
|
// If first page of app, then set URL to load to be the one passed in
|
||||||
if (initUrl == null || (this.urls.size() > 0)) {
|
if (initUrl == null) {
|
||||||
this.loadUrlIntoView(url);
|
this.loadUrlIntoView(url);
|
||||||
}
|
}
|
||||||
// Otherwise use the URL specified in the activity's extras bundle
|
// Otherwise use the URL specified in the activity's extras bundle
|
||||||
@ -391,7 +387,7 @@ public class CordovaWebView extends WebView {
|
|||||||
String initUrl = this.getProperty("url", null);
|
String initUrl = this.getProperty("url", null);
|
||||||
|
|
||||||
// If first page of app, then set URL to load to be the one passed in
|
// If first page of app, then set URL to load to be the one passed in
|
||||||
if (initUrl == null || (this.urls.size() > 0)) {
|
if (initUrl == null) {
|
||||||
this.loadUrlIntoView(url, time);
|
this.loadUrlIntoView(url, time);
|
||||||
}
|
}
|
||||||
// Otherwise use the URL specified in the activity's extras bundle
|
// Otherwise use the URL specified in the activity's extras bundle
|
||||||
@ -419,10 +415,6 @@ public class CordovaWebView extends WebView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.pluginManager.init();
|
this.pluginManager.init();
|
||||||
|
|
||||||
if (!this.useBrowserHistory) {
|
|
||||||
this.urls.push(url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a timeout timer for loadUrl
|
// Create a timeout timer for loadUrl
|
||||||
@ -494,7 +486,7 @@ public class CordovaWebView extends WebView {
|
|||||||
|
|
||||||
// If not first page of app, then load immediately
|
// If not first page of app, then load immediately
|
||||||
// Add support for browser history if we use it.
|
// Add support for browser history if we use it.
|
||||||
if ((url.startsWith("javascript:")) || this.urls.size() > 0 || this.canGoBack()) {
|
if ((url.startsWith("javascript:")) || this.canGoBack()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If first page, then show splashscreen
|
// If first page, then show splashscreen
|
||||||
@ -542,25 +534,6 @@ public class CordovaWebView extends WebView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the top url on the stack without removing it from
|
|
||||||
* the stack.
|
|
||||||
*/
|
|
||||||
public String peekAtUrlStack() {
|
|
||||||
if (this.urls.size() > 0) {
|
|
||||||
return this.urls.peek();
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a url to the stack
|
|
||||||
*
|
|
||||||
* @param url
|
|
||||||
*/
|
|
||||||
public void pushUrl(String url) {
|
|
||||||
this.urls.push(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Go to previous page in history. (We manage our own history)
|
* Go to previous page in history. (We manage our own history)
|
||||||
@ -571,37 +544,15 @@ public class CordovaWebView extends WebView {
|
|||||||
|
|
||||||
// Check webview first to see if there is a history
|
// Check webview first to see if there is a history
|
||||||
// This is needed to support curPage#diffLink, since they are added to appView's history, but not our history url array (JQMobile behavior)
|
// This is needed to support curPage#diffLink, since they are added to appView's history, but not our history url array (JQMobile behavior)
|
||||||
if (super.canGoBack() && this.useBrowserHistory) {
|
if (super.canGoBack()) {
|
||||||
printBackForwardList();
|
printBackForwardList();
|
||||||
super.goBack();
|
super.goBack();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// If our managed history has prev url
|
|
||||||
else if (this.urls.size() > 1 && !this.useBrowserHistory) {
|
|
||||||
this.urls.pop(); // Pop current url
|
|
||||||
String url = this.urls.pop(); // Pop prev url that we want to load, since it will be added back by loadUrl()
|
|
||||||
this.loadUrl(url);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if there is a history item.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean canGoBack() {
|
|
||||||
if (super.canGoBack() && this.useBrowserHistory) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (this.urls.size() > 1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the specified URL in the Cordova webview or a new browser instance.
|
* Load the specified URL in the Cordova webview or a new browser instance.
|
||||||
@ -627,12 +578,6 @@ public class CordovaWebView extends WebView {
|
|||||||
// Make sure url is in whitelist
|
// Make sure url is in whitelist
|
||||||
if (url.startsWith("file://") || url.indexOf(this.baseUrl) == 0 || Config.isUrlWhiteListed(url)) {
|
if (url.startsWith("file://") || url.indexOf(this.baseUrl) == 0 || Config.isUrlWhiteListed(url)) {
|
||||||
// TODO: What about params?
|
// TODO: What about params?
|
||||||
|
|
||||||
// Clear out current url from history, since it will be replacing it
|
|
||||||
if (clearHistory) {
|
|
||||||
this.urls.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load new URL
|
// Load new URL
|
||||||
this.loadUrl(url);
|
this.loadUrl(url);
|
||||||
}
|
}
|
||||||
@ -669,13 +614,6 @@ public class CordovaWebView extends WebView {
|
|||||||
* <log level="DEBUG" />
|
* <log level="DEBUG" />
|
||||||
*/
|
*/
|
||||||
private void loadConfiguration() {
|
private void loadConfiguration() {
|
||||||
// Config has already been loaded, and it stores these preferences on the Intent.
|
|
||||||
if("false".equals(this.getProperty("useBrowserHistory", "true")))
|
|
||||||
{
|
|
||||||
//Switch back to the old browser history and state the six month policy
|
|
||||||
this.useBrowserHistory = false;
|
|
||||||
Log.w(TAG, "useBrowserHistory=false is deprecated as of Cordova 2.2.0 and will be removed six months after the 2.2.0 release. Please use the browser history and use history.back().");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("true".equals(this.getProperty("fullscreen", "false"))) {
|
if ("true".equals(this.getProperty("fullscreen", "false"))) {
|
||||||
this.cordova.getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
this.cordova.getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||||
@ -729,13 +667,7 @@ public class CordovaWebView extends WebView {
|
|||||||
}
|
}
|
||||||
else if(keyCode == KeyEvent.KEYCODE_BACK)
|
else if(keyCode == KeyEvent.KEYCODE_BACK)
|
||||||
{
|
{
|
||||||
//Because exit is fired on the keyDown and not the key up on Android 4.x
|
return !(this.startOfHistory()) || this.bound;
|
||||||
//we need to check for this.
|
|
||||||
//Also, I really wished "canGoBack" worked!
|
|
||||||
if(this.useBrowserHistory)
|
|
||||||
return !(this.startOfHistory()) || this.bound;
|
|
||||||
else
|
|
||||||
return this.urls.size() > 1 || this.bound;
|
|
||||||
}
|
}
|
||||||
else if(keyCode == KeyEvent.KEYCODE_MENU)
|
else if(keyCode == KeyEvent.KEYCODE_MENU)
|
||||||
{
|
{
|
||||||
|
@ -193,11 +193,7 @@ public class CordovaWebViewClient extends WebViewClient {
|
|||||||
// If our app or file:, then load into a new Cordova webview container by starting a new instance of our activity.
|
// If our app or file:, then load into a new Cordova webview container by starting a new instance of our activity.
|
||||||
// Our app continues to run. When BACK is pressed, our app is redisplayed.
|
// Our app continues to run. When BACK is pressed, our app is redisplayed.
|
||||||
if (url.startsWith("file://") || url.startsWith("data:") || url.indexOf(this.appView.baseUrl) == 0 || Config.isUrlWhiteListed(url)) {
|
if (url.startsWith("file://") || url.startsWith("data:") || url.indexOf(this.appView.baseUrl) == 0 || Config.isUrlWhiteListed(url)) {
|
||||||
//This will fix iFrames
|
return false;
|
||||||
if (appView.useBrowserHistory || url.startsWith("data:"))
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
this.appView.loadUrl(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not our application, let default viewer handle
|
// If not our application, let default viewer handle
|
||||||
@ -248,12 +244,6 @@ public class CordovaWebViewClient extends WebViewClient {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
||||||
// Clear history so history.back() doesn't do anything.
|
|
||||||
// So we can reinit() native side CallbackServer & PluginManager.
|
|
||||||
if (!this.appView.useBrowserHistory) {
|
|
||||||
view.clearHistory();
|
|
||||||
this.doClearHistory = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Flush stale messages.
|
// Flush stale messages.
|
||||||
this.appView.jsMessageQueue.reset();
|
this.appView.jsMessageQueue.reset();
|
||||||
@ -392,23 +382,6 @@ public class CordovaWebViewClient extends WebViewClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Notify the host application to update its visited links database.
|
|
||||||
*
|
|
||||||
* @param view The WebView that is initiating the callback.
|
|
||||||
* @param url The url being visited.
|
|
||||||
* @param isReload True if this url is being reloaded.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
|
|
||||||
/*
|
|
||||||
* If you do a document.location.href the url does not get pushed on the stack
|
|
||||||
* so we do a check here to see if the url should be pushed.
|
|
||||||
*/
|
|
||||||
if (!this.appView.peekAtUrlStack().equals(url)) {
|
|
||||||
this.appView.pushUrl(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the authentication token.
|
* Sets the authentication token.
|
||||||
|
Loading…
Reference in New Issue
Block a user