Going Universal

Continuing on the Universal Windows Platform track, last fall I started working with Xamarin Forms in Microsoft’s Visual Studio. I had done several apps using .NET and Microsoft Forms but Xamarin offered a way to create one app using the UWP (Universal Windows Platform) to create an app for Android, Windows and iOS.

I’ve had a number of requests for iOS apps over the years but I shied away from doing them because 1) I didn’t own a Mac and 2) nor did I want to invest time in learning Objective C which has little use outside of Apple products. UWP offered a way to do this.

I wasn’t all that foreign to Xamarin cross development having done apps using Mono on Linux and compiling them for Windows using Xamarin. With Visual Studio Community being available first when I did an app for Unity 3D and then available for other development I jumped in.

Initially it was for a much requested version for 7” tablets of my popular Indian astrology app. I had a landscape layout for 10” tablets but people wanted that on a their 7”. The problem is that the layout that worked for 10” tablets would be difficult to navigate sized down to 7”.

Hence I used Xamarin to create a new tablet layout. This grew into a new version for phones as well as tablets. These are going to be two separate “pro” versions with the extra features that people have requested that would be difficult to add to existing versions.

Another thing about “forms” is they are much easier to work with than the Android development environment. As other developers have noted it’s often difficult when spending some time away from Android development to remember how it all works. Not so if time is spent away from Xamarin. It’s all very straight forward with a lot of options.

There are, of course, some things missing that I need. One was popup dialogs that could used more than just text. Turns out there was an XLabs popup module that could handle that. And on the other hand was something available missing on Android: Formatted Text. On Android many of my text was all just drawn as a graphic and a bit of a pain to program. Formatted Text is much more like using HTML where I could change color and text attributes programmatically.

Also I have the ability to just change the Xaml layouts to get a portrait phone and tablet landscape version from the same code. However my experience with Android users is these are best offered as separate apps. There have been tablet users who wanted the portrait phone layout on their 10” tablet. Now this will be possible.

Next up will be an article on my experience of using Visual Studio 2017 to port an SDL2 C++ developed game to Android. I hope to offer some example source too for some of the underdocumented or tricky things to do with these environments.

Over the Top Programming Examples

One of the problems I run into developing for a new platform, SDK or toolset is finding examples that are not “over the top”. Seems that some of the SDK developers feel the need to write a kitchen sink example that you have to wade through to just figure out how something works. It’s like their kitchen sink (or Swiss army knife) is intended to be a resume for their next job instead of helping developers get up and running quickly.

I’ve been attempting to do some cross development with Visual Studio 2015 and Xamarin. I’ve written apps on Xamarin for Android only and have developed some apps for Windows using C#. Next up was trying out the Universal Windows Platform (UWP) to make one app that could run on Windows, Android, iPhone and Windows Phone. That is the goal of UWP but it’s really not quite there yet.

The app I wanted to develop is a new astrology program for those platforms. Astrology programs are generally pretty simple as far as the interface goes. You have some screens or pages which consist of text, lists and …. horoscopes which of course require graphics though simple graphics.

When I first developed an astrology program in 1997 it was for Windows and the purpose was to learn C++. I wound up using the Microsoft Foundation Class (MFC) for my first Windows app “Junior Jyotish”. All the graphics support was there for drawing horoscopes. Around the 2005 I started developing a version in Java. Again all the graphics support was there. In 2009 when I started Android development, again all the graphics support was there. When I developed a few programs in C# using MonoDevelop on Linux, all the graphics support was there. When I tried some Android apps on Xamarin the graphics support was there as Xamarin (now available in Visual Studio) provides a C# layer on top of the Android API.

But with UWP when I went to draw a horoscope I hit a brick wall. Horoscopes consist of lines and text. If it is a wheel chart then circles. But all that is just basic graphics. UWP does not have much of any graphics support. The way of creating and importing a graphic is clunky.

So the Xamarin folks are implementing Skia, a graphics library. But it hellacious to get working. All I wanted was a simple graphics example that would draw maybe just a box. Oh, you’ll find examples but just of the calls to Skia. What is missing is a complete example that draws that box (or graphic element) on a Xamarin Form. Why don’t they have that?

Instead there is this overblown set of examples on GitHub included in the Skia library. To build those is high voodoo. Too much is assumed of the developer to get them working. Or they were really never even tested by the developers who wrote them. Running the build command from the Windows 10 Powershell throws an error. Great! Common guys, just give us a simple VS example like I mentioned above. Experienced developers do not want to unwind your complicated samples to figure out how to get things working.

This was one thing that Microsoft got right back in the and still sometimes do: one simple example to get you started that will actually build and run. So for now UWP is really not ready for prime time.

Update:

I did find a simple demo of how to use the Skia library. You can find it here:
https://jefdaels.wordpress.com/2016/11/29/xamarins-skiasharp-how-to-get-started