venerdì 27 agosto 2010

My blog has been moved

My blog has been moved to http://www.ugochirico.com

Il mio blog è stato spostato a http://www.ugochirico.com

venerdì 11 dicembre 2009

Greeter per inviare messaggi d'auguri

In occasione dell'approssimarsi delle festività natalizie, quando per consuetudine ci si scambia SMS e MMS d'auguri, ho rilasciato Greeter, una nuova applicazione gratuita per telefoni cellulari che consente di inviare fantastici SMS e MMS d'auguri già pronti per ogni occasione.

L'applicazione si installa su qualsiasi telefonino Java e contiene centinaia di frasi d'auguri e di immagini già pronte e personalizzabili per le occasioni più importanti: Natale, Capodanno, San Valentino, Compleanno, ecc.



Il sito web di Greeter è: http://www.greeter.it
L'applicazione può essere scaricata dal browser del telefono cellulare
collegandosi al sito http://mob.greeter.it oppure dal sito web http://www.greeter.it

lunedì 2 novembre 2009

Animated GIF using LWUIT

Since a couple of weeks ago, I'm working on moving my mobile applications to a new attractive user interface using LWUIT (LightWeigth User Interface Toolkit).
I found LWUIT really very impressive and the results are really excellent: my mobile apps now are much nicer then before.
But I found some little lacks in LWUIT. The most relevant is the lack of a class to manage animated GIF at runtime.
As of this writing, the current version of LWUIT supports animated gifs only if they are added in the resource file by the Resource Editor as "Animated Images". Such animated images can be added to a Label, to a Button or to another component and are animated when shown.
What I mean is that there are no way to use an animated GIF as animated image in a component if the gif is loaded at runtime from an input stream. Also, there is no way to manage the animation loop programmatically (i.e. stopping and starting the animation).
So, I googled a little to find a solution. First of all I found several posts related to that. This means that such a lack is involving several programmers. Second, I found the class GifDecoder ported to J2ME for decoding any animated gif.
Starting from that class and reading how the class StaticAnimation of LWUIT is implemented I wrote a new class AnimatedGIF, derived from the class com.sun.lwuit.Image, that allows to use animated gif at runtime in your applications.
You can use it as any other image.
The following is a snippet that shows how to create a Button with a animated gif image:

AnimatedGIF image = AnimatedGIF.createAnimatedGIF(
    new ByteArrayInputStream(btImage));
Button btn = new Button();
btn.setIcon(image);

The source code can be downloaded from here and it is published under LGPL.
Mainly this is the most relevant topics:
- the package must be com.sun.lwuit because I need the costructor Image(Object) that has package visibility (I think it should have protected visibility)
- an animated gif is rapresented as an array of frames
- the frames are generated by the class GifDecoder
- a gif is animated if it has more then one frame
- the animation can be started and stopped on demand by the method start and stop
- the loop counter can be set by the method setLoopCount
- the rest of the code has been taken and adapted from the class StaticAnimation

For more info about LWUIT visit this url http://lwuit.dev.java.net).

venerdì 16 gennaio 2009

Commodore 64 o Windows Vista?

Nel 1969 è bastata la potenza di calcolo di due Commodore 64, con CPU da 4Mhz e 64 KB di RAM, per mandare una navicella sulla Luna.
Nell'anno 2009 è necessario un Intel Centrino Dual Core da 2Ghz con 2GB di RAM e Hard Disk da 120GB per far funzionare Windows Vista.

mercoledì 11 giugno 2008

gmail app su windows mobile

Per l'ennesima volta mi sono imbattuto nell'installazione dell'applicazione Gmail client su un dispositivo Windows Mobile.
Poichè penso che sia un argomento che possa interessare molti altri possessori di Smartphone e PDA Windows Mobile (che probabilmente hanno avuto i miei stessi problemi), mi sono deciso a scrivere un post sull'argomento con l'intenzione di fornire una guida per l'installazione.
L'help di Gmail si limita a dire che l'applicazione Gmail non supporta Windows Mobile (vedi questa url) tuttavia suggerisce di provare con la JVM fornita da IBM, che tra l'altro ora sembra introvabile (io, fortunatamente l'ho scaricata tempo fa quando era ancora disponibile sul sito ufficiale).
Fortunatamente ciò che dice l'help è totalmente errato.
Ho installato con successo Gmail sul mio LGKS20, sul vecchio HP rw6815 e su un Toshiba G500 e, conoscendo bene anche gli HTC, sono sicuro che la procedura funzioni su qualsiasi cellulare Windows Mobile.
In primo luogo, occorre assicurarsi che sul proprio cellulare ci sia una Java Virtual Machine (JVM). In Start->Programmi dovrebbe esserci l'icona relativa. Sugli HTC, sugli HP e sui Toshiba dovrebbe esserci quella di Esmertec. LG ne ha una senza marca (o almeno non riesco a capire chi l'abbia sviluppata), sugli I-Mate non ricordo ma sono sicuro che c'è. Tuttavia se il vostro non ne ha una si può installare quella di IBM.
In secondo luogo occorre scaricare la MIDlet dell'applicazione gmail ossia il fatidico file gmail-g.jar.
Chi, come me, ha provato la procedura standard prevista per il download e l'installazione di applicazioni java, ossia, ha fatto puntare il browser o la JVM alla url http://gmail.com/app suggerita da Gmail, ha fallito miseramente ricevendo un messaggio che approssimativamente dice:-"I parametri del file .jad non sono corretti" o qualcosa di simile. Questo errore è dovuto ad una errata risposta del server di gmail che non viene compresa dalla Application Manager della JVM che, pertanto, non riesce ad installare l'applicazione.
La procedura corretta invece è questa:
1) scaricare sul PC il file gmail-g.jar (v.1.1.1) da questa url:
http://gmail.com/app/v1.1.1/L1/gmail-g.jar
2) copiare il file gmail-g.jar in una cartella sullo smartphone (mediante Active Sync o bluetooth)
3) sullo smartphone, aprire la cartella dove è stato salvato il suddetto file (con Esplora File)
4) clickare sul file gmail-g.jar (questa operazione farà partire la JVM)
5) seguire le istruzioni che compariranno sullo schermo.

Buon divertimento...

giovedì 8 marzo 2007

My application is running on Vista?

Yesterday I find an answer to the following question: my application is running on Vista or not? The following is a peice of code which gets the Windows version of the underling operating system including the latest release of Vista:

#define OS_UNKNOWN -1
#define OS_NT4 0
#define OS_2000 1
#define OS_XP 2
#define OS_2003 3
#define OS_VISTA 4

int getWinVer()
{
    OSVERSIONINFO osVerInfo;

    osVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

    GetVersionEx(&osVerInfo);

    if(osVerInfo.dwMajorVersion == 6)
    {
        return OS_VISTA;
    }
    else if(osVerInfo.dwMajorVersion == 5)
    {
        if(osVerInfo.dwMinorVersion == 2)
        {
            return OS_2003;
        }
        else if(osVerInfo.dwMinorVersion == 1)
        {
            return OS_XP;
        }
         else if(osVerInfo.dwMinorVersion == 0)
        {
            return OS_2000;
        }
    }
    else if(osVerInfo.dwMajorVersion <= 4)
    {
        return OS_NT4;
    }
    else
    {
        return OS_UNKNOWN;
    }
}

mercoledì 7 marzo 2007

Piede al tramonto / Foot at sunset