mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 20:33:07 +08:00
Working on CB-585
This commit is contained in:
parent
f4cf2cecb5
commit
480e5ca4d1
@ -30,7 +30,7 @@
|
|||||||
<!-- <access origin=".*"/> Allow all domains, suggested development use only -->
|
<!-- <access origin=".*"/> Allow all domains, suggested development use only -->
|
||||||
|
|
||||||
<log level="DEBUG"/>
|
<log level="DEBUG"/>
|
||||||
<preference name="useWebkitHistory" value="false" />
|
<preference name="useBrowserHistory" value="false" />
|
||||||
</cordova>
|
</cordova>
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ public class CordovaWebView extends WebView {
|
|||||||
String baseUrl;
|
String baseUrl;
|
||||||
private Stack<String> urls = new Stack<String>();
|
private Stack<String> urls = new Stack<String>();
|
||||||
|
|
||||||
|
boolean useBrowserHistory = false;
|
||||||
|
|
||||||
protected int loadUrlTimeout;
|
protected int loadUrlTimeout;
|
||||||
|
|
||||||
protected long loadUrlTimeoutValue;
|
protected long loadUrlTimeoutValue;
|
||||||
@ -304,6 +306,7 @@ public class CordovaWebView extends WebView {
|
|||||||
}
|
}
|
||||||
pluginManager.init();
|
pluginManager.init();
|
||||||
|
|
||||||
|
if(!useBrowserHistory)
|
||||||
this.urls.push(url);
|
this.urls.push(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +318,8 @@ public class CordovaWebView extends WebView {
|
|||||||
public void loadUrl(final String url, final int time)
|
public void loadUrl(final String url, final int time)
|
||||||
{
|
{
|
||||||
// If not first page of app, then load immediately
|
// 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);
|
this.loadUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +152,10 @@ 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.indexOf(appView.baseUrl) == 0 || appView.isUrlWhiteListed(url)) {
|
if (url.startsWith("file://") || url.indexOf(appView.baseUrl) == 0 || appView.isUrlWhiteListed(url)) {
|
||||||
|
//This will fix iFrames
|
||||||
|
if(appView.useBrowserHistory)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
appView.loadUrl(url);
|
appView.loadUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +204,9 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|||||||
// when another application (activity) is started.
|
// when another application (activity) is started.
|
||||||
protected boolean keepRunning = true;
|
protected boolean keepRunning = true;
|
||||||
|
|
||||||
|
// Store the useBrowserHistory preference until we actually need it.
|
||||||
|
private boolean useBrowserHistory = false;
|
||||||
|
|
||||||
// preferences read from cordova.xml
|
// preferences read from cordova.xml
|
||||||
protected PreferenceSet preferences;
|
protected PreferenceSet preferences;
|
||||||
|
|
||||||
@ -225,6 +228,8 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|||||||
if (preferences.prefMatches("fullscreen","true")) {
|
if (preferences.prefMatches("fullscreen","true")) {
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
} else if(preferences.prefMatches("useBrowserHistory", "true")) {
|
||||||
|
useBrowserHistory = true;
|
||||||
} else {
|
} else {
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
|
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
|
||||||
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
|
// Add web view but make it invisible while loading URL
|
||||||
this.appView.setVisibility(View.INVISIBLE);
|
this.appView.setVisibility(View.INVISIBLE);
|
||||||
|
this.appView.useBrowserHistory = useBrowserHistory;
|
||||||
root.addView(this.appView);
|
root.addView(this.appView);
|
||||||
setContentView(root);
|
setContentView(root);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user