Dependency Injection in Android

October 29, 2010 1 comment

I’m a big fan of the Android OS. I like its openness in the same way as I like the openness of Java. Besides, programming in Android has a flavor so close to Java that I cannot be other than sympathetic towards it.

Since 2005 I got unit-test infected. Well, I feel I’m not infected that bad because I still tend to write the main functionality first. Then I write a test that covers that main functionality and (eventually) fix the errors shown by it. Then I just add test after test until I feel I covered all the functionality required.

Writing tests wouldn’t be so much fun if Spring was not around. Having those mocks automatically injected for me makes me be more productive when writing tests: I don’t have to worry to much about the initialization phase since it is taken care for me.

I was wondering these days if I can use DI and unit testing in Android applications as in my usual Java applications. Fortunately I found out that there are two 2 possibilities:

  1. SpringME
  2. Guice without AOP support

Well.. I’m happy with all these alternatives but making a choice is not very easy. I would go for SpringME since I already have working experience with Spring. However, it is based on XML files configurations which is kind of old and sometimes cumbersome to work with. On the other hand Guice 2.0 supports annotations and it’s family to Android, so I expect it to be better maintained in the future.

Both these libraries can be found on Maven repositories, so I cannot differentiate here (I’m a big fan of Maven). However, there could be another reason to choose Guice. I found a possibly-useful library named Roboguice that seems to be made especially for Android and it’s built on top of Guice itself. Plus it offers some help in terms of unit testing Android. However, it looks like it’s not maintained very often (at the moment of writing it showed Medium on the Activity) and its documentation is pretty scarce, so I cannot speculate if it can help me or not.

For the moment I’ll start with Guice no-AOP.. I’ll post again with my findings so come back if you are interested.

Configuring the AnyDATA ADU-510L modem on Mac OS X

August 14, 2009 7 comments

Recently I subscribed to the new VDSL service from Romtelecom for 3 years and, as a bonus, I got the Clicknet Mobile service for free. Romtelecom uses (or at least this is what I got) as modem for this service the following modem model: ADU-510L from AnyDATA.

The modem worked as a charm on Windows, but on Mac OS X I had a few problems.. The modem was recognized just fine the first time when I inserted it into my computer, but then, the next times, it wasn’t. I was getting only screens such as:

Disk insertion

It seems this problem is caused by the zeroconf feature of ADU-510L modem: once it’s installed, the configuration is removed from the USB device (at least this was the explanation that I found somewhere on the net). Hence, any later attempt to install it won’t work. (let me know if this is wrong so I can correct it)

Then I found a few posts on the internet on how to make this modem work on Linux. The most useful was this one, in Romanian (thank you!)

So.. here are the steps I used to make everything work on my computer.. These steps might not work for you, so use them with caution !

  • I installed libusb using macports:
    • sudo port install libusb
  • I downloaded the usb_modeswitch from here and I compiled it:
    • I edited the Makefile:
      • I added the following line at the beginning: CFLAGS = -I/local/include -I/opt/local/include -L/local/lib -L/opt/local/lib
      • I added the $(CFLAGS) in the $(PROG) line below: $(CC) $(CCFLAGS) $(CFLAGS) -o $(PROG) $(OBJS)
    • I un-commented the following lines in usb_modeswitch.conf:

    DefaultVendor=  0x05c6

    DefaultProduct= 0×1000

    TargetVendor=   0x16d5

    TargetProduct=  0×6502

    MessageEndpoint=0×08

    MessageContent=”5553424312345678000000000000061b000000020000000000000000000000″

    • Then I run make && make install to compile and install it.
  • I inserted the modem into the computer (I still got the error dialog above).
  • I executed the following command (this step was inspired by this post):
    • sudo kextunload -b com.apple.iokit.IOUSBMassStorageClass
  • After this, I run the command sudo usb_modeswitch which, to my surprise, was successful.
  • Then I went System Preferences -> Network. A dialog let me know that the modem was recognized..
  • From this moment on, I just followed the docs provided with the Mac drivers.

Yippee ! Now I’m really mobile ! :)

fjar, cygwin and console2

December 15, 2008 Leave a comment

I didn’t write here for a long time – in part because I left my old job in ITC Networks and I had to get used to my new position in IBM but also because I had to finish my SCEA assignment. So now, since I’m a certified Sun Certified Enterprise Architect, I can start again to post here..

Due to my recent job change I’m forced to use Windows XP for a while (one year, I expect). I’m missing some of the tools from Linux and it’s stability. However, I started to find alternatives on Windows for most of the Linux tools I used.

One of the tools that helped me very much when developing Java applications on Linux was fjar.sh. This script will search for each occurrence of a Java class in a folder (searches the jars present in that folder). This is very useful when you know you need a class but you don’t know in which jar it is.

So I had to find a way to make this script work on windows as well (you’ll need to install Cygwin and Console2 to follow the instructions in this post). Enough talking .. here is is:

1) Console2 changes

Create a tab in Console2 with sh as shell. Make sure you add a “–login -i” after it. This way the bash will read the configuration as if it comes from a login process. This will allow you to specify your environment variables in Cygwin only and not mess with the Windows ones.

For me, the shell command looks like this: D:\cygwin\bin\sh.exe –login -i

The -i above makes the shell interactive (basically this helped me to stop the script once it found the file I need)

2) Changes in Cygwin

Create a sh script file in your Cygwin etc/profile.d folder to contain the following:

PATH=/cygdrive/d/cygwin/bin/:$PATH
export PATH

This will ensure that the version of find used by fjar utility is the one from Cygwin, not the one from Windows.

3) Changes in fjar.sh script

One more step now: modify the method doSearch() in fjar.sh utility as follows:

Change the line:
jar tf “$2″ | grep $grepargs “$1″ >$tmpfile
to:
jar tf `cygpath -m “$2″` | grep $grepargs “$1″ >$tmpfile

The change above will send a well-formed path to the jar utility.

Enjoy !

Categories: console2, cygwin, java, tools Tags: , ,

fingerprint reader

June 9, 2008 Leave a comment

As always, on my birthday I try to buy myself something to make me ecstatic, enthusiastic. At the same time it has to be something that can help me in my daily work. Usually it’s a device which keeps me busy for a few days while I configure it and find out everything about it. I know, I know.. it’s a toy :)

So.. this year I decided to buy a fingerprint reader, hoping that it will help me not type my password all the time when I login. However, the only type of fingerprint reader I could find was one from Microsoft. Fortunately there was no problem with the support on Linux (it seems the fingerprint reader is in fact re-branded from Digital Persona). Of course, before buying it I tried to find out if there is support for this type of fingerprint reader on Linux.

And there is support for it – Daniel Drake did a wonderful job writing the driver for it. However, the integration software for this kind of device is not very advanced. I hoped I would only touch the fingerprint reader and the system will let me in. Unfortunately this is not yet possible it seems, so I guess I’ll have to wait until the support is there.

For the moment though I configured it so when I type “su -” it gets activated and I get to login using my fingerprint. But I’m grateful even for this anyway. Hopefully the support will be better in the future..

PS: I read that this kind of devices is not very secure – one guy was able to fool the device with a false print. So I will use the device only at home then .. :)

Categories: Uncategorized

Extreme feedback

April 12, 2008 Leave a comment

In May 2007 I participated in Santa Clara at an Agile training organized by Nortel. I heard then from Mishkin Berteig of other companies who are using extreme feedback for their continuous integration – a lava lamp that starts to bubble when the automated build fails. I thought at that time I should do something like that for my team, so I started to study…

In September 2007 I finally set up a lava lamp for the project I’m in.. I followed the instructions on Instructables site and, except for some small problems, I was able to successfully finish this small agile project. The lamp is working fine now and everybody got accustomed with it; now, when we have a Build failed and the lamp goes on, everybody starts asking who broke it and it gets fixed in no time.

However, currently the lamp behaves like that: it is on when a build is failed and off when all builds passed. This doesn’t say much of the current status of the build (maybe somebody fixed it and it is currently building).

The solution I’m thinking about is to create a circuit containing about 15 leds – 5 leds for each of the following colors: red, yellow and green – and insert them in a white-transparent globe.

The lava lamp would not be a lava lamp anymore, I know.. but it is still an extreme form of feedback. The behavior would change to this one:

  • Red when one of the builds is failed (and the continuum integration engine doesn’t run for this specific build)
  • Yellow if the build was broken previously but currently there is another build running (so somebody took care of the failed build)
  • Green if all builds passed.

Unfortunately I don’t have much time left to finish the project. I would like it to look like this one here.

img_37690001.jpg

I’ll post again when I’ll finish the project (although I’m not sure when this will happen cause I’m preparing for the second SCEA exam ..).

Annoying default keyring password dialog when starting Evolution

April 3, 2008 Leave a comment

When I’m starting Evolution on my recently installed Fedora 8 OS, I’m being asked for a default keyring password. I ignored it for quite a while, but I’m fed up now !

I started to look on forums for a solution and I found one here:

http://forums.fedoraforum.org/forum/showthread.php?t=172827

This solved my problem so no more annoying dialogs for me :)

Categories: Uncategorized

Setting a bookmark in PDF documents

March 26, 2008 Leave a comment

Since I start reading ebooks I was looking for a possibility to set a bookmark in my books. Is seems to me that this basic functionality should not miss, especially from such an application whose main purpose is to let users read electronic books.

Recently my patience got to a limit and I started looking on the Internet if somebody has any solution for this problem. I found a “patch” for the bookmark problem at this page:

http://www.aldenta.com/2006/09/15/plugin-bookmark-a-page-in-your-pdf/

You just copy the javascript file found on the site in a specific folder on your computer and you’ll be able to find the functionality in your Adobe Acrobat !

 

Bookmark in Acrobat Reader

Although the author mentions that he tested it only on Windows and Mac, I successfully installed it on Linux as well.

First post here

March 26, 2008 Leave a comment

This is my first post on my blog on WordPress. Hooray !

I’m using Bleezer to upload my entries – I usually write my blogs offline and then publish them. I don’t know why, but it seems safer this way..

I used to have another blog on Blogger.com, but when I started to use Bleezer I found out it cannot upload photos on the Blogger. It has this feature only for WordPress. Since I had only one post on my other blog, I’ll move it here, to wordpress.

Ok, see you soon !

 

Powered by Bleezer

Categories: bleezer, blogger
Follow

Get every new post delivered to your Inbox.