cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dase...@apache.org
Subject cordova-windows git commit: CB-12238 [Windows] Colorize titlebar to match splash bg color
Date Tue, 20 Dec 2016 12:00:38 GMT
Repository: cordova-windows
Updated Branches:
  refs/heads/master b021dc303 -> 1cf27a9db


CB-12238 [Windows] Colorize titlebar to match splash bg color


Project: http://git-wip-us.apache.org/repos/asf/cordova-windows/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-windows/commit/1cf27a9d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-windows/tree/1cf27a9d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-windows/diff/1cf27a9d

Branch: refs/heads/master
Commit: 1cf27a9db5fa103228b803539ce5ede52e524aee
Parents: b021dc3
Author: daserge <v-seshak@microsoft.com>
Authored: Tue Dec 13 15:34:42 2016 +0300
Committer: daserge <v-seshak@microsoft.com>
Committed: Mon Dec 19 18:01:33 2016 +0300

----------------------------------------------------------------------
 cordova-js-src/splashscreen.js | 33 +++++++++++++++++++++++++++++++++
 template/www/cordova.js        | 35 ++++++++++++++++++++++++++++++++++-
 2 files changed, 67 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/1cf27a9d/cordova-js-src/splashscreen.js
----------------------------------------------------------------------
diff --git a/cordova-js-src/splashscreen.js b/cordova-js-src/splashscreen.js
index 4dac1e0..6fe918b 100644
--- a/cordova-js-src/splashscreen.js
+++ b/cordova-js-src/splashscreen.js
@@ -43,6 +43,8 @@ var DEFAULT_SPLASHSCREEN_DURATION = 3000, // in milliseconds
     PROGRESSRING_BOTTOM_MARGIN = 10; // needed for windows 10 min height window
 
 var bgColor = "#464646",
+    titleInitialBgColor,
+    titleBgColor,
     autoHideSplashScreen = true,
     splashScreenDelay = DEFAULT_SPLASHSCREEN_DURATION,
     fadeSplashScreen = true,
@@ -73,6 +75,13 @@ function readPreferencesFromCfg(cfg, manifest) {
             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;
 
@@ -200,9 +209,30 @@ function exitFullScreen() {
     }
 }
 
+// Make title bg color match splashscreen bg color
+function colorizeTitleBar() {
+    var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
+    if (appView.titleBar) {
+        titleInitialBgColor = appView.titleBar.backgroundColor;
+
+        appView.titleBar.backgroundColor = titleBgColor;
+        appView.titleBar.buttonBackgroundColor = titleBgColor;
+    }
+}
+
+// Revert title bg color
+function revertTitleBarColor() {
+    var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
+    if (appView.titleBar) {
+        appView.titleBar.backgroundColor = titleInitialBgColor;
+        appView.titleBar.buttonBackgroundColor = titleInitialBgColor;
+    }
+}
+
 // Displays the extended splash screen. Pass the splash screen object retrieved during activation.
 function show() {
     enterFullScreen();
+    colorizeTitleBar();
     disableUserInteraction();
     positionControls();
 
@@ -276,6 +306,9 @@ function hide() {
             exitFullScreen();
         }
 
+        // Color reversion before fading is over looks better:
+        revertTitleBarColor();
+
         // https://issues.apache.org/jira/browse/CB-11751
         // This can occur when we directly replace whole document.body f.e. in a router.
         // Note that you should disable the splashscreen in this case or update a container
element instead.

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/1cf27a9d/template/www/cordova.js
----------------------------------------------------------------------
diff --git a/template/www/cordova.js b/template/www/cordova.js
index 1efa105..4cfb998 100644
--- a/template/www/cordova.js
+++ b/template/www/cordova.js
@@ -1908,6 +1908,8 @@ var DEFAULT_SPLASHSCREEN_DURATION = 3000, // in milliseconds
     PROGRESSRING_BOTTOM_MARGIN = 10; // needed for windows 10 min height window
 
 var bgColor = "#464646",
+    titleInitialBgColor,
+    titleBgColor,
     autoHideSplashScreen = true,
     splashScreenDelay = DEFAULT_SPLASHSCREEN_DURATION,
     fadeSplashScreen = true,
@@ -1938,6 +1940,13 @@ function readPreferencesFromCfg(cfg, manifest) {
             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;
 
@@ -2010,7 +2019,7 @@ function init(config, manifest) {
 
     if (isWp81) {
         extendedSplashProgress.classList.add('extended-splash-progress-phone');
-    } else if (isWp10) {   
+    } else if (isWp10) {
         extendedSplashProgress.classList.add('extended-splash-progress-wp10');
     } else {
         extendedSplashProgress.classList.add('extended-splash-progress-desktop');
@@ -2065,9 +2074,30 @@ function exitFullScreen() {
     }
 }
 
+// Make title bg color match splashscreen bg color
+function colorizeTitleBar() {
+    var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
+    if (appView.titleBar) {
+        titleInitialBgColor = appView.titleBar.backgroundColor;
+
+        appView.titleBar.backgroundColor = titleBgColor;
+        appView.titleBar.buttonBackgroundColor = titleBgColor;
+    }
+}
+
+// Revert title bg color
+function revertTitleBarColor() {
+    var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
+    if (appView.titleBar) {
+        appView.titleBar.backgroundColor = titleInitialBgColor;
+        appView.titleBar.buttonBackgroundColor = titleInitialBgColor;
+    }
+}
+
 // Displays the extended splash screen. Pass the splash screen object retrieved during activation.
 function show() {
     enterFullScreen();
+    colorizeTitleBar();
     disableUserInteraction();
     positionControls();
 
@@ -2141,6 +2171,9 @@ function hide() {
             exitFullScreen();
         }
 
+        // Color reversion before fading is over looks better:
+        revertTitleBarColor();
+
         // https://issues.apache.org/jira/browse/CB-11751
         // This can occur when we directly replace whole document.body f.e. in a router.
         // Note that you should disable the splashscreen in this case or update a container
element instead.


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


Mime
View raw message