As part of the New Year tidy up I decided to add a wireless charging pad to my desk so that I can easily top up devices without too many trailing wires. I saw the new second generation DT-601 and thought it looked perfect – smaller than the original pad and with a USB interface which can go into a powered hub or optionally its own a/c adaptor. I picked the red one expecting bright post office red from the pictures but on the packaging it is described as neon red. Personally I would describe it as “Radioactive Salmon”, it has certainly brightened up my desk!
I plugged it in and tried a couple of devices on it and it was straight-forward to use. I have a 1020 with charging shell and this one was odd because you have to put the phone onto the round pad so the camera bezel sits on the edge of the pad so it’s not quite flat. This feels wrong but works fine – I guess the 1020 was always going to be a special case because of its unusually shaped derriere. If you have multiple devices you have to get used to where the charging point is as they seem to vary a bit. Keeping moving the phone around until you see that it is charging. I don’t have anything which supports QI charging which isn’t a Nokia phone but it should support any QI compatible device.
In the latest update to the Windows Phone Tasks app I’ve added in some API features for other apps to hook into. This is facilitated by Windows Phone 8’s support for custom Uri schemes – the app supports the tasks: scheme and allows you to do a couple of useful things with it. You can use it both to launch the app and also to pre-populate the New Task dialog. This allows the user to save a new Task as they can a Calendar event or Contact from your app. Full details on the Uri scheme are maintained here:-
In addition to this and following the example of Nokia, I’ve created an API library for Windows Phone which is available now on NuGet. This simplifies the creation of a new Task by providing a SaveTodoTask which has a model which should be instantly familiar to any Windows Phone developer. I chose to name this SaveTodoTask rather than SaveTaskTask as that sounded clunky and task items are interchangeably known as to-dos as well.
This functionality follows swiftly on the heels of the 1.80 release which added a New Task optional start tile as a short-cut to this functionality. 1.81 also includes numerous bug fixes and sync improvements along with support for Lock Screen notifications.
If you have feedback for the Tasks app remember you can submit it to our Uservoice site which will help us plan future updates.
Using the Windows Phone SDK the only method to return a list of your other published apps (e.g. for your About page) is to use the MarketplaceSearchTask and specify your company name in the search criteria. The problem with this is that it doesn’t return the actual publisher list but does a keyword search so you may find that a few other apps appear if other devs have used your company name in their descriptions or keywords.
The solution is to use a Uri and the LaunchUriAsync method in Windows Phone 8. The zune (yes it’s a throwback from the olden days) Uri scheme includes the ability to specify a publisher name e.g.
Windows.System.Launcher.LaunchUriAsync(new Uri("zune:search?publisher=APPA Mundi Ltd"));
In case you don’t want to hard-code your publisher name (to create a shared component for example) you can add this from the metadata of your app using Charming ApplicationModel e.g.
Windows.System.Launcher.LaunchUriAsync(new Uri("zune:search?publisher=" + InTheHand.ApplicationModel.Package.Current.PublisherDisplayName));
The equivalent functionality in Windows 8 is implemented through the ms-windows-store Uri scheme:-
or again using package information:-
Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:Publisher?name=" + Windows.ApplicationModel.Package.Current.PublisherDisplayName));
There are a number of steps when translating a Windows Phone app. Hopefully you are using the Microsoft Multilingual App Toolkit (http://msdn.microsoft.com/en-us/windows/apps/bg127574) which supports the standard XLIFF format. Often you will start with your own language string resources and then add other languages, possibly first with machine translation and then passing them to a native speaker to correct. Since Windows Phone (and Windows 8) adopt quite an informal conversational style it is likely that colloquialisms will enter your text which won’t necessarily translate literally. Also there will be times when you want to use a phrase for a system feature or action where there are existing strings which appear throughout the system. You’ll want to match these to avoid confusing the user. Take for example “Pin to Start” – if translated literally it would imply that you must use a pin to start some action (e.g. French “broche pour commencer”), when actually you want to place a link on your start screen, the OS uses the following string “épingler sur l’écran d’accueil”. The good news is all of these are available publicly for all of the supported Windows Phone languages. The Microsoft Languages site (http://www.microsoft.com/language) has a search tool which allows you to look up phrases for particular products and in specific languages. For example a deep link to the “pin to Start” string would be:-
Don’t be surprised if the search returns multiple identical matches, I’ve noticed this happens frequently. An example of where I used this was in my NFC Share Task. In order to be instantly familiar I wanted exactly the same text and appearance as activating the feature from built in apps, and I wouldn’t be able to call on native speakers from every possible language for Windows Phone 8. You get the advantage here of Microsoft’s own user testing and provide consistent wording to features the user will already be familiar with.
A tweet by @martinsuchan earlier reminded me of an issue I faced porting some code from Windows Phone to Windows Store. Moving from the Isolated Storage API to the new Windows.Storage namespace there was nothing built-in to determine if a file/folder exists prior to Windows 8.1. This meant the only supported option was to try and access the file and catch an exception. This is in itself horrible but even worse if you’re trying to use the same code on Windows Phone and Windows 8, because these exceptions have an even worse impact on the phone. My solution was to create an extension method for StorageFolder which would use the Isolated Storage API under the hood to call FileExists() or DirectoryExists() on Windows Phone and only the try/catch method when compiled on Windows 8. I had this code sitting around for a while and following 8.1 I reworked the code to add a TryGetItemAsync extension method for Windows Phone and I didn’t need the Windows 8 version any more. This functionality is packaged up in “Charming Storage” which is available on NuGet:-
Add the package, insert:
At the top of your code file and then you can use the extension method in exactly the same way as the Windows 8.1 method. Checking for file existence is as simple as:-
if(await Windows.Storage.ApplicationData.Current.LocalFolder.TryGetItemAsync("cheese") != null)
The Charming Storage library also adds a local settings API which is code compatible with Windows 8 and stores settings in the package’s local storage. This offers a replacement to IsolatedStorageSettings and gives you the same code as Windows Store (just the namespace is different).
The last post showed how to get the current app’s tile colour in Windows 8. What about Windows Phone? There isn’t the concept of a tile colour – you provide a full image for your app icon and tiles and this can be whatever colour you choose or transparent in which case the user’s accent colour is used. In terms of a theme colour for phone apps the application icon is probably a better place to start. The vast majority of apps use a solid colour background, this is seldom the case with games but since this post focusses on apps let’s not worry about that.
The Charming ApplicationModel library contains a more complete implementation of the Windows.ApplicationModel.Package class for reading app metadata at runtime – on Windows Phone most of the properties are not implemented. This has been updated with a number of new Windows 8.1 properties such as Logo which returns a Uri to the application logo file within your package. We can then use a WriteableBitmap to read an individual pixel from the image and create a solid colour brush to be used inside the app. This allows you to change the appearance of your app without any code or XAML changes, and is also useful for custom controls where the code might reside separately from the application itself. Below is the equivalent code to the Win8 version posted before. This creates a resource “AppAccentBrush” which can be used within the app UI.
System.Windows.Resources.StreamResourceInfo sri = Application.GetResourceStream(InTheHand.ApplicationModel.Package.Current.Logo);
System.Windows.Media.Imaging.BitmapImage img = new System.Windows.Media.Imaging.BitmapImage();
System.Windows.Media.Imaging.WriteableBitmap wb = new System.Windows.Media.Imaging.WriteableBitmap(img);
int rgb = wb.Pixels;
byte r, g, b;
r = (byte)((rgb & 0xFF0000) >> 16);
g = (byte)((rgb & 0xFF00) >> 8);
b = (byte)(rgb & 0xFF);
System.Windows.Media.Color c = System.Windows.Media.Color.FromArgb(0xff, r, g, b);
Application.Current.Resources.Add(“AppAccentBrush”, new System.Windows.Media.SolidColorBrush(c));
There is currently no check here for transparent backgrounds as we’d probably want to default to a solid colour in this case (perhaps fall back to PhoneAccentBrush). I’m looking at improving this code and integrating it into the charming libraries, to provide customisation to some of the UI such as the settings screens. You can grab the Charming libraries from Codeplex (http://charming.codeplex.com) or NuGet (http://www.nuget.org/packages?q=charming).
If you want to determine the space used for a particular folder in Isolated Storage you have to work recursively through the files in the folder (and sub-folders) and determine their sizes. In the Windows API the StorageFolder gives the indication that you can get the BasicProperties for a folder and use this to get its size. Unfortunately this just returns zero for folders. Therefore you have to use the same basic approach but modified for the new API (and async code). Below is an example of a method to do that. Simply pass in the StorageFolder of interest and it will return the size e.g.
ulong size = await GetFolderSize( await Windows.Storage.ApplicationData.Current.LocalFolder.GetFolderAsync(“cheese”));
The method looks like this:-
public async System.Threading.Tasks.Task<ulong> GetFolderSize(Windows.Storage.StorageFolder folder)
ulong size = 0;
foreach (Windows.Storage.StorageFolder thisFolder in await folder.GetFoldersAsync())
size += await GetFolderSize(thisFolder);
foreach (Windows.Storage.StorageFile thisFile in await folder.GetFilesAsync())
Windows.Storage.FileProperties.BasicProperties props = await thisFile.GetBasicPropertiesAsync();
size += props.Size;
You can use this across both Windows Phone 8 and Windows Store projects.