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/24 20:15:09 UTC

[1/3] git commit: CB-6268 WP8. Apply BackgroundColor from config.xml

Repository: cordova-wp8
Updated Branches:
  refs/heads/master 5f92cd4e8 -> cc1d54fcb


CB-6268 WP8. Apply BackgroundColor from config.xml


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

Branch: refs/heads/master
Commit: e49a4c8a442efe33eb0b2b5a657d5b83d7b910ea
Parents: 0f80d88
Author: sgrebnov <se...@gmail.com>
Authored: Sat Mar 15 14:24:02 2014 +0400
Committer: sgrebnov <se...@gmail.com>
Committed: Sat Mar 15 14:24:02 2014 +0400

----------------------------------------------------------------------
 wp8/template/cordovalib/CordovaView.xaml.cs | 46 +++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/e49a4c8a/wp8/template/cordovalib/CordovaView.xaml.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/CordovaView.xaml.cs b/wp8/template/cordovalib/CordovaView.xaml.cs
index 094290b..b6e95b4 100644
--- a/wp8/template/cordovalib/CordovaView.xaml.cs
+++ b/wp8/template/cordovalib/CordovaView.xaml.cs
@@ -12,6 +12,7 @@
     limitations under the License.
 */
 
+using System.Globalization;
 using Microsoft.Phone.Controls;
 using Microsoft.Phone.Shell;
 using System;
@@ -23,6 +24,7 @@ using System.IO.IsolatedStorage;
 using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Media;
 using WPCordovaClassLib.Cordova;
 using WPCordovaClassLib.Cordova.JSON;
 using WPCordovaClassLib.CordovaLib;
@@ -171,10 +173,29 @@ namespace WPCordovaClassLib
             nativeExecution = new NativeExecution(ref this.CordovaBrowser);
             bmHelper = new BrowserMouseHelper(ref this.CordovaBrowser);
 
+            ApplyConfigurationPreferences();
 
             CreateDecorators();
         }
 
+        /// <summary>
+        /// Applies configuration preferences. Only BackgroundColor is currently supported.
+        /// </summary>
+        private void ApplyConfigurationPreferences()
+        {
+            string bgColor = configHandler.GetPreference("backgroundcolor");
+
+            if (String.IsNullOrEmpty(bgColor)) return;
+            try
+            {
+                Browser.Background = new SolidColorBrush(ColorFromHex(bgColor));
+            }
+            catch (Exception ex)
+            {
+                Debug.WriteLine("Unable to parse BackgroundColor value '{0}'. Error: {1}", bgColor, ex.Message);
+            }
+        }
+
         /*
          *   browserDecorators are a collection of plugin-like classes (IBrowserDecorator) that add some bit of functionality to the browser.
          *   These are somewhat different than plugins in that they are usually not async and patch a browser feature that we would
@@ -494,6 +515,29 @@ namespace WPCordovaClassLib
            }
         }
 
-
+        /// <summary>
+        /// Converts hex color string to a new System.Windows.Media.Color structure.
+        /// If the hex is only rgb, it will be full opacity.
+        /// </summary>
+        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;
+        }
     }
 }


[2/3] git commit: Merge branch 'CB-6268' of https://github.com/sgrebnov/cordova-wp8

Posted by pu...@apache.org.
Merge branch 'CB-6268' of https://github.com/sgrebnov/cordova-wp8


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

Branch: refs/heads/master
Commit: d60dfb5d6b967dfedf86adb149c2d70a23603537
Parents: 5f92cd4 e49a4c8
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Mar 24 10:25:58 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Mar 24 10:25:58 2014 -0700

----------------------------------------------------------------------
 wp8/template/cordovalib/CordovaView.xaml.cs | 46 +++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[3/3] git commit: applied CB-6268 backgroundcolor to WP7 also

Posted by pu...@apache.org.
applied CB-6268 backgroundcolor to WP7 also


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

Branch: refs/heads/master
Commit: cc1d54fcb2a00b49e498c872db68449e2bcbfcc0
Parents: d60dfb5
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Mar 24 12:15:12 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Mar 24 12:15:12 2014 -0700

----------------------------------------------------------------------
 wp7/template/cordovalib/CordovaView.xaml.cs | 48 ++++++++++++++++++++++++
 wp8/template/cordovalib/CordovaView.xaml.cs | 18 +++++----
 2 files changed, 58 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/cc1d54fc/wp7/template/cordovalib/CordovaView.xaml.cs
----------------------------------------------------------------------
diff --git a/wp7/template/cordovalib/CordovaView.xaml.cs b/wp7/template/cordovalib/CordovaView.xaml.cs
index e6688e1..f7d026f 100644
--- a/wp7/template/cordovalib/CordovaView.xaml.cs
+++ b/wp7/template/cordovalib/CordovaView.xaml.cs
@@ -18,11 +18,13 @@ using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Diagnostics;
+using System.Globalization;
 using System.IO;
 using System.IO.IsolatedStorage;
 using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Media;
 using System.Windows.Resources;
 using System.Xml.Linq;
 using WPCordovaClassLib.Cordova;
@@ -152,6 +154,7 @@ namespace WPCordovaClassLib
                 }
             }
 
+            ApplyConfigurationPreferences();
 
             browserDecorators = new Dictionary<string, IBrowserDecorator>();
 
@@ -187,6 +190,26 @@ namespace WPCordovaClassLib
 
         }
 
+        /// <summary>
+        /// Applies configuration preferences. Only BackgroundColor+fullscreen is currently supported.
+        /// </summary>
+        private void ApplyConfigurationPreferences()
+        {
+            string bgColor = configHandler.GetPreference("backgroundcolor");
+
+            if (!String.IsNullOrEmpty(bgColor)) {
+                try
+                {
+                    Browser.Background = new SolidColorBrush(ColorFromHex(bgColor));
+                }
+                catch (Exception ex)
+                {
+                    Debug.WriteLine("Unable to parse BackgroundColor value '{0}'. Error: {1}", bgColor, ex.Message);
+                }
+            }
+
+        }
+
 
 
         void AppClosing(object sender, ClosingEventArgs e)
@@ -508,6 +531,31 @@ namespace WPCordovaClassLib
             }
         }
 
+        /// <summary>
+        /// Converts hex color string to a new System.Windows.Media.Color structure.
+        /// If the hex is only rgb, it will be full opacity.
+        /// </summary>
+        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;
+        }
+
 
     }
 }

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/cc1d54fc/wp8/template/cordovalib/CordovaView.xaml.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/CordovaView.xaml.cs b/wp8/template/cordovalib/CordovaView.xaml.cs
index b6e95b4..74de7d2 100644
--- a/wp8/template/cordovalib/CordovaView.xaml.cs
+++ b/wp8/template/cordovalib/CordovaView.xaml.cs
@@ -179,20 +179,22 @@ namespace WPCordovaClassLib
         }
 
         /// <summary>
-        /// Applies configuration preferences. Only BackgroundColor is currently supported.
+        /// Applies configuration preferences. Only BackgroundColor+fullscreen is currently supported.
         /// </summary>
         private void ApplyConfigurationPreferences()
         {
             string bgColor = configHandler.GetPreference("backgroundcolor");
 
-            if (String.IsNullOrEmpty(bgColor)) return;
-            try
+            if (!String.IsNullOrEmpty(bgColor))
             {
-                Browser.Background = new SolidColorBrush(ColorFromHex(bgColor));
-            }
-            catch (Exception ex)
-            {
-                Debug.WriteLine("Unable to parse BackgroundColor value '{0}'. Error: {1}", bgColor, ex.Message);
+                try
+                {
+                    Browser.Background = new SolidColorBrush(ColorFromHex(bgColor));
+                }
+                catch (Exception ex)
+                {
+                    Debug.WriteLine("Unable to parse BackgroundColor value '{0}'. Error: {1}", bgColor, ex.Message);
+                }
             }
         }