You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ja...@apache.org on 2018/01/19 17:08:18 UTC

[cordova-windows] branch master updated: CB-13641: support transparent splash screen background color. (#245)

This is an automated email from the ASF dual-hosted git repository.

janpio pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-windows.git


The following commit(s) were added to refs/heads/master by this push:
     new c288357  CB-13641: support transparent splash screen background color. (#245)
c288357 is described below

commit c288357b1e3e098472f99805c0d350db1e63a542
Author: IndieSW <In...@users.noreply.github.com>
AuthorDate: Fri Jan 19 11:08:16 2018 -0600

    CB-13641: support transparent splash screen background color. (#245)
---
 cordova-js-src/splashscreen.js | 31 ++++++++++++++++++-------------
 template/www/cordova.js        | 31 ++++++++++++++++++-------------
 2 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/cordova-js-src/splashscreen.js b/cordova-js-src/splashscreen.js
index 99b60d9..97fd86c 100644
--- a/cordova-js-src/splashscreen.js
+++ b/cordova-js-src/splashscreen.js
@@ -43,6 +43,7 @@ var DEFAULT_SPLASHSCREEN_DURATION = 3000, // in milliseconds
     PROGRESSRING_BOTTOM_MARGIN = 10; // needed for windows 10 min height window
 
 var bgColor = "#464646",
+    isBgColorTransparent = false,
     titleInitialBgColor,
     titleBgColor,
     autoHideSplashScreen = true,
@@ -69,18 +70,22 @@ function readPreferencesFromCfg(cfg, manifest) {
         splashImageSrc = schema + ':///' + manifest.getSplashScreenImagePath().replace(/\\/g, '/');
 
         bgColor = cfg.getPreferenceValue('SplashScreenBackgroundColor') || bgColor;
-        bgColor = bgColor.replace('0x', '#').replace('0X', '#');
-        if (bgColor.length > 7) {
-            // Remove aplha
-            bgColor = bgColor.slice(0, 1) + bgColor.slice(3, bgColor.length);
-        }
+        bgColor = bgColor.toLowerCase().replace('0x', '#');
+        isBgColorTransparent = (bgColor === 'transparent');
+
+        if (!isBgColorTransparent) {
+            if (bgColor.length > 7) {
+                // Remove alpha
+                bgColor = bgColor.slice(0, 1) + bgColor.slice(3, bgColor.length);
+            }
 
-        titleBgColor = {
-            a: 255,
-            r: parseInt(bgColor.slice(1, 3), 16),
-            g: parseInt(bgColor.slice(3, 5), 16),
-            b: parseInt(bgColor.slice(5, 7), 16)
-        };
+            titleBgColor = {
+                a: 255,
+                r: parseInt(bgColor.slice(1, 3), 16),
+                g: parseInt(bgColor.slice(3, 5), 16),
+                b: parseInt(bgColor.slice(5, 7), 16)
+            };
+        }
 
         autoHideSplashScreen = readBoolFromCfg('AutoHideSplashScreen', autoHideSplashScreen, cfg);
         splashScreenDelay = cfg.getPreferenceValue('SplashScreenDelay') || splashScreenDelay;
@@ -212,7 +217,7 @@ function exitFullScreen() {
 // Make title bg color match splashscreen bg color
 function colorizeTitleBar() {
     var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
-    if (isWin10UWP) {
+    if (isWin10UWP && !isBgColorTransparent) {
         titleInitialBgColor = appView.titleBar.backgroundColor;
 
         appView.titleBar.backgroundColor = titleBgColor;
@@ -223,7 +228,7 @@ function colorizeTitleBar() {
 // Revert title bg color
 function revertTitleBarColor() {
     var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
-    if (isWin10UWP) {
+    if (isWin10UWP && !isBgColorTransparent) {
         appView.titleBar.backgroundColor = titleInitialBgColor;
         appView.titleBar.buttonBackgroundColor = titleInitialBgColor;
     }
diff --git a/template/www/cordova.js b/template/www/cordova.js
index b412c0f..3d9d414 100644
--- a/template/www/cordova.js
+++ b/template/www/cordova.js
@@ -1879,6 +1879,7 @@
         var PROGRESSRING_BOTTOM_MARGIN = 10; // needed for windows 10 min height window
 
         var bgColor = '#464646';
+        var isBgColorTransparent = false;
         var titleInitialBgColor;
         var titleBgColor;
         var autoHideSplashScreen = true;
@@ -1905,18 +1906,22 @@
                 splashImageSrc = schema + ':///' + manifest.getSplashScreenImagePath().replace(/\\/g, '/');
 
                 bgColor = cfg.getPreferenceValue('SplashScreenBackgroundColor') || bgColor;
-                bgColor = bgColor.replace('0x', '#').replace('0X', '#');
-                if (bgColor.length > 7) {
-                    // Remove aplha
-                    bgColor = bgColor.slice(0, 1) + bgColor.slice(3, bgColor.length);
-                }
+                bgColor = bgColor.toLowerCase().replace('0x', '#');
+                isBgColorTransparent = (bgColor === 'transparent');
 
-                titleBgColor = {
-                    a: 255,
-                    r: parseInt(bgColor.slice(1, 3), 16),
-                    g: parseInt(bgColor.slice(3, 5), 16),
-                    b: parseInt(bgColor.slice(5, 7), 16)
-                };
+                if (!isBgColorTransparent) {
+                    if (bgColor.length > 7) {
+                        // Remove alpha
+                        bgColor = bgColor.slice(0, 1) + bgColor.slice(3, bgColor.length);
+                    }
+
+                    titleBgColor = {
+                        a: 255,
+                        r: parseInt(bgColor.slice(1, 3), 16),
+                        g: parseInt(bgColor.slice(3, 5), 16),
+                        b: parseInt(bgColor.slice(5, 7), 16)
+                    };
+                }
 
                 autoHideSplashScreen = readBoolFromCfg('AutoHideSplashScreen', autoHideSplashScreen, cfg);
                 splashScreenDelay = cfg.getPreferenceValue('SplashScreenDelay') || splashScreenDelay;
@@ -2048,7 +2053,7 @@
         // Make title bg color match splashscreen bg color
         function colorizeTitleBar () {
             var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
-            if (isWin10UWP) {
+            if (isWin10UWP && !isBgColorTransparent) {
                 titleInitialBgColor = appView.titleBar.backgroundColor;
 
                 appView.titleBar.backgroundColor = titleBgColor;
@@ -2059,7 +2064,7 @@
         // Revert title bg color
         function revertTitleBarColor () {
             var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
-            if (isWin10UWP) {
+            if (isWin10UWP && !isBgColorTransparent) {
                 appView.titleBar.backgroundColor = titleInitialBgColor;
                 appView.titleBar.buttonBackgroundColor = titleInitialBgColor;
             }

-- 
To stop receiving notification emails like this one, please contact
['"commits@cordova.apache.org" <co...@cordova.apache.org>'].

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org