Working on CB-585

This commit is contained in:
Joe Bowser 2012-05-04 11:18:19 -07:00
parent f4cf2cecb5
commit 480e5ca4d1
4 changed files with 19 additions and 5 deletions

View File

@ -30,7 +30,7 @@
<!-- <access origin=".*"/> Allow all domains, suggested development use only -->
<log level="DEBUG"/>
<preference name="useWebkitHistory" value="false" />
<preference name="useBrowserHistory" value="false" />
</cordova>

View File

@ -47,6 +47,8 @@ public class CordovaWebView extends WebView {
String baseUrl;
private Stack<String> urls = new Stack<String>();
boolean useBrowserHistory = false;
protected int loadUrlTimeout;
protected long loadUrlTimeoutValue;
@ -304,7 +306,8 @@ public class CordovaWebView extends WebView {
}
pluginManager.init();
this.urls.push(url);
if(!useBrowserHistory)
this.urls.push(url);
}
}
@ -315,7 +318,8 @@ public class CordovaWebView extends WebView {
public void loadUrl(final String url, final int time)
{
// If not first page of app, then load immediately
if (this.urls.size() > 0) {
// Add support for browser history if we use it.
if (this.urls.size() > 0 || this.canGoBack()) {
this.loadUrl(url);
}

View File

@ -152,7 +152,11 @@ 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.
// Our app continues to run. When BACK is pressed, our app is redisplayed.
if (url.startsWith("file://") || url.indexOf(appView.baseUrl) == 0 || appView.isUrlWhiteListed(url)) {
appView.loadUrl(url);
//This will fix iFrames
if(appView.useBrowserHistory)
return false;
else
appView.loadUrl(url);
}
// If not our application, let default viewer handle

View File

@ -203,7 +203,10 @@ public class DroidGap extends Activity implements CordovaInterface {
// If true, then the JavaScript and native code continue to run in the background
// when another application (activity) is started.
protected boolean keepRunning = true;
// Store the useBrowserHistory preference until we actually need it.
private boolean useBrowserHistory = false;
// preferences read from cordova.xml
protected PreferenceSet preferences;
@ -225,6 +228,8 @@ public class DroidGap extends Activity implements CordovaInterface {
if (preferences.prefMatches("fullscreen","true")) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else if(preferences.prefMatches("useBrowserHistory", "true")) {
useBrowserHistory = true;
} else {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
@ -286,6 +291,7 @@ public class DroidGap extends Activity implements CordovaInterface {
// Add web view but make it invisible while loading URL
this.appView.setVisibility(View.INVISIBLE);
this.appView.useBrowserHistory = useBrowserHistory;
root.addView(this.appView);
setContentView(root);