cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [31/35] git commit: Added Windows Phone support
Date Thu, 13 Mar 2014 19:59:00 GMT
Added Windows Phone support



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

Branch: refs/heads/master
Commit: d7498d31ed88e912deef1fc89905f00a181d542e
Parents: 7b64841
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Tue Mar 11 14:25:15 2014 -0700
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Tue Mar 11 14:25:15 2014 -0700

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


http://git-wip-us.apache.org/repos/asf/cordova-statusbar/blob/d7498d31/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index ff462fa..6a6c59b 100644
--- a/plugin.xml
+++ b/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-statusbar/blob/d7498d31/src/wp/StatusBar.cs
----------------------------------------------------------------------
diff --git a/src/wp/StatusBar.cs b/src/wp/StatusBar.cs
new file mode 100644
index 0000000..c6e6fe7
--- /dev/null
+++ b/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


Mime
View raw message