You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/03/11 23:27:33 UTC

[1/5] git commit: moved named color resolving to JS so platforms can just worry about hex values

Repository: cordova-plugins
Updated Branches:
  refs/heads/master 6d954c0b9 -> 2c4701802


moved named color resolving to JS so platforms can just worry about hex values


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugins/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugins/commit/80af194e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugins/tree/80af194e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugins/diff/80af194e

Branch: refs/heads/master
Commit: 80af194ef5f89cb9359fad2c908ccf1ddfaea0c6
Parents: 6d954c0
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Mar 6 17:40:01 2014 -0800
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Mar 6 17:40:01 2014 -0800

----------------------------------------------------------------------
 statusbar/www/statusbar.js | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/80af194e/statusbar/www/statusbar.js
----------------------------------------------------------------------
diff --git a/statusbar/www/statusbar.js b/statusbar/www/statusbar.js
index 04b894b..9fee988 100644
--- a/statusbar/www/statusbar.js
+++ b/statusbar/www/statusbar.js
@@ -23,6 +23,23 @@ var argscheck = require('cordova/argscheck'),
     utils = require('cordova/utils'),
     exec = require('cordova/exec');
 
+var namedColors = {
+    "black":"#000000", 
+    "darkGray":"#A9A9A9", 
+    "lightGray":"#D3D3D3", 
+    "white":"#FFFFFF", 
+    "gray":"#808080", 
+    "red":"#FF0000", 
+    "green":"#00FF00", 
+    "blue":"#0000FF", 
+    "cyan":"#00FFFF", 
+    "yellow":"#FFFF00", 
+    "magenta":"#FF00FF", 
+    "orange":"##FFA500", 
+    "purple":"#800080", 
+    "brown":"#A52A2A"
+};
+
 // prime it
 exec(null, null, "StatusBar", "_ready", []);
 
@@ -50,7 +67,7 @@ StatusBar.styleBlackOpaque = function() {
 };
 
 StatusBar.backgroundColorByName = function(colorname) {
-    exec(null, null, "StatusBar", "backgroundColorByName", [colorname]);
+    return StatusBar.backgroundColorByHexString(namedColors[colorname]);
 }
 
 StatusBar.backgroundColorByHexString = function(hexString) {


[4/5] git commit: Store updated value of isVisible when we call show/hide. Use callback to set initial isVisible value for _ready

Posted by pu...@apache.org.
Store updated value of isVisible when we call show/hide. Use callback to set initial isVisible value for _ready


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugins/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugins/commit/35740b8b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugins/tree/35740b8b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugins/diff/35740b8b

Branch: refs/heads/master
Commit: 35740b8b4dfc9c7a68e88815e01aa64b527b21b3
Parents: ee959cb
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Mar 11 15:22:54 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Mar 11 15:22:54 2014 -0700

----------------------------------------------------------------------
 statusbar/www/statusbar.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/35740b8b/statusbar/www/statusbar.js
----------------------------------------------------------------------
diff --git a/statusbar/www/statusbar.js b/statusbar/www/statusbar.js
index 0dcf30e..dc456a9 100644
--- a/statusbar/www/statusbar.js
+++ b/statusbar/www/statusbar.js
@@ -41,7 +41,10 @@
     };
 
     // prime it
-    exec(null, null, "StatusBar", "_ready", []);
+    
+    exec(function (res) {
+        StatusBar.isVisible = res;
+    }, null, "StatusBar", "_ready", []);
 
     var StatusBar = function () {
     };
@@ -89,10 +92,12 @@
 
     StatusBar.hide = function () {
         exec(null, null, "StatusBar", "hide", []);
+        StatusBar.isVisible = false;
     }
 
     StatusBar.show = function () {
         exec(null, null, "StatusBar", "show", []);
+        StatusBar.isVisible = true;
     }
 
     StatusBar.isVisible = true;


[3/5] git commit: Added Windows Phone support

Posted by pu...@apache.org.
Added Windows Phone support


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

Branch: refs/heads/master
Commit: ee959cb1a69bf58fe06cf08ffd9d6ba2e51940da
Parents: 20c73cf
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Mar 11 14:25:15 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Mar 11 14:25:15 2014 -0700

----------------------------------------------------------------------
 statusbar/plugin.xml          |  20 ++++++
 statusbar/src/wp/StatusBar.cs | 142 +++++++++++++++++++++++++++++++++++++
 2 files changed, 162 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/ee959cb1/statusbar/plugin.xml
----------------------------------------------------------------------
diff --git a/statusbar/plugin.xml b/statusbar/plugin.xml
index ff462fa..6a6c59b 100644
--- a/statusbar/plugin.xml
+++ b/statusbar/plugin.xml
@@ -44,4 +44,24 @@
         
     </platform>
 
+    <!-- wp7 -->
+    <platform name="wp7">
+        <config-file target="config.xml" parent="/*">
+            <feature name="StatusBar">
+                <param name="wp-package" value="StatusBar"/>
+            </feature>
+        </config-file>
+        <source-file src="src/wp/StatusBar.cs" />
+    </platform>
+
+    <!-- wp8 -->
+    <platform name="wp8">
+        <config-file target="config.xml" parent="/*">
+            <feature name="StatusBar">
+                <param name="wp-package" value="StatusBar"/>
+            </feature>
+        </config-file>
+        <source-file src="src/wp/StatusBar.cs" />
+    </platform>
+
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/ee959cb1/statusbar/src/wp/StatusBar.cs
----------------------------------------------------------------------
diff --git a/statusbar/src/wp/StatusBar.cs b/statusbar/src/wp/StatusBar.cs
new file mode 100644
index 0000000..c6e6fe7
--- /dev/null
+++ b/statusbar/src/wp/StatusBar.cs
@@ -0,0 +1,142 @@
+/*  
+	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.
+*/
+
+
+using Microsoft.Phone.Shell;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Globalization;
+using System.Threading;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Threading;
+
+
+/*
+ *   http://www.idev101.com/code/User_Interface/StatusBar.html
+ *   https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/Bars.html
+ *   https://developer.apple.com/library/ios/documentation/uikit/reference/UIApplication_Class/Reference/Reference.html#//apple_ref/c/econst/UIStatusBarStyleDefault
+ * */
+
+
+namespace WPCordovaClassLib.Cordova.Commands
+{
+    public class StatusBar : BaseCommand
+    {
+
+        // returns an argb value, if the hex is only rgb, it will be full opacity
+        protected Color ColorFromHex(string hexString)
+        {
+            string cleanHex = hexString.Replace("#", "").Replace("0x", "");
+            // turn #FFF into #FFFFFF
+            if (cleanHex.Length == 3)
+            {
+                cleanHex = "" + cleanHex[0] + cleanHex[0] + cleanHex[1] + cleanHex[1] + cleanHex[2] + cleanHex[2];
+            }
+            // add an alpha 100% if it is missing
+            if (cleanHex.Length == 6)
+            {
+                cleanHex = "FF" + cleanHex;
+            }
+            int argb = Int32.Parse(cleanHex, NumberStyles.HexNumber);
+            Color clr = Color.FromArgb((byte)((argb & 0xff000000) >> 0x18),
+                              (byte)((argb & 0xff0000) >> 0x10),
+                              (byte)((argb & 0xff00) >> 8),
+                              (byte)(argb & 0xff));
+            return clr;
+        }
+
+        public void _ready(string options)
+        {
+            Deployment.Current.Dispatcher.BeginInvoke(() =>
+            {
+                bool isVis = SystemTray.IsVisible;
+                // TODO: pass this to JS
+            });
+        }
+
+        public void overlaysWebView(string options)
+        {    //exec(null, null, "StatusBar", "overlaysWebView", [doOverlay]);
+             // string arg = JSON.JsonHelper.Deserialize<string[]>(options)[0];
+        }
+
+        public void styleDefault(string options)
+        {    //exec(null, null, "StatusBar", "styleDefault", []);
+            Deployment.Current.Dispatcher.BeginInvoke(() =>
+            {
+                SystemTray.Opacity = 1.0d;
+                SystemTray.ForegroundColor = (Color)Application.Current.Resources["PhoneForegroundColor"];
+                SystemTray.BackgroundColor = (Color)Application.Current.Resources["PhoneChromeColor"];
+            });
+        }
+
+        public void styleLightContent(string options)
+        {    //exec(null, null, "StatusBar", "styleLightContent", []);
+            Deployment.Current.Dispatcher.BeginInvoke(() =>
+            {
+                SystemTray.Opacity = 1.0d;
+                SystemTray.ForegroundColor = SystemColors.ControlLightColor;
+                SystemTray.BackgroundColor = SystemColors.ControlDarkColor;
+            });
+        }
+
+        public void styleBlackTranslucent(string options)
+        {    //exec(null, null, "StatusBar", "styleBlackTranslucent", []);
+            styleLightContent(options);
+        }
+
+        public void styleBlackOpaque(string options)
+        {    //exec(null, null, "StatusBar", "styleBlackOpaque", []);
+            styleLightContent(options);
+        }
+
+        public void backgroundColorByName(string options)
+        {    //exec(null, null, "StatusBar", "backgroundColorByName", [colorname]);
+
+        }
+
+        public void backgroundColorByHexString(string options)
+        {    //exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
+            string argb = JSON.JsonHelper.Deserialize<string[]>(options)[0];
+
+            Color clr = ColorFromHex(argb);
+              
+            Deployment.Current.Dispatcher.BeginInvoke(() =>
+            {
+                SystemTray.Opacity = clr.A / 255.0d;
+                SystemTray.BackgroundColor = clr;
+                
+            });
+        }
+
+        public void hide(string options)
+        {    //exec(null, null, "StatusBar", "hide", []);
+            Deployment.Current.Dispatcher.BeginInvoke(() =>
+            {
+                SystemTray.IsVisible = false;
+            });
+
+        }
+
+        public void show(string options)
+        {    //exec(null, null, "StatusBar", "show", []);
+            Deployment.Current.Dispatcher.BeginInvoke(() =>
+            {
+                SystemTray.IsVisible = true;
+            });
+        }
+	}
+}
\ No newline at end of file


[2/5] git commit: support shorthand css color values like #F3D and sanity check for leading octothorp

Posted by pu...@apache.org.
support shorthand css color values like #F3D and sanity check for leading octothorp


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugins/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugins/commit/20c73cf2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugins/tree/20c73cf2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugins/diff/20c73cf2

Branch: refs/heads/master
Commit: 20c73cf23ed6c60d6e52a495e2d04b889190af51
Parents: 80af194
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Mar 11 14:23:13 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Mar 11 14:23:13 2014 -0700

----------------------------------------------------------------------
 statusbar/www/statusbar.js | 185 +++++++++++++++++++++-------------------
 1 file changed, 99 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/20c73cf2/statusbar/www/statusbar.js
----------------------------------------------------------------------
diff --git a/statusbar/www/statusbar.js b/statusbar/www/statusbar.js
index 9fee988..0dcf30e 100644
--- a/statusbar/www/statusbar.js
+++ b/statusbar/www/statusbar.js
@@ -1,87 +1,100 @@
 /*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- *
-*/
-
-var argscheck = require('cordova/argscheck'),
-    utils = require('cordova/utils'),
-    exec = require('cordova/exec');
-
-var namedColors = {
-    "black":"#000000", 
-    "darkGray":"#A9A9A9", 
-    "lightGray":"#D3D3D3", 
-    "white":"#FFFFFF", 
-    "gray":"#808080", 
-    "red":"#FF0000", 
-    "green":"#00FF00", 
-    "blue":"#0000FF", 
-    "cyan":"#00FFFF", 
-    "yellow":"#FFFF00", 
-    "magenta":"#FF00FF", 
-    "orange":"##FFA500", 
-    "purple":"#800080", 
-    "brown":"#A52A2A"
-};
-
-// prime it
-exec(null, null, "StatusBar", "_ready", []);
-
-var StatusBar = function() {
-};
-
-StatusBar.overlaysWebView = function(doOverlay) {
-    exec(null, null, "StatusBar", "overlaysWebView", [doOverlay]);
-};
-
-StatusBar.styleDefault = function() {
-    exec(null, null, "StatusBar", "styleDefault", []);
-};
-
-StatusBar.styleLightContent = function() {
-    exec(null, null, "StatusBar", "styleLightContent", []);
-};
-
-StatusBar.styleBlackTranslucent = function() {
-    exec(null, null, "StatusBar", "styleBlackTranslucent", []);
-};
-
-StatusBar.styleBlackOpaque = function() {
-    exec(null, null, "StatusBar", "styleBlackOpaque", []);
-};
-
-StatusBar.backgroundColorByName = function(colorname) {
-    return StatusBar.backgroundColorByHexString(namedColors[colorname]);
-}
-
-StatusBar.backgroundColorByHexString = function(hexString) {
-    exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
-}
-
-StatusBar.hide = function() {
-    exec(null, null, "StatusBar", "hide", []);
-}
-
-StatusBar.show = function() {
-    exec(null, null, "StatusBar", "show", []);
-}
-
-StatusBar.isVisible = true;
-
-module.exports = StatusBar;
+     *
+     * Licensed to the Apache Software Foundation (ASF) under one
+     * or more contributor license agreements.  See the NOTICE file
+     * distributed with this work for additional information
+     * regarding copyright ownership.  The ASF licenses this file
+     * to you 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.
+     *
+    */
+
+    var argscheck = require('cordova/argscheck'),
+        utils = require('cordova/utils'),
+        exec = require('cordova/exec');
+
+    var namedColors = {
+        "black": "#000000",
+        "darkGray": "#A9A9A9",
+        "lightGray": "#D3D3D3",
+        "white": "#FFFFFF",
+        "gray": "#808080",
+        "red": "#FF0000",
+        "green": "#00FF00",
+        "blue": "#0000FF",
+        "cyan": "#00FFFF",
+        "yellow": "#FFFF00",
+        "magenta": "#FF00FF",
+        "orange": "##FFA500",
+        "purple": "#800080",
+        "brown": "#A52A2A"
+    };
+
+    // prime it
+    exec(null, null, "StatusBar", "_ready", []);
+
+    var StatusBar = function () {
+    };
+
+    StatusBar.overlaysWebView = function (doOverlay) {
+        exec(null, null, "StatusBar", "overlaysWebView", [doOverlay]);
+    };
+
+    StatusBar.styleDefault = function () {
+        // dark text on a light background
+        exec(null, null, "StatusBar", "styleDefault", []);
+    };
+
+    StatusBar.styleLightContent = function () {
+        // light text on a dark background
+        exec(null, null, "StatusBar", "styleLightContent", []);
+    };
+
+    StatusBar.styleBlackTranslucent = function () {
+        // #88000000 ? Apple says to use lightContent instead
+        exec(null, null, "StatusBar", "styleBlackTranslucent", []);
+    };
+
+    StatusBar.styleBlackOpaque = function () {
+        // #FF000000 ? Apple says to use lightContent instead
+        exec(null, null, "StatusBar", "styleBlackOpaque", []);
+    };
+
+    StatusBar.backgroundColorByName = function (colorname) {
+        return StatusBar.backgroundColorByHexString(namedColors[colorname]);
+    }
+
+    StatusBar.backgroundColorByHexString = function (hexString) {
+        if (hexString.indexOf("#") < 0) {
+            hexString = "#" + hexString;
+        }
+
+        if (hexString.length == 4) {
+            var split = hexString.split("");
+            hexString = "#" + hexString[1] + hexString[1] + hexString[2] + hexString[2] + hexString[3] + hexString[3];
+        }
+
+        exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
+    }
+
+    StatusBar.hide = function () {
+        exec(null, null, "StatusBar", "hide", []);
+    }
+
+    StatusBar.show = function () {
+        exec(null, null, "StatusBar", "show", []);
+    }
+
+    StatusBar.isVisible = true;
+
+    module.exports = StatusBar;


[5/5] git commit: lightContent always sets BG to black, default always sets BG to white

Posted by pu...@apache.org.
lightContent always sets BG to black, default always sets BG to white


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugins/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugins/commit/2c470180
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugins/tree/2c470180
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugins/diff/2c470180

Branch: refs/heads/master
Commit: 2c47018023b3fb544bcbd33845018458ea653e95
Parents: 35740b8
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Mar 11 15:24:18 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Mar 11 15:24:18 2014 -0700

----------------------------------------------------------------------
 statusbar/src/wp/StatusBar.cs | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/2c470180/statusbar/src/wp/StatusBar.cs
----------------------------------------------------------------------
diff --git a/statusbar/src/wp/StatusBar.cs b/statusbar/src/wp/StatusBar.cs
index c6e6fe7..c20f680 100644
--- a/statusbar/src/wp/StatusBar.cs
+++ b/statusbar/src/wp/StatusBar.cs
@@ -65,6 +65,8 @@ namespace WPCordovaClassLib.Cordova.Commands
             {
                 bool isVis = SystemTray.IsVisible;
                 // TODO: pass this to JS
+                //Debug.WriteLine("Result::" + res);
+                DispatchCommandResult(new PluginResult(PluginResult.Status.OK, isVis));
             });
         }
 
@@ -77,19 +79,21 @@ namespace WPCordovaClassLib.Cordova.Commands
         {    //exec(null, null, "StatusBar", "styleDefault", []);
             Deployment.Current.Dispatcher.BeginInvoke(() =>
             {
+                SystemTray.BackgroundColor = Colors.White;
+                SystemTray.ForegroundColor = Colors.Black;
                 SystemTray.Opacity = 1.0d;
-                SystemTray.ForegroundColor = (Color)Application.Current.Resources["PhoneForegroundColor"];
-                SystemTray.BackgroundColor = (Color)Application.Current.Resources["PhoneChromeColor"];
+
             });
         }
 
         public void styleLightContent(string options)
         {    //exec(null, null, "StatusBar", "styleLightContent", []);
+            
             Deployment.Current.Dispatcher.BeginInvoke(() =>
             {
+                SystemTray.BackgroundColor = Colors.Black;
+                SystemTray.ForegroundColor = Colors.White;
                 SystemTray.Opacity = 1.0d;
-                SystemTray.ForegroundColor = SystemColors.ControlLightColor;
-                SystemTray.BackgroundColor = SystemColors.ControlDarkColor;
             });
         }
 
@@ -105,7 +109,7 @@ namespace WPCordovaClassLib.Cordova.Commands
 
         public void backgroundColorByName(string options)
         {    //exec(null, null, "StatusBar", "backgroundColorByName", [colorname]);
-
+             // this should NOT be called, js should now be using/converting color names to hex 
         }
 
         public void backgroundColorByHexString(string options)