You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by galexandrov <gi...@git.apache.org> on 2015/03/05 15:13:55 UTC

[GitHub] cordova-plugin-splashscreen pull request: [WP8] Respect SplashScre...

GitHub user galexandrov opened a pull request:

    https://github.com/apache/cordova-plugin-splashscreen/pull/38

    [WP8] Respect SplashScreen and SplashScreenDelay preferences from config file

    Extend WP8 Splash Screen to respect SplashScreen and SplashScreenDelay preferences from config file

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Icenium/cordova-plugin-splashscreen galexandrov/wp8-fixes

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-plugin-splashscreen/pull/38.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #38
    
----
commit d56b180384ecd077c3be3f67f85c0e152262643b
Author: Georgi Alexandrov <ge...@telerik.com>
Date:   2015-03-05T13:56:44Z

    Extend WP8 Splash Screen to respect SplashScreen and SplashScreenDelay preferences from config file

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-splashscreen pull request: [WP8] Respect SplashScre...

Posted by robpaveza <gi...@git.apache.org>.
Github user robpaveza commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-splashscreen/pull/38#discussion_r26144383
  
    --- Diff: src/wp/SplashScreen.cs ---
    @@ -40,26 +40,35 @@ namespace WPCordovaClassLib.Cordova.Commands
         /// </summary>
         public class SplashScreen : BaseCommand
         {
    +        private readonly Preferences preferences = new Preferences();
             private Popup popup;
    -        private bool autohide = true;
     
             private static bool WasShown = false;
     
             public SplashScreen()
             {
    -            Image SplashScreen = new Image();
    -            BitmapImage splash_image = new BitmapImage();
    -            splash_image.SetSource(Application.GetResourceStream(new Uri(@"SplashScreenImage.jpg", UriKind.Relative)).Stream);
    -            SplashScreen.Source = splash_image;
    +            this.LoadPreferencesFromConfiguration();
    +
    +            Image SplashScreen = new Image()
    +            {
    +                Height = Application.Current.Host.Content.ActualHeight,
    +                Width = Application.Current.Host.Content.ActualWidth,
    +                Stretch = Stretch.Fill
    +            };
    +
    +            var imageResource = Application.GetResourceStream(preferences.SplashScreenImage);
    +            if (imageResource != null)
    +            {
    +                BitmapImage splash_image = new BitmapImage();
    +                splash_image.SetSource(imageResource.Stream);
    +                SplashScreen.Source = splash_image;
    +            }
     
                 // Instansiate the popup and set the Child property of Popup to SplashScreen
    -            popup = new Popup() {IsOpen = false, Child = SplashScreen };
    +            this.popup = new Popup() { IsOpen = false, Child = SplashScreen };
    --- End diff --
    
    Nit: prefixed use of "this" when referring to members isn't bad, but is unnecessary.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-splashscreen pull request: [WP8] Respect SplashScre...

Posted by robpaveza <gi...@git.apache.org>.
Github user robpaveza commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-splashscreen/pull/38#discussion_r26143768
  
    --- Diff: src/wp/SplashScreen.cs ---
    @@ -68,27 +77,52 @@ public override void OnInit()
                 if (!WasShown)
                 {
                     WasShown = true;
    -                show();
    +                this.show();
                 }
             }
     
    -        void LoadConfigValues()
    +        private static void GetPreference(XDocument document, string preferenceName, Action<string> action)
    --- End diff --
    
    This method works somewhat backwards, where you check up to N strings for every preference, making your worst-case performance O(n^2) (in the case that you don't find the preferences).  Suggested alternative: Populate a Dictionary<string, Action<string>>, and then for-each preference element, if (dictionary.TryGetValue(preferenceName, out action)) action(value).  Dictionary lookups approach O(1).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-splashscreen pull request: [WP8] Respect SplashScre...

Posted by robpaveza <gi...@git.apache.org>.
Github user robpaveza commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-splashscreen/pull/38#discussion_r26150136
  
    --- Diff: src/wp/SplashScreen.cs ---
    @@ -40,26 +40,35 @@ namespace WPCordovaClassLib.Cordova.Commands
         /// </summary>
         public class SplashScreen : BaseCommand
         {
    +        private readonly Preferences preferences = new Preferences();
             private Popup popup;
    -        private bool autohide = true;
     
             private static bool WasShown = false;
    --- End diff --
    
    Nits: Why static?  Why PascalCased for a private?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-splashscreen pull request: [WP8] Respect SplashScre...

Posted by robpaveza <gi...@git.apache.org>.
Github user robpaveza commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-splashscreen/pull/38#discussion_r26149994
  
    --- Diff: src/wp/SplashScreen.cs ---
    @@ -68,27 +77,52 @@ public override void OnInit()
                 if (!WasShown)
                 {
                     WasShown = true;
    -                show();
    +                this.show();
                 }
             }
     
    -        void LoadConfigValues()
    +        private static void GetPreference(XDocument document, string preferenceName, Action<string> action)
    --- End diff --
    
    Variable name 'document' should probably be 'configuration' or 'configFile'.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-splashscreen pull request: [WP8] Respect SplashScre...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/cordova-plugin-splashscreen/pull/38


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-splashscreen pull request: [WP8] Respect SplashScre...

Posted by robpaveza <gi...@git.apache.org>.
Github user robpaveza commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-splashscreen/pull/38#discussion_r26149711
  
    --- Diff: src/wp/SplashScreen.cs ---
    @@ -163,5 +190,30 @@ public void hide(string options = null)
                     story.Begin();
                 });
             }
    +
    +        private void StartAutoHideTimer()
    +        {
    +            var timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(preferences.SplashScreenDelay) };
    +            timer.Tick += (object sender, EventArgs e) =>
    --- End diff --
    
    Suggest: Promote the Tick handler to a member function.  In the callback, remove the Tick handler.  This eliminates the circular reference which is created by auto-referencing 'this' in your callback.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-splashscreen pull request: [WP8] Respect SplashScre...

Posted by robpaveza <gi...@git.apache.org>.
Github user robpaveza commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-splashscreen/pull/38#discussion_r26149807
  
    --- Diff: src/wp/SplashScreen.cs ---
    @@ -163,5 +190,30 @@ public void hide(string options = null)
                     story.Begin();
                 });
             }
    +
    +        private void StartAutoHideTimer()
    +        {
    +            var timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(preferences.SplashScreenDelay) };
    +            timer.Tick += (object sender, EventArgs e) =>
    +            {
    +                this.hide();
    +                timer.Stop();
    +            };
    +            timer.Start();
    +        }
    +
    +        private class Preferences
    --- End diff --
    
    It's not clear that another heap-allocated object is worth it here.  With only three preferences, in a private class, each of these could be promoted to a member variable of the owning class, eliminating the private class altogether.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-plugin-splashscreen pull request: [WP8] Respect SplashScre...

Posted by purplecabbage <gi...@git.apache.org>.
Github user purplecabbage commented on the pull request:

    https://github.com/apache/cordova-plugin-splashscreen/pull/38#issuecomment-78152746
  
    Thanks for the contribution.
    I did some cleanup in general of this code, some per comments from @robpaveza 
    ( 6b1e72c6312f1c449d15a11be445b858c6689d6a )
    The code has been merged.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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