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

Jupiter Broadcasting App

Ok so this is going to be my first post. I never really blogged before but I wanted a outlet for some of the cool and not so cool little projects that I do (mainly to do with software). Anyway, last Thursday I was watching Linux Action Show and TechSnap. Which are awesome by the way. I heard someone in the chatroom say that there was an iphone app but not an android app. I really think that is because you don't really need an android app with all the apps in the market place to stream content and to get rss feeds but I made this anyway because its annoying to keep hearing people say things like that and it will be a good educational piece of code for people starting off with android.

Lets get started, so first thing I did was decide to play the audio stream. So I created a media player object and set the data source to mp3 stream from Then I created a quick GUI, just a button using drag and drop with eclipse. Then I linked the button to a listener like this

play.setOnClickListener(new OnClickListener(){
public void onClick(View v) {


where play is the button Object. So I gave the chat room a link and was told they liked it but was asked if could I add ongoing app notifications. I went rummaging through the android docs to find out how to do this, turns out its not that hard. So I set the notifications on the on Pause listener like this

@Override protected void onPause() {
  String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
Notification notification = new Notification(R.drawable.icon, "Jupiter Broadcasting",System.currentTimeMillis());

Intent notificationIntent = new Intent(this, Home.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

PendingIntent intent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(getApplicationContext(),"Jupiter Broadcasting", "Playing Live Stream", intent);

notification.flags = Notification.FLAG_ONGOING_EVENT ;

The "mNotificationManager.cancel(34);" is very important to stop the notification appearing unintentionally. By this stage we have a relatively functional radio app and I started thinking about new features that could be useful and I remembered I had some code for an RSS reader that I grabbed from someones blog and modified slightly so I added the feed for all shows so that people can download the latest episodes.

I'm just about finished but I'll probably update and add stuff to this over time but its pretty much done. I'd also like to point out that while most of the code is mine(The RSS reader part isn't I've been trying to find the blog I took it from however I have modified it to click into links) and feel free to use it whatever way you want. The images I don't know what sort of copy right there is about the images and if Chris or anyone else from jupiter broadcasting wants me to take this down or remove or modify it. I will without issue. Hope you enjoyed my first blog(Although it was probably boring as sin sorry :))

Here is the code and the apk
Source Code (Eclipse Project)

Update its in the android market now :