You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2013/05/14 06:15:26 UTC

[19/50] [abbrv] webworks commit: Added SplashScreen plugin

Added SplashScreen plugin

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/991e4fdb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/991e4fdb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/991e4fdb

Branch: refs/heads/master
Commit: 991e4fdb71e4c38a4d413b7a7c7862d5b7886602
Parents: 860544e
Author: Rosa Tse <rt...@blackberry.com>
Authored: Wed Apr 10 23:38:22 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:30 2013 -0400

----------------------------------------------------------------------
 .../templates/project/cordova/lib/config-parser.js |    7 +-
 .../project/plugins/SplashScreen/index.js          |   28 +++++
 .../bin/test/plugins/SplashScreen/index.js         |   82 +++++++++++++++
 blackberry10/framework/lib/webview.js              |   11 ++-
 4 files changed, 123 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/991e4fdb/blackberry10/bin/templates/project/cordova/lib/config-parser.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/config-parser.js b/blackberry10/bin/templates/project/cordova/lib/config-parser.js
index 2282a81..15d6281 100644
--- a/blackberry10/bin/templates/project/cordova/lib/config-parser.js
+++ b/blackberry10/bin/templates/project/cordova/lib/config-parser.js
@@ -516,9 +516,10 @@ function processNameAndDescription(data, widgetConfig) {
 }
 
 function processCordovaPreferences(data, widgetConfig) {
-    if (data.preferences) {
-        var preferences = processParamObj(data.preferences);
-        widgetConfig.packageCordovaJs = preferences.packageCordovaJs === "enable";
+    if (data.preference) {
+        var preference = processParamObj(data.preference);
+        widgetConfig.packageCordovaJs = preference.packageCordovaJs === "enable";
+        widgetConfig.autoHideSplashScreen = preference.AutoHideSplashScreen !== "false";
     }
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/991e4fdb/blackberry10/bin/templates/project/plugins/SplashScreen/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/SplashScreen/index.js b/blackberry10/bin/templates/project/plugins/SplashScreen/index.js
new file mode 100644
index 0000000..bd7e48c
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/SplashScreen/index.js
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2013 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+module.exports = {
+    show: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        result.error("Not supported on platform", false);
+    },
+
+    hide: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        window.qnx.webplatform.getApplication().windowVisible = true;
+        result.ok(undefined, false);
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/991e4fdb/blackberry10/bin/test/plugins/SplashScreen/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/SplashScreen/index.js b/blackberry10/bin/test/plugins/SplashScreen/index.js
new file mode 100644
index 0000000..1dcccee
--- /dev/null
+++ b/blackberry10/bin/test/plugins/SplashScreen/index.js
@@ -0,0 +1,82 @@
+/*
+* Copyright 2013 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+describe("SplashScreen", function () {
+    var _apiDir = __dirname + "./../../../templates/project/plugins/SplashScreen/",
+        index,
+        mockedEnv = {
+            response: {
+                send: jasmine.createSpy()
+            }
+        },
+        mockedApplication = {
+            windowVisible: undefined
+        };
+
+    beforeEach(function () {
+        index = require(_apiDir + "index");
+        mockedEnv.response.send.reset();
+    });
+
+    afterEach(function () {
+        index = null;
+        delete require.cache[require.resolve(_apiDir + "index")];
+    });
+    describe("show", function () {
+        beforeEach(function () {
+            GLOBAL.PluginResult = function (args, env) {};
+            GLOBAL.PluginResult.prototype.error = jasmine.createSpy();
+        });
+
+        afterEach(function () {
+            delete GLOBAL.PluginResult;
+        });
+
+        it("calls PluginResult.error if show is called", function () {
+            index.show();
+
+            expect(PluginResult.prototype.error).toHaveBeenCalledWith("Not supported on platform", false);
+        });
+    });
+
+    describe("hide", function () {
+        beforeEach(function () {
+            GLOBAL.window = {
+                qnx: {
+                    webplatform: {
+                        getApplication: function () {
+                            return mockedApplication;
+                        }
+                    }
+                }
+            };
+
+            GLOBAL.PluginResult = function (args, env) {};
+            GLOBAL.PluginResult.prototype.ok = jasmine.createSpy();
+        });
+
+        afterEach(function () {
+            delete GLOBAL.window;
+            delete GLOBAL.PluginResult;
+        });
+
+        it("calls PluginResult.ok if hide is called", function () {
+            index.hide();
+
+            expect(mockedApplication.windowVisible).toBeTruthy();
+            expect(PluginResult.prototype.ok).toHaveBeenCalledWith(undefined, false);
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/991e4fdb/blackberry10/framework/lib/webview.js
----------------------------------------------------------------------
diff --git a/blackberry10/framework/lib/webview.js b/blackberry10/framework/lib/webview.js
index 690fd1c..495dfbe 100644
--- a/blackberry10/framework/lib/webview.js
+++ b/blackberry10/framework/lib/webview.js
@@ -58,7 +58,12 @@ webview =
             _webviewObj.allowWebEvent("DialogRequested");
 
             _webviewObj.addEventListener("DocumentLoadFinished", function () {
-                window.qnx.webplatform.getApplication().windowVisible = true;
+                // show app window if auto hide splash screen is true, OR splash screen is not specified
+                // if auto hide is set to false explicitly but no splash screen is specified, should still show app window
+                // otherwise the app cannot be launched
+                if (config.autoHideSplashScreen || !config["rim:splash"]) {
+                    window.qnx.webplatform.getApplication().windowVisible = true;
+                }
             });
 
 
@@ -70,7 +75,9 @@ webview =
 
             // If content is not loaded, too bad open the visibility up.
             setTimeout(function () {
-                window.qnx.webplatform.getApplication().windowVisible = true;
+                if (config.autoHideSplashScreen || !config["rim:splash"]) {
+                    window.qnx.webplatform.getApplication().windowVisible = true;
+                }
             }, 2500);
         });