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.
This commit is contained in:
macdonst 2012-02-13 18:41:06 -05:00
parent 900ff9ed2c
commit 363b1429e3
2 changed files with 36 additions and 23 deletions

View File

@ -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);
}
}
}

View File

@ -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
*