So finally I have started to play with some programming on the Palm Pre 2. It is interesting to find that web applications runs as smooth as native onces in this device. What is more interesting is that, like Android, you can program in Windows, Linux and Mac. It is nice to know you have official tools that runs in all platforms, and you don’t have to stick with XCode or Visual Studio.
Apart from web applications, Palm’s (now HP) webOS let’s you program in C/C++ with native SDL and OpenGL 1 and 2 support. Most of low level hardware of the device can be access using standard linux procedure to open a stream and write or read. This is particularly interested because because it changes the mobile world a bit in two ways. You don’t have to root your phone (like in Android OS) or jailbreak it (like in iPhone) to access low level functions. webOS is built over a standard Linux, so if you want to take Python sources, compile it for ARM and put the library inside your C/C++ project (something I’m planning to do in the few months) YOU CAN, and it’s legal in the Application Catalog!
The lastest SDK, emulators and documentation of webOS can be found at Palm’s Developer Site. These tools are completely free and you only have to sign-up to get them, no need of 99U$D per year. Just download the tools for your platform, read the tutorials, understand what MOJO is about, and go on! It also has a development tool called ARES, which is a full feature IDE in the web, so may be you can even program in an iPad using Safari.
Creating an (empty) application
Let’s run Eclipse with Palm SDK plug-in and create a basic application.
Once created, you will see a project structure like this:
A basic (and empty) scene can be created by clicking on the Palm icon, and selecting. I will name this scene “home”
The “home” scene recently created adds two files to the project. “home-asssiant.js” (aka. a Controller for the Home scene) and “home-scene.html” (the view). So now the project looks like this
From a terminal window (or command line) , place in a directory before the project directory and type
palm-package <name of the project>
This will generate a “ipk” file which is the application packaged. Then in order to install the package into the device, just type
palm-install <ipk file>
This will produce the output you will see in the following screenshot
Here you will see the setup method of the assistant, widgets should be initialized here, and you can add some validations methods inside this setup. Like, for example, chars allowed in a TextField.
In the setup method you can also declare event handlers for the widgets, as I do in this piece of code
The view of this project it’s quite simple as you can see in this screenshot. Everything is HTML, every widget is identified by id, and you will use that id with the MOJO framework to customize the widget and manage it. The most relevant part if that you define a x-mojo-element property that tells the framework which type of object it is.
The final app looks like this without modifying the stylesheet or applying any custom style.