Friday, 28 October 2011

Web Texting Apps

So if your an Irish KDE user or n810 owner the little projects that I'm about to write about are going to be useful to you. If not it may be an interesting read or it may not(Your decision really). There is a web texting app for android,web, j2me and windows called cabbage . The developer seems like quite a nice guy I emailed him before starting initially to get the php setting for the web scripts for the app because my initial Idea was to run my n810 as a web server (using ligHTTPd) to host the scripts and build a much simpler web based gui on top of them but unfortunately the php packages for the n810 doesn't support curl which meant that Idea was dead in the water.

I then decided to implement my app in python and to not need a web server using his scripts as a model to rick the networks websites with httplib but to be honest that was going to be a lot of work and I already have a server online so there was no really need. So as you can see I was being quite lazy about this project therfore I decided to be even lazier and use a developer tool called Illumination Software Creator.  Which allows you to program with blocks and build guis really easily. It didn't have all the functionality I needed but the developers allow you to make and use custom blocks. This meant that all the code I had to write was

 data = urllib.urlencode({"u":"YourNumber",
 f = urllib.urlopen("YourServer", data)
 s =
 ISCVariable1  = s #so I can alert the number of messages later with illumination


A very lazy(efficient if I'm ever asked in an interview) way to code :). As you can see this quite a simple but effective little program and to be quite honest for not all that much effort. Here is the full source and Illumination files:
Python Source Code
Ilumination Project

The server I'm using is given to me by my university judging on the blog stats there shuldn't be to much of an issue because there isn't that many of you reading this and the proportion from Ireland is only like 10% tops but if there is to much traffic is sent to the server I'll take down the scripts.

I not that many of you may know I have recently converted back from gnome to kde because once I change the keyboard shortcuts kde was much more like gnome 2 than gnome 3 or unity. One of the really cool features that I got from my switch from gnome to kde was desktop plasma widgets ( and probably the prettiest desktop in the world) which as it turns out are super easy to develop. Hats off to the kde developer for making such cool ways to make these widgets and great documentation . You can develop widgets in python, javascript, ruby, c++ and web technologies. So I just made a simple little web page a .desktop file and I had my awesome little web texter kde applet.

Here is the source :
Applet(Open Zip to see source)

To add this to  your desktop just right click add widget -> click get new widgets -> install from file -> and choose the zip file above and you will have your awesome texting widget. I'll be adding phone book support to this later and I'll chuck a note on another post when I do so you know that you can upgrade :).

Wednesday, 19 October 2011

Java Script Mobile Kings App

So a few weeks ago I was in Eindhoven with a few friends consuming copious amounts of alcohol. Before going out we were engaging in the great student tradition of pre-drinking by playing drinking games. Mainly "Kings" or "King's Cup" according to Wikipedia however there was a few issues with this game, we had to spent quite a bit of time to find the cards when we wanted to play and when the cards were lined around the cup they became quite wet.

I thought it would be great to have an app to play kings so that I wouldn't have to find a deck of cards only to spill drinks on them . It turns out that both the android market and apple app store have "Kings" apps available but I don't just want an app for my android I want one for all of my devices especially my nokia n810 maemo device.
So I decided to write the app in javascript and html because lets face it. Its hard to think of a devices that doesn't support either. I kept it very simple so that it would be fast on all mobile devices therefore I chose to not use jquery or any other library.

I started by getting some free card images off . It doesn't really matter about the quality of these images for the moment. I may see if I can get really pretty images like the cards from the cards games in kde desktop later.
I started a simple web page with an image and a button :

<img src="./css/b1fv.png" id="card" onclick="nextCard();" width="200px" >
<button class="boldbuttons"id="RuleButton" onclick="rule();" type="button" style="width: 200px;">Rule</button>

I then created three functions in java script. The changeSize() function which I run when the page loads and does something like this for both the button and the card :

                var cardImg = document.getElementById('card');

The nextCard() function  generates a random number associated with the card image and changes the src value of the image to that number and throws that number into an array so it isn't used again and finally the rule() function which is just a lot of if statements in order to throw a java-script alert of the rule based on the current card. So as you can see this was rather easy to write and is ultra portable and anyone  can make it look as pretty as they like later with different images and css.

Here is the code:

In order to make it an app I can host in on a server, package it with webviews in android or just leave the files on the device. So for the n810 I just left the files on the device but on my droid I packaged it up with a webview and initializing it with the web age in the assets folder . One of the great things about doing this is that the user generally can't even tell that the app is just a web page. On top of that if you wished to include ads rather than use ad-mob you could just use regular Google ads embedded in the web page.

Here is the code and apk:
source code

I hope this helps some alcoholics and people who want make apps but don't want to use java alike :) .

PS. Next time I put money into my account I'll pay the 25 dollars and upload the jupiter broadcasting app and the kings app to the android market place and here is the qr code for the jupiter broadcasting app thank to rob

Thursday, 13 October 2011