Can I do some work for you?

If you like what you see and would like to get some pricing going, please drop me a line at web@federicojacobi.com. I'll get back to you as quickly as I can.

Thanks for visiting my site!

@federico_jacobi

I'm in awe with they are somewhere in between instagram and reddit

Update on App code | Incomplete Cash Calculator

Tags: , — January 22, 2011

So far a couple of things learned:

  • If you know java or object oriented programming, the learning curve is WAY less steep, but steep never the less.
  • The icon for your app can be found in /res/drawable-ldpi (and mdpi, and hdpi)
  • With out input there’s very little to do, so the basic of all basics is EditText. To get it’s contents use YourObject.getText().toString() which implements comparable so use equals() to compare.
  • If you want to get numbers only, even though it seems good practice to sanitize the input, you can specify in the XML layout android:inputType=”numberDecimal” to restrict input.
  • Setup layouts in XML and handle the mechanics through code. Keeps the UI separate from the code, and it is WAY easier to define.
  • Dialogs can have custom setups through XML.
  • Dialogs are created ONCE, so in this application, for example, you want to get the final number to make your invoice to before taxes. If you go with the google examples, chances are, the first time you do it, it’ll be fine, change your values and show the dialog again, now it reads exactly the same. If you need the SAME dialog to display different info you either create a new one, or keep a reference of the old one and modify the values of the actual Dialog object. Modifying global variables is not good enough.

Here is the code:

package com.example.helloandroid;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class HelloAndroid extends Activity implements OnClickListener {

	String message;

	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button button = (Button)findViewById(R.id.calculate);
        button.setOnClickListener(this);
    }

    public void onClick(View v) {
    	EditText cashobj = (EditText)findViewById(R.id.cash);
    	EditText taxobj = (EditText)findViewById(R.id.tax);

    	if (!(cashobj.getText().toString().equals("") || taxobj.getText().toString().equals(""))) {
        	Float cash = new Float (cashobj.getText().toString());
        	Float tax = new Float (taxobj.getText().toString());

        	if ((cash > 0) && (tax>0) && (tax<60)) {
    	    			Float valor = ( 100 * cash ) / ( 100 + tax );
    	    			message = new String(valor.toString());
    	    			showDialog(1);
        		} else {
        			showDialog(2);
        	}
    	}

    }

    protected Dialog onCreateDialog(int id) {
        Dialog dialog;
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        switch(id) {
        case 1:

        	builder.setMessage(message)
        	       .setCancelable(false)
        	       .setTitle("Make Invoice for:")
        	       .setNeutralButton("Ok", new DialogInterface.OnClickListener() {
        	           public void onClick(DialogInterface dialog, int id) {
       	    				removeDialog(1);
        	           }
        	       });
        	dialog = builder.create();
            break;
        case 2:
        	builder.setMessage("Check your numbers, something is so not right")
        	       .setCancelable(false)
        	       .setTitle("ERROR")
        	       .setNeutralButton("Ok", new DialogInterface.OnClickListener() {
        	           public void onClick(DialogInterface dialog, int id) {
        	                dialog.dismiss();
        	           }
        	       });
        	dialog = builder.create();
            break;
        default:
            dialog = null;
        }
        return dialog;
    }
}

Android App from nothing.

Tags: , — January 15, 2011

Today I will start an Android App from 0% which I will try to document here for 2 reasons: help other people that don’t know anything about App making and to force myself to write. At this point I have written some Java, and by some I mean very little, minimal C++, and tons of PHP. It doesn’t matter the language, programming is a thing of structure and logic. Language is a matter of syntax and getting used to new functions/commands. This is by no means a how-to guide. It is just my way of sharing my experiences in the proccess.

That being said you need the following:

  1. Programming knowledge (if you know Java, you are pretty much ready, just go to developer.android.com and find your way)
  2. Java 1.5 or better
  3. Eclipse
  4. Android SDK
  5. ADT Plugin for Eclipse
  6. Lots of patience and lots of reading

Follow the instructions on http://developer.android.com/sdk/installing.html and get ready to try to run your typical Hello World (Hello, Android) example. First thing I noticed is that it didn’t work.

If you see the “Emulator” with your fake phone means that it DID work, but nothing will happen until you turn your fake phone ON!!!. It takes a while for the fake phone to boot, just like it does your real phone. Once it starts you’ll see your nice app working.

Stupid, but important.

As a learning experiment i will port my useless application “Incomplete Cash Calculator” to Android.

I hope that all that I write from here on, actually helps you. In advance I apologize as I don’t expect the posts to be very long or explicative.