From 363b1429e39515a4b11269a14439c7228dfd9b73 Mon Sep 17 00:00:00 2001 From: macdonst Date: Mon, 13 Feb 2012 18:41:06 -0500 Subject: [PATCH] Fix issue with document.location.href not calling loadUrlIntoView Now we peek at the history and add the url the stack if loadUrlIntoView is not being called. --- .../apache/cordova/CordovaWebViewClient.java | 15 +++++-- .../src/org/apache/cordova/DroidGap.java | 44 +++++++++++-------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java index a5e57455..a44d23ea 100755 --- a/framework/src/org/apache/cordova/CordovaWebViewClient.java +++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java @@ -183,9 +183,6 @@ public class CordovaWebViewClient extends WebViewClient { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { - Log.d("CordovaWebViewClient", "I got a page started for = " + url); - Log.d("CordovaWebViewClient", "can go back " + view.canGoBack()); - // Clear history so history.back() doesn't do anything. // So we can reinit() native side CallbackServer & PluginManager. view.clearHistory(); @@ -200,7 +197,6 @@ public class CordovaWebViewClient extends WebViewClient { */ @Override public void onPageFinished(WebView view, String url) { - Log.d("CordovaWebViewClient", "I got a page finished for = " + url); super.onPageFinished(view, url); /** @@ -296,4 +292,15 @@ public class CordovaWebViewClient extends WebViewClient { super.onReceivedSslError(view, handler, error); } } + + @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.ctx.peekAtUrlStack().equals(url)) { + this.ctx.pushUrl(url); + } + } } diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java index 2bc6c38e..8dc9fd7a 100755 --- a/framework/src/org/apache/cordova/DroidGap.java +++ b/framework/src/org/apache/cordova/DroidGap.java @@ -33,8 +33,6 @@ import org.apache.cordova.api.IPlugin; import org.apache.cordova.api.LOG; import org.apache.cordova.api.CordovaInterface; import org.apache.cordova.api.PluginManager; -import org.json.JSONArray; -import org.json.JSONException; import org.xmlpull.v1.XmlPullParserException; import android.app.Activity; @@ -43,17 +41,12 @@ import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.content.res.XmlResourceParser; import android.database.Cursor; -import android.graphics.Bitmap; import android.graphics.Color; import android.media.AudioManager; import android.net.Uri; -import android.net.http.SslError; import android.os.Bundle; import android.util.Log; import android.view.Display; @@ -64,19 +57,10 @@ import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; -import android.webkit.ConsoleMessage; -import android.webkit.GeolocationPermissions.Callback; -import android.webkit.HttpAuthHandler; -import android.webkit.JsPromptResult; -import android.webkit.JsResult; -import android.webkit.SslErrorHandler; -import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebSettings.LayoutAlgorithm; -import android.webkit.WebStorage; import android.webkit.WebView; import android.webkit.WebViewClient; -import android.widget.EditText; import android.widget.LinearLayout; @@ -229,8 +213,6 @@ public class DroidGap extends Activity implements CordovaInterface { // preferences read from cordova.xml protected PreferenceSet preferences; - private boolean classicRender; - /** * Sets the authentication token. * @@ -1370,7 +1352,31 @@ public class DroidGap extends Activity implements CordovaInterface { } return false; } - + + /* + * URL stack manipulators + */ + + /** + * Returns the top url on the stack without removing it from + * the stack. + */ + public String peekAtUrlStack() { + if (urls.size() > 0) { + return urls.peek(); + } + return ""; + } + + /** + * Add a url to the stack + * + * @param url + */ + public void pushUrl(String url) { + urls.push(url); + } + /* * Hook in DroidGap for menu plugins *