From 2bdc849c2ba505d944f2b81fc02245fba9fbf204 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Tue, 30 Jul 2013 15:03:25 -0700 Subject: [PATCH] CB-3819: Implemented Feature --- framework/src/org/apache/cordova/Config.java | 4 ++ .../org/apache/cordova/CordovaActivity.java | 65 +++++++++++++------ .../org/apache/cordova/CordovaWebView.java | 1 + 3 files changed, 50 insertions(+), 20 deletions(-) diff --git a/framework/src/org/apache/cordova/Config.java b/framework/src/org/apache/cordova/Config.java index 51f8f3f8..716b7952 100644 --- a/framework/src/org/apache/cordova/Config.java +++ b/framework/src/org/apache/cordova/Config.java @@ -136,6 +136,10 @@ public class Config { int value = xml.getAttributeIntValue(null, "value", 20000); action.getIntent().putExtra(name, value); } + else if(name.equalsIgnoreCase("SplashScreenDelay")) { + int value = xml.getAttributeIntValue(null, "value", 3000); + action.getIntent().putExtra(name, value); + } else if(name.equalsIgnoreCase("KeepRunning")) { boolean value = xml.getAttributeValue(null, "value").equals("true"); diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index 685424c4..82d97c91 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -391,6 +391,16 @@ public class CordovaActivity extends Activity implements CordovaInterface { this.init(); } + this.splashscreenTime = this.getIntegerProperty("SplashScreenDelay", this.splashscreenTime); + if(this.splashscreenTime > 0) + { + this.splashscreen = this.getIntegerProperty("SplashScreen", 0); + if(this.splashscreen != 0) + { + this.showSplashScreen(this.splashscreenTime); + } + } + // Set backgroundColor this.backgroundColor = this.getIntegerProperty("BackgroundColor", Color.BLACK); this.root.setBackgroundColor(this.backgroundColor); @@ -401,9 +411,43 @@ public class CordovaActivity extends Activity implements CordovaInterface { // Then load the spinner this.loadSpinner(); - this.appView.loadUrl(url); + //Load the correct splashscreen + + if(this.splashscreen != 0) + { + this.appView.loadUrl(url, this.splashscreenTime); + } + else + { + this.appView.loadUrl(url); + } } + /** + * Load the url into the webview after waiting for period of time. + * This is used to display the splashscreen for certain amount of time. + * + * @param url + * @param time The number of ms to wait before loading webview + */ + public void loadUrl(final String url, int time) { + + this.splashscreenTime = time; + this.loadUrl(url); + + /* + // Init web view if not already done + if (this.appView == null) { + this.init(); + } + + this.splashscreenTime = time; + this.splashscreen = this.getIntegerProperty("SplashScreen", 0); + this.showSplashScreen(this.splashscreenTime); + this.appView.loadUrl(url, time); + */ + } + /* * Load the spinner */ @@ -437,25 +481,6 @@ public class CordovaActivity extends Activity implements CordovaInterface { } } - /** - * Load the url into the webview after waiting for period of time. - * This is used to display the splashscreen for certain amount of time. - * - * @param url - * @param time The number of ms to wait before loading webview - */ - public void loadUrl(final String url, int time) { - - // Init web view if not already done - if (this.appView == null) { - this.init(); - } - - this.splashscreenTime = time; - this.splashscreen = this.getIntegerProperty("SplashScreen", 0); - this.showSplashScreen(this.splashscreenTime); - this.appView.loadUrl(url, time); - } /** * Cancel loadUrl before it has been loaded. diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index 45d39cea..f798794c 100755 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -23,6 +23,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; +import java.util.Locale; import org.apache.cordova.Config; import org.apache.cordova.CordovaInterface;