My first Android application on Play store, The Address.

theAddress
This is exciting to get my first Google Play store application. Previously I worked on some Android applications, but nothing was up there in the Play Store. For me its really a different experience pushing it to the Play store. Unlike pushing to Apple App store, the Play Store push feels like no brainer.
Now, talking about the application, its a personal note taking application for an absolute necessary address. This application does not require internet connection at all. Its a pure standalone application on its own. Its private to the user.
Open up the application, fill out the form to add an address and save it. Thats all it does. Once you come back to get the address, it shows upfront the saved address. Incase you are done with the currently stored address, update the form with a new address and save it. It does not store history of your previous addresses.
Now the implementation is done with Cordova (phonegap) 2.7 , jQuery 2.0 , jQuery Mobile 1.3 , lawnchair and GASP JS(GreenSock Animation Platform for Javascript). Its completely opensource and the code can be found at Github.

Looking forward to listen from you all.

Cordova(Phonegap), jQueryMobile and making a popup

This may seem obvious to make a pop-up with jQuerymobile with its popup API, but its a little more than just calling the api.
The problem is closing the popup. When working in a single page application in jQuerymobile and phonegap, the closing of the popup will take you to different jQueryMobile pages depending upon your setup.
The solution is to make the popup ready to be open just at the current page and while closing it should not make the application go to different pages. The trick is to while initialising the popup widget, initialise it with “{history: false}”, and thats all.
Here is a popup created with jQueryMobile API.

My PopUp

Title

Save Cancel

Here is the javascript code to initialise the widget and open it.

//making a popup which will not take you back to the previous page.
$('#popupDialog').popup({history: false});//awesomeness
$('#popupDialog').popup('open');

Happy coding :)

Things to consider for Cordova (phonegap) development

This came to me as a learning from my first Cordova(phonegap) application development.
The first thing one comes across while developing in Phonegap is “the need for a GUI lib” and the first thing to get in a search result is jQuery, its mobile version and the UI lib. There are many other good libs out there, but this one seems quite ok. While one may choose to use a UI lib or build own lib its up to the developer. In my experience its easy to get started with jQueryMobile and its UI, which uses “Theme roller” to theme the UI.
If one is using jQueryMobile then the trick is to try and solve all the UI problems with this lib itself (not hacking the CSS and JS all over the place in the project). That way the performance will be more and pain to solve all the UI problems is less.

One can just start to make one Cordova application without any libraries, but to be productive soon, the minimum required libraries are
1. jQuery
2. jQueryMobile
3. cordova

Now the most important library which might not be required for the project as a project dependency but is a real time saver is
1. UnderscoreJS
After some playing around with the library and from the suggestion from the community I found Lo-Dash library, which is a drop-in replacement for UnderscoreJS with performance enhancements. So I would recommend using
1. Lo-Dash

Now to coding tips, if one knows the “scope” and “this” in javascript, then writing javascript applications are just fun. So prepare yourself with javascript and how it works, so as to make your life easier developing the application.

Target platform and the library support :
The current Cordova lib might not support your required target platform !! Yeah, that is another thing which might take up sometime to know in the beginning. With each release these libraries kind of deprecate support for old platforms, so check that out in the beginning itself.
The same goes for jQuery and jQueryMbile. Check out whether the latest version of the library supports your target platform.

Native Notifications in Cordova is not supported :
Cordova (phonegap) does not support native notifications. It only supports “alerts”,”confirm” (kind of alert only),”beep”(sound) and “vibrate” (device vibration). But then if you expect to do “alert” notification as iOS and Android devices do (like showing the alerts to user when the application is running in background), then Cordova (phonegap) does not help. One has to write native libraries in native languages and call them from javascript through Cordova.

jQuery tips :
Adding an element to a page and displaying it :
jQuery “append()” and “prepend()” does not update the UI (or DOM), so the added elements are not visible by default. we can hack it by dispatching a jQuery event called “create”, the code will look as below

$("#p_4_content").prepend("hello World").trigger( "create" );

That will tell jQuery to render the UI again, resulting in displaying the added item.

Defining EventHandler Scope :
Another nice thing is calling the event handler in required “scope”. The jQuery library provides a handy method for adding event event handlers as

$('#id_btn').on( 'tap', onBtnTapped );

But then it will be scoped to the same scope as where its being written. If you are writing things in an Object, you might want to get the “scope” in the handler(which is “this”), in order to do that, jQuery provides a “third” parameter option, and one can pass the scope in there. The optional parameter is at the middle instead of at the end (as comparing to other object oriented programming convention)!! But then its the way to go. So the modified code will look as below

$('#id_btn').on( 'tap', this, onBtnTapped ); //Look at the middle parameter
//and the handler code looks as below
onBtnTapped :function(event){
    	//just saving the scope, may be we need it in future here
    	var that = event.data; //here event.data=this (which we passed as second param)
    }

That way inside the handler we can get the “scope” as below

var that = event.data;

The second parameter sent while binding the handler to the event, can be got inside the event handler as “event.data”. Since we are just passing “this”, we can get that in the handler as the example shown above.

Writing the EventHandler :
Well, now the trick writing an eventhandler without making the application behave unreasonably is a challenge. It might sound silly but it is not. If you write an event handler as

onBtnTapped: function(event){
    	//Do something
    }

Then its bound to get in your way of the behavior of your application. The jQuery fix is to do a “return false” in all the handlers. But then that might not be the case of your handler as that might return in between the code itself. So the fix is make a call to “preventDefault” as soon as you are inside the handler method. the modified code will look as below

onBtnTapped: function(event){
        event.preventDefault();
    	//Do something
    }

That is the start, I will post more tips as I fight through the scenarios.

My first workable Android application, AFinder.

On my quest with different tools/languages, I started on OpenPlug|Studio for developing in Android. Though this is a tool for developing for multiple devices, I specifically tried this for Android for the time being.
This IDE is based on Eclipse and there are two flavors of installations. One installs it directly as a standalone IDE and you have option to install it over FlashBuilder. The development is also based upon the same component style development as in Flex SDK. There is a different name-space for mobile specific UIs. they start with “mob” rather than “mx”. From compiling to publishing as an .apk file for android device installations are quite straight forward. The best part about the IDE is its completely free. Well then it has potential as to one codebase and publish to multiple platforms. The community at OpenPlug|Studio forum seems active too and one can feel there are a lot going behind as to fix up bugs and add new features to the tool set. Though there are bugs and features to be added, but as I said, once you involve in forum, you got to know they are already working on it and new releases are happening almost in 2-3 months.
Here is my basic Android application to move around your file system on the device. Would love to listen the feedback.

Lua : getting started

At very basic Lua syntax is very flexible. Lua can interpret the line ending!! I am serious. For example the code below

local a=6 local b=5 print (a+b)

is exactly same as the code below

local a=6 
local b=5 
print (a+b)

That means we can go ahead writing like the code below too.

local 
a=6 local b
=5 print 
(a+b)

But then comes readability. Its generally better to write code, which we, ourselves can read later too !! So generally one statement per line is a convention.
Now for the declaration of variables, by default any variable declaration is a global variable, unless we define it as a local variable with the ‘local’ keyword as follows.

local a=1
local b='string'

If we remove ‘local’ keyword, the variables are global.
Any variable declaration can contain any kind of values, i mean its not mandatory for a variable to store one kind of values, Lua interpreter can take care of that.
For people who are used to semicolons at the end of the statement, can write that way too and Lua interpreter can take care of that too.

local a=6;
local b=5;
print (a+b);

Writing a for loop in Lua is as below

for i=0,10 do
print (i)
end

Writing a conditional statement is as below

if(a>b) then
print ('a>b')
end

Similarly the if-else would be as below

if(a>b) then
print ('a>b')
end if(a

Finally the way we load different .lua files is through 'require' as follows

require "newFile.lua"

Finally there is a way to start experimenting with Lua without even installing it. This is through the Web Lua project.

With that I think we can get started with this small but powerful language, Lua.

Lua : My experience with it.

Well, on my journey with mobile development, I picked up Lua for sometime. I am quite impressed with its simplicity and power. If you do not know, Corona SDK provides Lua scripting language to build applications for mobile devices. The popular Angrybirds game utilises the power of Lua.
Basically its a simple language with very minimum number of key words and language syntaxes. Anyone familiar with javascript or actionscript can start jumping into it and be productive from day one. There are variants of the installer for Mac and Windows. Some what I feel Windows installer is the best and has got its own IDE, which is on top of popular SciTE IDE.
There is a complete 2D game engine / framework for Lua named Love. With that one can instantly start creating Lua games. As Lua is simple, so as Love is. But then one gets a whole lot of goodies out of a framework. I would say a must try for any game developer.
There is a nice framework for iPhone, which uses Lua and its called WAX. This also fits Lua’s philosophy as to keep the framework simple and easy. The best part is, once you start coding in WAX, you do not have to think about memory management, which is very important and sometimes most time consuming act, while developing application with ObjectiveC.
Now that I have seen Lua’s power and simplicity, I will try that out more and more and post updates about my experiments. Here are some Lua related links for you to get used to
1. Users, tutorials and more
2. Love : 2D game engine
3. WAX : iOS development framework
4. 2D Engine A 2D game engine (I Have not tried yet)
5. Luxinia 3D game engine (I have not tried yet)
6. Lua Forge Projects, tutorials and more
7. Baja Engine A game engine (I have not tried yet)

With that I think I also have to pick up some engines and start playing with it. Overall, Lua feels just perfect as its simplicity and power. Its portable and lightweight. After all its Opensource and Free.

One size fits all, does not fit.

I heard this one before, but then kind of ignored. Why?!! For I, as a web and desktop designer and developer when started iphone development it seemed, “ok, fine, lets do the design and go for development” . Iphone and any iOS in that case have a clear guideline of user interactions. So no worries, if I am sticking to those guidelines, I am sure the product will have a nice user experience. Keeping that in mind, I moved on. And then it all went well. Until I started developing for other devices and other OS such as Android.
Developing games on the other hand is not about those default navigations, one has to think of it from the gaming UI perspective. So what I think is while game design can be one design for multiple devices but the size factor does the trick. If a game is designed for 2 different mobile phones (may be different make too of same OS), it does not matter which OS they are running in, as long as the size of the device screen is kind of same, we are good to go. But then if at all there is a difference in the ratio of height and width of a device screen, the design needs some tweak to give the user a same or similar user experience.
Now, if we talk about application design for mobile, then its all together different approach. Apart from the size, one has to take into account, the platform that is running the application. This surprised me, when I was trying to port an application from iphone to android. Well, we can just port it and it will work the same way it works on iphone, but then there are different physical buttons present in Android devices (even Windows mobile phones and other OS phones), which are not present in iOS devices. The point is either we are not utilising the UI of the device or making a bad use case of the UI of the device and in turn our application, if we port one application as is to another device.
So clearly, each device will have a different design, the code base may be same, but design must be different to be useful and give the same user experience through out devices.