[Jaffa Software]

Tuesday, 19 June 2012

Initial success in porting Harmattan/Symbian QML app to BlackBerry

This is the first post in a new BlackBerry category in my blog. Having attended the "BlackBerry 10 Dev Jam" in London last week, BB10 looks very interesting - and a spiritual successor to MeeGo 1.2 Harmattan, i.e. the Nokia N9.

It's particularly interesting as BlackBerry have created their own Qt/QML-based environment, called Cascades.

However, I've got an existing app, Bedside which is almost pure QML. Could I get it running? More detailed instructions will come later, but here's how I got to where I am:

  1. Install the BlackBerry 10 Native SDK and developer environment.
  2. Create a new BlackBerry Cascades C++ project, although we're going to use it for "plain" Qt (as described in this Chinese blog post).
  3. Ensure you add <env var="QT_QPA_FONTDIR" value="/usr/lib/qt4/lib/fonts" /> to bar-descriptor.xml.
  4. Copy qmlapplicationviewer.{cpp,h} from the existing project into APP/src/.
  5. Put your QML resources in APP/assets/ (note you can't use asset://... URLs within the QML files, as you can with Cascades).
  6. Replace main.cpp with a simplified version from your other project, for example:

#include <QtGui/QApplication>
#include <QtDeclarative>
#include "qmlapplicationviewer.h"

int main(int argc, char **argv) {
  QApplication app(argc, argv);
  QmlApplicationViewer viewer;
  viewer.setMainQmlFile("app/native/assets/main.qml");
  viewer.showFullScreen();
  return app.exec();
}

In particular, note the path to the main-QML-file.

And here's the initial version of Bedside (with no screensaver interaction yet) running on the BlackBerry 10 Dev Alpha:

UPDATE: With a bit more work, I've got a single source tree working: now I can deploy to Symbian, Maemo, Harmattan or BlackBerry 10 (using Qt SDK for the first three, and BB10 Native SDK for the latter).

Instructions are in this forum post.

Sunday, 26 February 2012

Avoiding jet lag using continuous clock change

These days I'm often travelling long distances; whether it's to Asia or Detroit with work; or San Francisco for the MeeGo and JavaOne Conferences.

Ten hour flights are rarely fun; but when combined with a ten hour time difference? The jet lag can destroy you.

However, I trust a clock when I see it. So if I can convince myself that the time isn't changing in one big jump, jet lag is less of an issue. I used to do this with my watch: every two hours on a ten hour flight with an eight hour time difference: move my watch forward two hours. By speeding up, or slowing down time, I find it excellent for transitioning gradually to my destination timezone.

My N9's standby screen provides an opportunity to do this automatically: every time I glance at my phone on the flight, it could show me the right "transient" time.

I prototyped it with a spreadsheet (download), for a recent trip to Korea, to see how effective it would be before writing an app:

 

To try it out, first off, enter the local departure and arrival times; and the timezone difference:


If travelling eastwards, the time difference will be positive. If travelling westwards, it will be negative.

A shell script will then be shown in column E. Copy this column and paste it into a text editor. Copy the resulting script to your UNIX-based mobile device (N9, N950, N900, N8x0, jailbroken iPad).

On a Harmattan device, the script needs to be run in develsh:

~ $ develsh outbound.sh
...

On everything else it needs to be run as root:

Jaffas-iPad:~ mobile$ su -
Password:
Jaffas-Ipad:~ root# sh outbound.sh
...

If run with screen or nohup, you shouldn't even need to keep the terminal open.

NEXT STEPS

Obviously the next step is an app. Is it something you'd be interested in? Is there a nice Qt API for changing the time? Are there Qt APIs for looking up timezones, and setting the device's timezone?

Thanks to eipi for allowing me to use MaeFlight's icon in this post. Also published on Nokia Developer blogs