mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-11 00:00:05 +08:00
Working on CB-585
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user