Posts Tagged "Daylight"

Daylight for Windows Phone – Finally published

It has taken two rejections, but I am happy to announce that Daylight is available in the Windows Phone Marketplace. Here is a summary of some things learnt while developing it.

1. Make your life easy using open source libraries from NuGet

Following the idea of not reinventing the wheel, this is the list of libraries used:

  • Coding4Fun: Set of controls (progress overlay, toggle button, colour picker, etc.) and converters. Essential for any app.
  • Northern Lights WP7 Toolkit: This is a library with a set of classes that will simplify the usage of Isolated Storage (persistent cache on the phone), asymmetric encryption, handling of errors sending a report via email, among other things.
  • Your Last About Dialog: To get your app certified by Microsoft you need to include information about the publisher, and a way to contact you. This library gives you that in a Pivot control and you only have to enter de data in a XML file. It supports localization.

2. Getting icons to use in the app

There are many open source collections, but I like these 2:

Metro Icons: 130 icons from the Windows Phone 7 preview shown at the Mobile World Congress 2010 in Barcelona.

Templarian Icons: a project started a few months ago to supply creative commons licensed icons to Windows Phone developers. Built specifically for Windows Phone and include vector icons. If you need an icon not included, just mention @Templarian on Twitter explaining the icon, and you’ll get it. Currently there are more than 600 icons.

3. Using Location Services and getting your app certified

Another requirement by Microsoft to get your app certified when using Location Services, is to include a Privacy Policy in your app. You also need to let the user disable Location Services from your app.

This is the reason why this app needed a Settings section:

The correspondent XAML for this is:

<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock x:Name="ApplicationTitle" Text="Daylight"
         Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock x:Name="PageTitle" Text="Settings" Margin="9,-7,0,0"
         Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>
    <StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <toolkit:ToggleSwitch Header="Location" Name="EnableLocation"
           Checked="EnableLocation_Checked" Unchecked="EnableLocation_Unchecked" />
        <TextBlock Text="Privacy policy ...." TextWrapping="Wrap" />
        <TextBlock Tap="EnableLocation_Contact" Margin="0 10 0 0">
            <Underline><Run Text="Email Us"/></Underline>
        </TextBlock>
    </StackPanel>
</Grid>

The code behind, not using MVVM for simplicity in this example:

public partial class Settings : PhoneApplicationPage
{
    public Settings()
    {
        InitializeComponent();

        if (NorthernLights.PersistentVariables.Get<bool?>("enableLocation") == true)        
        {
            EnableLocation.IsChecked = true;
        }
        else
        {
            EnableLocation.IsChecked = false;
            EnableLocation.Content = Localization.AppResources.Off;
        }
    }

    private void EnableLocation_Checked(object sender, RoutedEventArgs e)
    {
        NorthernLights.PersistentVariables.Set<bool?>("enableLocation", true);
    }

    private void EnableLocation_Unchecked(object sender, RoutedEventArgs e)
    {
        NorthernLights.PersistentVariables.Set<bool?>("enableLocation", false);
    }

    private void EnableLocation_Contact(object sender, System.Windows.Input.GestureEventArgs e)
    {
        new EmailComposeTask
        {
           Subject = "Privacy Question",
           Body = "Daylight",
           To = "email@comyoucom.com"
        }.Show();
    }
}

4. Localising your app

Daylight is currently available in English and Spanish. The first thing that I’d recommend you to read if you are planning to localize your app is to follow the Best practices for Windows Phone. To set up your app to support localization, you can follow the official documentation, or this good tutorial from windows phone geek.

5. Make sure that your app works with the Dark and Light themes

By default Windows Phone supports two colour themes: dark (black background) and light (white background). Your app must work when the phone is set up to use any of those. You are not obligated to have two colour themes in your app too, but it’s a nice to have. In order to achieve that, instead using hard-coded styles, you could use the styles that are defined in the phone already.

Download Daylight