Posts Tagged ‘twittoday’

Why I haven’t written TwitToday for Android

Thursday, February 25th, 2010

(or “looking at the limitations of the Android home screen widgets framework”)

Twitter client for Windows MobileA couple of years ago, I wrote a Windows Mobile app called TwitToday : a Twitter widget for the “Today screen” (the default screen when the phone is on, with all apps closed or minimised).

The rationale was that it was useful to have a way to post a tweet quickly when you don’t want to have to wait for a full-blown client to start.

Or if you don’t want to incur the battery or memory cost of leaving a client running all the time.


A widget that doesn't work on AndroidAndroid has a “Home screen”, which is similar to the Today screen on Windows Mobile. And it has support for widgets. This led several people to ask me why I never ported TwitToday to Android.

The short answer is that I did try, but the current state of the widgets framework made it impossible.

I tried to write a TwitToday widget back when the Android widgets framework was first introduced in Android 1.5.

It all started quite well:

  1. I wrote the Android Service that would carry out the background task of posting a tweet. No problems there – it worked fine.
  2. I wrote the widget XML to define the GUI. This is what you can see running in the screenshot. And it works… sort of. It has a text box that you can type up to 140 characters into. And if you press the button, it causes a chunk of code to get invoked.

The problem came when I tried to link the two together: to get the Service that posts tweets to obtain the String from the text box in my widget.

This isn’t possible. Android’s widget framework as it currently stands is geared around displaying information to the user, not collecting user input.

(more…)

Improvements to TwitToday

Wednesday, June 10th, 2009

I’ve been doing too much Java at work recently, so in the interest of keeping my hand in with some low-level C++, I picked up the code for my mobile twitter client, TwitToday, again.

I originally wrote it at a hackday, but I’ve since come back to tweak it a couple of times to get it to spawn background worker threads, add SIP on-screen keyboard support, and improve support for sending special and accented characters.

After another evening of tweaking, I’ve added a few new minor features:

Transparent text box

When not in use, the text box is now transparent. When it has focus, it is coloured in white as usual.

A few people commented that a bright white text box could dominate a dark Today screen too much, so this is hopefully a nice aesthetic improvement.

I did this by creating a custom windows procedure for the text box.

The windows procedure needed to handle a couple of events:

Handling WM_PAINT by using SetBkMode to make the text box TRANSPARENT

Handling WM_ERASEBKGND by using TODAYM_DRAWWATERMARK to draw the background over the text control’s rectangle.

(more…)

Posting to Twitter… carefully

Thursday, November 13th, 2008

I’ve recently picked up my the code for my Windows Mobile Twitter client again.

It was originally written back in April as a hackday idea. The code posts Twitter updates using a variation on the twitter-from-curl approach of HTTP POSTing “status=MyTweet” to the twitter update url.

I started with the update URL, and appended the message I wanted to tweet. This is fine for a quick hackday demo, but it did mean that you could end up with a URL like:

http://twitter.com/statuses/update.xml?status=Hello (twitter) world! Special chars = a problem?

Which fails if you want to post characters such as accents or characters which have special meaning in URLs, like + ? / & etc.

I was encouraged by a number of users to have another look at this, which I’ve done now, and hopefully version 1.1 solves the problems.

A quick Google turned up that a number of other Twitter apps share at least some of the same problems that mine had, so thought I’d share the fix here.

(more…)

Improving TwitToday – more Today Screen coding

Wednesday, July 23rd, 2008

Twitter client for Windows MobileApart from adding the ability to initiate an internet connection, my Twitter widget for Windows Mobile Today screens is still virtually the same code as I wrote in a few hours overnight at the Over The Air hackday.

Which isn’t great – as I know there have been a bunch of people waiting for me to make some fixes and add some basic features.

Tonight I had a bit of time to spare, so I finally dug out the code to start making a few improvements:

  • Background worker thread
    Today screen widgets are compiled into DLLs. They aren’t a separate executable, and are run by the Today Screen in the Today screen’s (i.e. explorer.exe’s) flow of execution. When the code tries to post to twitter.com, explorer can’t do anything else until that’s finished.

    That might even be tolerable with most websites, but with twitter – which is known to fall over from time to time! – it means TwitToday could effectively hang your phone for ages until the HTTP post timed-out.

    Not good. Now it does all the HTTP work in a background thread, so you can get on with other stuff while it tries to send your tweet.

  • SIP support
    This was asked for a lot. The Today screen doesn’t include the button to show/hide the on-screen stylus/finger keyboard. So if your mobile doesn’t have a keyboard, TwitToday wasn’t much use.

    I’ve added a setting now that lets you programmatically show the SIP keyboard when you tap on the text box.

If you want to try the new version, you can download it from here. If you want to see how I did it, read on.

(more…)

Twitter for Windows Mobile

Friday, April 4th, 2008

First of the random ideas for Over The Air hacks – a Twitter client for Windows Mobile.

Twitter client for Windows MobileWhen posting a tweet, the key is speed. I don’t want to wait to launch an app, I don’t want lots of features. I just want something to take my message and post it.

When reading tweets, I don’t mind waiting (e.g. for the list to be gathered).

And on mobile, I don’t really want regular notifications or polling. Following over a hundred people, I’d either hose my phone battery by constantly getting updates, or I’d miss most updates anyway. I just need to be able to see a list of updates when I want.

I went for a Today screen widget for posting, written in C++ to keep it quick and lightweight.
And if you click on the twitter logo, it launches your default browser at the mobile Twitter site http://m.twitter.com/. The best of both worlds :-)

Download a copy here
To set your username and password, go to the Options dialog for “Twit Today” from the Today screen control panel applet.

(more…)