diff --git a/plugin.xml b/plugin.xml
index d684ae8..19f0e8e 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -58,7 +58,7 @@
-
+
@@ -98,6 +98,7 @@
+
@@ -111,6 +112,7 @@
+
diff --git a/src/wp/ResolutionHelper.cs b/src/wp/ResolutionHelper.cs
new file mode 100644
index 0000000..4d7996c
--- /dev/null
+++ b/src/wp/ResolutionHelper.cs
@@ -0,0 +1,60 @@
+/*
+ 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.Info;
+using System;
+using System.Windows;
+
+namespace WPCordovaClassLib.Cordova.Commands
+{
+ public enum Resolutions { WVGA, WXGA, HD };
+
+ public static class ResolutionHelper
+ {
+ private static bool IsWvga
+ {
+ get
+ {
+ return Application.Current.Host.Content.ScaleFactor == 100;
+ }
+ }
+
+ private static bool IsWxga
+ {
+ get
+ {
+ return Application.Current.Host.Content.ScaleFactor == 160;
+ }
+ }
+
+ private static bool IsHD
+ {
+ get
+ {
+ return Application.Current.Host.Content.ScaleFactor == 150;
+ }
+ }
+
+ public static Resolutions CurrentResolution
+ {
+ get
+ {
+ if (IsWvga) return Resolutions.WVGA;
+ else if (IsWxga) return Resolutions.WXGA;
+ else if (IsHD) return Resolutions.HD;
+ else throw new InvalidOperationException("Unknown resolution");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/wp/SplashScreen.cs b/src/wp/SplashScreen.cs
index 1c33c94..680a805 100644
--- a/src/wp/SplashScreen.cs
+++ b/src/wp/SplashScreen.cs
@@ -1,10 +1,10 @@
-/*
+/*
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.
@@ -43,7 +43,7 @@ namespace WPCordovaClassLib.Cordova.Commands
private Popup popup;
// Time until we dismiss the splashscreen
- private int prefDelay = 3000;
+ private int prefDelay = 3000;
// Whether we hide it by default
private bool prefAutoHide = true;
@@ -66,8 +66,7 @@ namespace WPCordovaClassLib.Cordova.Commands
Stretch = Stretch.Fill
};
- Uri imagePath = new Uri(prefImagePath, UriKind.RelativeOrAbsolute);
- var imageResource = Application.GetResourceStream(imagePath);
+ var imageResource = GetSplashScreenImageResource();
if (imageResource != null)
{
BitmapImage splash_image = new BitmapImage();
@@ -76,7 +75,7 @@ namespace WPCordovaClassLib.Cordova.Commands
}
// Instansiate the popup and set the Child property of Popup to SplashScreen
- popup = new Popup() { IsOpen = false,
+ popup = new Popup() { IsOpen = false,
Child = SplashScreen,
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Center
@@ -133,6 +132,52 @@ namespace WPCordovaClassLib.Cordova.Commands
}
}
+ private StreamResourceInfo GetSplashScreenImageResource()
+ {
+ // Get the base filename for the splash screen images
+ string imageName = System.IO.Path.GetFileNameWithoutExtension(prefImagePath);
+ Uri imageUri = null;
+ StreamResourceInfo imageResource = null;
+
+ // First, try to get a resolution-specific splashscreen
+ try
+ {
+ // Determine the device's resolution
+ switch (ResolutionHelper.CurrentResolution)
+ {
+ case Resolutions.HD:
+ imageUri = new Uri(imageName + ".screen-720p.jpg", UriKind.Relative);
+ break;
+
+ case Resolutions.WVGA:
+ imageUri = new Uri(imageName + ".screen-WVGA.jpg", UriKind.Relative);
+ break;
+
+ case Resolutions.WXGA:
+ default:
+ imageUri = new Uri(imageName + ".screen-WXGA.jpg", UriKind.Relative);
+ break;
+ }
+
+ imageResource = Application.GetResourceStream(imageUri);
+ }
+ catch (Exception)
+ {
+ // It's OK if we didn't get a resolution-specific image
+ }
+
+ // Fallback to the default image name without decoration
+ if (imageResource == null)
+ {
+ imageUri = new Uri(prefImagePath, UriKind.Relative);
+ imageResource = Application.GetResourceStream(imageUri);
+ }
+
+ if (imageUri != null) Debug.WriteLine("INFO :: SplashScreen: using image {0}", imageUri.OriginalString);
+
+ return imageResource;
+ }
+
public void show(string options = null)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>