janpio closed pull request #245: CB-13641: (windows) support transparent splash 
screen background color.
URL: https://github.com/apache/cordova-windows/pull/245
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/cordova-js-src/splashscreen.js b/cordova-js-src/splashscreen.js
index 99b60d9f..97fd86cd 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 b412c0f7..3d9d4140 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;
             }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to