Blogging on the Train

I am looking to update my blog from the train on my daily commute. The main hurdle to overcome is the fact that the computer will not be connected to the internet during this time. And so the hunt for a decent offline blog editor begins.

The obvious place to start is Windows Live Writer.

I need to find out how to post source code using it. Apparently there is a plug in.

Watch this space.

Mono for Android: Just too expensive

There has been much talk in the office about mobile development.

I work with several devs that are building mobile apps in various different techs on different platforms.

For ages, I’ve been flying the Xamarin flag and fighting its corner. I’ve got the guys to come to Stuart Lodge’s MVVM Cross talks etc. As a development environment, I like it very much and I’m comfortable. I’m a c# WPF developer and so I like C# and Visual Studio.

But with the new pricing, I feel as though I’ve been let down.

$1000 is just way too high for the hobbiest app developer. Not to mention that that is per dev, so the guys that are in a small team of 3 or 4 – is their app going to make back $4000? Not any time soon that’s for sure.

And so they are going the Javascript, Typescript, Angular etc route under PhoneGap or whatever. And I don’t blame them.

Meanwhile, I’ve 11 months left of my annual subscription to build something in Mono for Android before the $1000 bill comes around again. And I feel I’ll have a hard time justifying it.

Common UI? Spotify on WP8 != Spotify on Android

Welcome Spotify!

Several friends of mine have the beautiful Nokia 920 running Windows Phone 8. It is a nice piece of hardware and it showcases WP8 very nicely.

One notable omission from the WP app store until now has been Spotify.

I’ve been a big supporter of Spotify ever since the beginning and happily pay my monthly premium subscription. Being able to store music offline on my phone is an absolute killer feature.

And so I am genuinely pleased that it has made it to the WP platform.

A Common UI

A hot topic of recent conversation amongst the boys has been HTML5 and the possibility of a common UI across multiple platforms. The conversation typically includes:

“You can write it once and it’ll run on desktops, iPads, mobiles…”

I have been developing in Mono for Android which allows for the code from the “viewmodel” (a logical representation of the view), interaction and business logic, service calls, etc to be shared.

Crucially though, the view, the UI, is not shared. And I believe this is a good strategy.

Users of Android expect their apps to be Android-like. Ditto for iDevices and Windows Phone.

Looking at screenshots of the new WP8 Spotify app, it is clear that the UI has been redesigned specifically for the Windows Phone. And rightly so.

So I applaud Spotify for making this (what I believe to be the) correct decision.

 

http://blogs.windows.com/windows_phone/b/windowsphone/archive/2013/02/08/spotify-arrives-on-windows-phone-8.aspx

Pausable Observable

There are many times when we might need to “pause” a live stream of data.

For example, your app is receiving live updates to a screen and then the user opens some sort of popup. We might choose to pause the live updates until the popup is closed. Once the popup closes, we need to apply the updates that have arrived in the mean time.

Often, it isn’t possible to actually pause the source of the data, such as a server. We also wouldn’t want to unsubscribe temporarily because updates could be missed.

Here is an extension method that takes an RX stream and makes it pausable. It is controlled by an observable which indicates whether the stream is paused or not. Updates are buffered whilst the stream is paused. When the stream is unpaused, buffered updates are pumped.

PausableObservable: https://gist.github.com/4317938
Unit tests: https://gist.github.com/4317948

public static IObservable<T> Pausable<T>(
           this IObservable<T> sourceStream,
           IObservable<bool> isPausedStream,
           bool startPaused = false)
        {
            return Observable.Create<T>(o =>
            {
                var subscriptions = new SerialDisposable();
                var replaySubjects = new SerialDisposable();
 
                var subscription = sourceStream.Publish(stream =>
                {
                    Func<ReplaySubject<T>> replaySubjectFactory = () =>
                    {
                        var rs = new ReplaySubject<T>();
 
                        replaySubjects.Disposable = rs;
                        subscriptions.Disposable = stream.Subscribe(rs);
 
                        return rs;
                    };
 
                    var replaySubject = replaySubjectFactory();
 
                    Func<bool, IObservable<T>> switcher = isPaused =>
                    {
                        if (isPaused)
                        {
                            replaySubject = replaySubjectFactory();
 
                            return Observable.Empty<T>();
                        }
                        else
                        {
                            return replaySubject.Concat(stream);
                        }
                    };
 
                    return isPausedStream
                        .StartWith(startPaused)
                        .DistinctUntilChanged()
                        .Select(switcher)
                        .Switch();
                }).Subscribe(o);
 
                return new CompositeDisposable(subscription, subscriptions);
            });
        }

This is based on an answer to a question on StackOverflow. However, there was a small issue which I had to fix – and I also needed to be able to specify in which state the pausable stream started.

Facebook Photo Sync

The social media giant’s latest offering of background photo uploads had me slightly worried.

I’m working on an app to do effectively just that. However, on further reading, I’m not so worried.

Firstly, the official app uploads every single photo from your phone automatically. Don’t worry about picking out the keepers or my mobile data limit – just upload everything.

This is not the workflow that I’m targeting. It shouldn’t really be anyone’s work flow!

My app assumes the following workflow.

First, you to choose the photos you want to upload. This is usually the post processed version – even the best shots usually benefit from a little crop, some tone curves applied, a touch of sharpening.

Next, I would like to arrange the photos for my album, add descriptions and tag people – all offline.

Finally, I’d like it to upload in the background at some point. Perhaps I’ll only want to transfer over wifi.

Thankfully, Facebook must cater to the lowest common denominator. Whilst its brute force method may suit some, I hope to find a more select audience. At least before they improve the app too much!