You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by da...@apache.org on 2016/09/21 14:03:43 UTC

cordova-windows git commit: CB-11836 Allow setting of 'ForegroundText' property via config.xml

Repository: cordova-windows
Updated Branches:
  refs/heads/master 72c9e6a75 -> 10796b28a


CB-11836 Allow setting of 'ForegroundText' property via config.xml

Github: close #195


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

Branch: refs/heads/master
Commit: 10796b28a5bf4c0963b4f2eee1e63909ab215686
Parents: 72c9e6a
Author: Steffen Schaffert <sc...@itc.rwth-aachen.de>
Authored: Wed Sep 21 16:27:58 2016 +0300
Committer: daserge <v-...@microsoft.com>
Committed: Wed Sep 21 16:31:15 2016 +0300

----------------------------------------------------------------------
 spec/unit/AppxManifest.spec.js       | 25 +++++++++++++++++++++++++
 template/cordova/lib/AppxManifest.js | 13 +++++++++++++
 template/cordova/lib/prepare.js      |  1 +
 3 files changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/10796b28/spec/unit/AppxManifest.spec.js
----------------------------------------------------------------------
diff --git a/spec/unit/AppxManifest.spec.js b/spec/unit/AppxManifest.spec.js
index 0da7afa..a2c4bb5 100644
--- a/spec/unit/AppxManifest.spec.js
+++ b/spec/unit/AppxManifest.spec.js
@@ -187,6 +187,31 @@ describe('AppxManifest', function () {
         it('refineColor should leave CSS color name as is', function () {
             expect(refineColor(CSS_COLOR_NAME)).toEqual(CSS_COLOR_NAME);
         });
+
+        it('setForegroundText should change the ForegroundText property on non-Windows 10 platforms', function () {
+            var visualElementsWindows = AppxManifest.get(WINDOWS_MANIFEST).getVisualElements();
+            var visualElementsWindows10 = AppxManifest.get(WINDOWS_10_MANIFEST).getVisualElements();
+
+            var foregroundTextLight = 'light';
+            var foregroundTextDark = 'dark';
+            var foregroundTextDefault = foregroundTextLight;
+
+            // Set to 'light'
+            visualElementsWindows.setForegroundText(foregroundTextLight);
+            expect(visualElementsWindows.getForegroundText()).toEqual(foregroundTextLight);
+
+            // Set to 'dark'
+            visualElementsWindows.setForegroundText(foregroundTextDark);
+            expect(visualElementsWindows.getForegroundText()).toEqual(foregroundTextDark);
+
+            // Simulate removal of preference, should change back to default vlaue 'light'
+            visualElementsWindows.setForegroundText(undefined);
+            expect(visualElementsWindows.getForegroundText()).toEqual(foregroundTextDefault);
+
+            // Returns nothing on Windows 10
+            visualElementsWindows10.setForegroundText(foregroundTextLight);
+            expect(visualElementsWindows10.getForegroundText()).toEqual(undefined);
+        });
     });
 });
 

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/10796b28/template/cordova/lib/AppxManifest.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/AppxManifest.js b/template/cordova/lib/AppxManifest.js
index db59cf1..6973d13 100644
--- a/template/cordova/lib/AppxManifest.js
+++ b/template/cordova/lib/AppxManifest.js
@@ -385,6 +385,15 @@ AppxManifest.prototype.getVisualElements = function () {
                 return this.setBackgroundColor(color);
             } catch (e) { return this; }
         },
+        getForegroundText: function () {
+            return visualElements.attrib.ForegroundText;
+        },
+        setForegroundText: function (color) {
+            // If color is not set, fall back to 'light' by default
+            visualElements.attrib.ForegroundText = color || 'light';
+
+            return this;
+        },
         getSplashBackgroundColor: function () {
             var splashNode = visualElements.find('./' + self.prefix + 'SplashScreen');
             return splashNode && splashNode.attrib.BackgroundColor;
@@ -590,6 +599,10 @@ Win10AppxManifest.prototype.getVisualElements = function () {
     result.getToastCapable = function () {};
     result.setToastCapable = function () { return this; };
 
+    // ForegroundText was removed in Windows 10 as well
+    result.getForegroundText = function () {};
+    result.setForegroundText = function () { return this; };
+
     return result;
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/10796b28/template/cordova/lib/prepare.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/prepare.js b/template/cordova/lib/prepare.js
index 53838d5..31cef52 100644
--- a/template/cordova/lib/prepare.js
+++ b/template/cordova/lib/prepare.js
@@ -131,6 +131,7 @@ function updateManifestFile (config, manifestPath) {
     // Apply background color, splashscreen background color, etc.
     manifest.getVisualElements()
         .trySetBackgroundColor(config.getPreference('BackgroundColor'))
+        .setForegroundText(config.getPreference('ForegroundText'))
         .setSplashBackgroundColor(config.getPreference('SplashScreenBackgroundColor'))
         .setToastCapable(config.getPreference('WindowsToastCapable'))
         .setOrientation(config.getPreference('Orientation'));


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