[MATERIALES] Evento Mobility Day Madrid 2013

El pasado miercoles 22 de mayo estuve junto a mis compañeros de Plain Concepts Alfredo Fernandez , Javier Cantón y Rodrigo Díaz , en la Universidad Rey Juan Carlos de Móstoles. La idea del evento era contar un poco las novedades en desarrollo nativo para Windows Phone 8, de lo que me ocupé yo, desarrollo multiplataforma en PhoneGap, gracias a Alfredo, y desarrollo multiplataforma con Xamarin, de la mano de Javier y Rodrigo. Para terminar la mañana contamos…(read more)

Behind the Scenes: Headset Camera app for the N9

The logical step after the “Volume+ as Camera Button” app (Nokia Store link) for the N9 is another app that allows you to take photos while not touching your N9 at all. While time-triggered photos are fun, remote-triggered photos are.. erm.. “funner”? So what kind of remote “buttons” can we easily get on the N9? The remote control button on the headset is both “remote” and a “button”. Also, as seen in Panucci and gPodder versions since the N900, Bluetooth headset buttons can also be queried by applications. So what do we get by combining remote control and photo taking? The Headset Camera app (Nokia Store link) for the N9! Or – for the visual reader – this:

If you want to integrate such features into your own app, the code for querying the headset buttons is readily available in the gPodder source tree (src/gpodder/qmlui/helper.py):

import dbus
 
class MediaButtonsHandler(QtCore.QObject):
    def __init__(self):
        QtCore.QObject.__init__(self)
        headset_path = '/org/freedesktop/Hal/devices/computer_logicaldev_input_0'
        headset_path2 = '/org/freedesktop/Hal/devices/computer_logicaldev_input'
 
        system_bus = dbus.SystemBus()
        system_bus.add_signal_receiver(self.handle_button, 'Condition',
                'org.freedesktop.Hal.Device', None, headset_path)
        system_bus.add_signal_receiver(self.handle_button, 'Condition',
                'org.freedesktop.Hal.Device', None, headset_path2)
 
    def handle_button(self, signal, button):
        if signal == 'ButtonPressed':
            if button in ('play-cd', 'phone'):
                self.playPressed.emit()
            elif button == 'pause-cd':
                self.pausePressed.emit()
            elif button == 'previous-song':
                self.previousPressed.emit()
            elif button == 'next-song':
                self.nextPressed.emit()
 
    playPressed = QtCore.Signal()
    pausePressed = QtCore.Signal()
    previousPressed = QtCore.Signal()
    nextPressed = QtCore.Signal()

MediaButtonsHandler is already a QObject subclass, so you can easily expose an instance of this class to your QDeclarativeView rootContext() and connect to the signals in QML (such a “headset button handler” might actually be a good candidate for inclusion into nemo-qml-plugins in Sailfish OS and Nemo Mobile?). As it’s really just using the Python D-Bus bindings to get property changes from Hal devices, the code above should be easy (read: trivial) to port from Python to Qt/C++. Be aware that you need to connect to both …/computer_logicaldev_input_0 and …/computer_logicaldev_input, which can both exist if you have a cable headset and a Bluetooth headset connected at the same time.

You can get the Headset Camera App for the N9 in Nokia Store now, there is also a video on YouTube showing the app. Or start integrating headset button features into your own app or scripts by adapting the code above. One use case that comes to mind is using the previous/next buttons on a Bluetooth headset to control a photo slideshow on the N9 connected to TV-Out. Enjoy :)

HTML5 Web Apps on Mobile Devices

Get out your Buzzword Bingo cards, we’re talking HTML5. And Canvas2D. And WebGL. See? Check them off and then continue reading. So, while writing “native” apps using JavaScript is definitely possible and works great with QML, some games are just simple enough (or want to have a broad enough audience) to warrant writing everything in HTML5.

This might also be a good time to check off XmlHttpRequest on your BB card, even if none of the following games use it – you might want to use it in your applications or game for things such as server-side stored high scores.

As far as Maemo and MeeGo is concerned, you might want to try out some of these games (especially the WebGL variant of One Whale Trip) in Fennec (aka Mobile Firefox – get it for: N900, N950/N9, Nemo Mobile).

Color Lines: This one simply uses Canvas2D, and works nicely on all mobile browsers that I tested – Maemo, MeeGo, Android, WP7.5, BB Playbook, iOS. Comes in at about 650 lines of rather well-documented JavaScript, and could easily be ported to use QML as a renderer if need be (it would be good to have a QML Plug-In that provides a JavaScript context + (a subset of) the Canvas2D API – without using WebKit (cross that off, too), that is). Also, the N900′s stock browser has performance problems rendering this, while on the same device in Fennec it’s quite playable.

Circle1D: This is a straight Python-to-JavaScript port of a lame 2D “Physics” Engine. It’s kept very (read: very, very) simple, and collision detection could be done in a nicer way, but the inefficiency of it provides a nice benchmark for comparing JavaScript engine performance (I’m sure you can find “engine performance” on your bingo card as well) on mobile devices. The N900′s default browser can’t handle it at all, but Fennec can at least render/simulate it, albeit slowly.

One Whale Trip: This game actually started out as a Python game for PyWeek last September, which was also ported to the N950/N9, but as a test for trying out WebGL, I decided to port it from Python/PyGame to JavaScript/Canvas2D and then to WebGL (the Python version also contains two renderers – a “blitting” one using PyGame surfaces, and an OpenGL one using OpenGL [ES 2 on mobile]). The Canvas2D version works again in all modern mobile browsers (same as above), the WebGL only works on browsers supporting WebGL, for example Fennec/Firefox on both the N900 (even though very slowly) and not in any of the stock browsers (even not the one on the N9). As WebGL is “roughly” the same as OpenGL ES 2.x, one could imagine sharing at least shader programs for a possible C++-or-JavaScript cross-platform application.

So yeah, for smaller applications and/or games, HTML5 is definitely an option. In Firefox OS, your HTML5 web app will – also with WebGL – work and integrate nicely as “native” app. If you also want to create “native” applications (maybe after finishing the HTML5 version), consider encapsulating your JavaScript code so that you can re-use it in QML code, or (in case of WebGL apps), at least design the rendering part of your application in such a way that the code/architecture and shader programs can be shared with a C++ port of your existing HTML5 app.

Another option that’s worth considering: Writing a compatiblity application layer that can load (specially-crafted) WebGL subset applications and display them on a fullscreen SDL-(or Qt)-provided window. Applications written in this WebGL subset could then be deployed on the web as HTML5 application or “natively” running on top of a JavaScript engine only. I’d call that “webglenv“, and no, I haven’t written it yet.

Windows Phone Tip: Problemas al publicar para Windows Phone 7 y para Windows Phone 8

Hola a todos! Hoy quiero hablar un poco de la publicación de aplicaciones para Windows Phone 7 y 8. Básicamente tendremos que tener dos XAP distintos, uno para cada plataforma. La teoría nos dice que el XAP que hayamos compilado para Windows Phone 7, se desplegará a dispositivos 7.X, mientras que el XAP que hayamos compilado para Windows Phone 8 se desplegará a dispositivos 8.X. Pero como todos sabemos, a veces la teoría falla y he visto muchas confusiones…(read more)

Petals for Harmattan – A pure Qt4/Qt5 JS/QML puzzle game

Next up in my list of things I did in the last weeks/months and never blogged about is Petals (Nokia Store link), a “beautiful, brain-teasing puzzle game for 1-4 players” if the game’s website is to be believed (I would like to think it is…). As always, there’s some technical details about the porting and creation of this game. While another recent game (Tetrepetete) has been done on a low level (C++ using no frameworks, and interfacing with multiple front-ends directly, including an OpenGL ES frontend, a console-based ncurses frontend(!) as well as a server-sent events/XHR/Canvas2D-based HTML5 frontend(!!)), this one is approaching things from a very high level: JavaScript.

Petals: A puzzle game written in pure JavaScript and QML

The gameplay logic of the game is implemented in pure JavaScript (without any QML dependencies), so it could easily be ported to, say, HTML5, but for integration reasons, QML seemed like the better choice for a release on the N9/Harmattan. Also, writing things in JavaScript wouldn’t preclude a console-based frontend using nodejs and node-ncurses from happening should the need arise (making the flowers look good in ASCII art would be the challenge there – or cheating by using libcaca). Ok, ok – stop cursing, I’ll stop talking about curses (cue laugh track).

Writing pure QML applications has the advantage of easing porting to Qt 5. While QtQuick 1.1 still exists on Qt 5 (and is the only QML option at the moment if you are also targetting iOS), QtQuick 2.0 is usually the better choice for performance reasons.

In my case, the changes necessary to port from QtQuick 1.1 to QtQuick 2.0 were:

  • Change “import QtQuick 1.1” to “import QtQuick 2.0” (sed(1) helps here)
  • Instead of assigning a JavaScript function to a property to create a dynamic property binding (item.someprop = function() { return otheritem.otherprop * 3.0; }), this function has to be wrapped in a call to Qt.binding() in Qt 5 (see “Creating Property Bindings from JavaScript” in the Qt 5 docs)
  • Instead of using SQL Local Storage directly as in QtQuick 1.1, use QtQuick.LocalStorage 2.0, which you can still do in your .js files – use “.import” as described in this blog post
  • In your C++ launcher (in case you need one), QApplication becomes QGuiApplication, and QDeclarativeView becomes QQuickView
  • Use “QT += quick qml” instead of “QT += declarative” in your qmake project file

And that’s basically it. Of course, as this is a full-screen game with custom UI, no platform-specific components (such as Harmattan Components or Sailfish Silica) are used, so porting is a bit easier there (no need to “wait” for specific components to be compatible with QtQuick 2.0, which might realistically not happen at all for Harmattan Components). More screenshots of Petals and download links for multiple platforms can be found on the Petals Website.

Upcoming: Billboard 1.0.9 for Nokia N9

Turns out I haven’t posted here for two months, so here we go again: Billboard, your favorite low-power mode standby screen will soon receive a new update – version 1.0.9 has been uploaded to Nokia Store QA two days ago, and should hopefully pass QA and be available as an update in the next few days. This release brings a few major under-the-hood improvements and small bugfixes:

  • Fixed MeeCast icon (in 1.0.8, you can already use <<{meecast-icon-src}>>)
  • New formatter that allows you to nest {} expressions used for adding dynamic content
  • Optional image dithering (using # after the filename) for better colors in low power mode

With the new formatter, you can now output {} expressions in your scripts so that they get replaced, and similarly pass {} expressions as parameters to your scripts (for example to modify them in some way before displaying). This should allow for even more customization, some examples of what users have been doing on their N9 standby screen can be seen in the Billboard Standby Screen support thread on talk.maemo.org.

If you are looking for additional ways to tweak and enhance your Billboard-on-N9 experience, have a look at billboard-scripts, a growing collection of Shell and Python scripts that provide even more ways of customizing your standby screen.

If you haven’t purchased Billboard from Nokia Store yet, you can get the current version now for your N9, and get the upgrade to 1.0.9 as soon as it’s available. If you are already a happy user, watch your application updates in the next few days, and get the new version.

[EVENTO] Mobility Day Madrid el 22 de mayo

Hola a todos! En Plain Concepts estamos preparando un gran evento sobre desarrollo para Windows Phone 8 que tendrá lugar el 22 de mayo en la Escuela técnica superior de ingeniería informática de la Universidad Rey Juan Carlos, en el campus de Móstoles. El evento durará todo el día, desde las 9 de la mañana a las 6 de la tarde. Por la mañana, de 9:15 a 13:30 tendremos cuatro charlas ( http://mobilityday.eventbrite.com/ ): Desarrollo móvil nativo en Windows Phone 8 , donde podremos ver las principales…(read more)

Nokia Premium Developer Program for Asha – A Great Opportunity

 Hi,

 Here comes a great opportunity for developers: If you are having only two qualifying mobile applications published in any of the official store(e.g., Nokia Store, Windows Phone Store, Google Play, BlackBerry World, Apple App Store), then you can be a part of the Nokia Premium Developer Program for Asha.  This program has number of benefits including a free Nokia Asha 310 device, $500 (USD) in Nokia Ad Exchange (NAX) credits for use in creating external ad campaigns, free tech support tickets etc. I must say it’s a great opportunity for mobile application developers because you can target 675 million (and increasing) phones by targeting Nokia Asha platform.

Asha Premium Program Shipment

After reading about this opportunity, I instantly sent my registration request which get approved in 24 hours and I received the Nokia Asha 310 device in a week. The Nokia Asha platform provides a great UX and one can develop applications for Asha phones using Nokia Java SDK or Nokia Web Tools.

BloxRun MoSync

I am always interested in trying new development tools especially the cross-platform ones. That’s why, I chose to play with MoSync SDK which is a free, open-source & cross-platform development tool with a support for Nokia Asha (JavaME) phones. It provides a rich cross-platform IDE with a C/C++ foundation and provides a large number of APIs that can help developers in building cross-platform applications easily. I gave it a go and found that JavaME applications developed using MoSync worked really well on Nokia Asha phones.

Blox Run- Gamplay

‘Blox Run’ is the game which I ported from Nokia Anna/Belle phone to Nokia Asha (JavaME) platform using MoSync. This game has a pretty simple game engine implementation which took me only two days to port it to MoSync. For graphics part, I use to create vector graphics using Adobe Flash or Adobe Illustrator which can be easily ported to lower or higher resolution phones by simply resizing them. That’s why, it took me only few hours to regenerate all the graphics for Asha phones having resolution of 240×400. Just add one more day to it for testing & optimization, so, in total four days my porting process was completed. If you want to try out the game, it is published in the Nokia Store.

At the end, I also like to mention that I told one of my fellow ‘Murtaza Ashraf’ (a Founder and CEO of Ioptime) about this program and now, he is having his own Nokia Asha phone (sent by this program). Moreover, I actually get impressed by the UX and performance of Asha Phones and that’s why, I decided to do more experiments soon. Stay Tuned!

Best Regards,

Sajid Ali Anjum

Materiales Master Class en RIATec

Hola a todos! El pasado 8 de abril tuve la oportunidad de estar en Málaga con la gente del master RIATec hablando sobre Windows 8 y Windows Phone 8. En total tuvimos 4 horas para dar un repaso a las técnicas para compartir código entre Windows 8 y Windows Phone 8 (sin usar clases parciales ni enlace de archivos), ver los nuevos mapas de Windows Phone 8, las APIs de Voz y el uso de NFC. Aquí van las slides que usé: Compartir código entre Windows 8 y Windows Phone 8: RIATec Sharing code between win8…(read more)

Materiales Master Class en RIATec

Hola a todos! El pasado 8 de abril tuve la oportunidad de estar en Málaga con la gente del master RIATec hablando sobre Windows 8 y Windows Phone 8. En total tuvimos 4 horas para dar un repaso a las técnicas para compartir código entre Windows 8 y Windows Phone 8 (sin usar clases parciales ni enlace de archivos), ver los nuevos mapas de Windows Phone 8, las APIs de Voz y el uso de NFC. Aquí van las slides que usé: Compartir código entre Windows 8 y Windows Phone 8: RIATec Sharing code between win8…(read more)