Saturday, August 29, 2009

Android Book Mobile

I entered my Android application into the Android Developer Challenge II. You can read more about what "Book Mobile" does and my thoughts behind the name over at the product website.
  • I've integrated the Google book api into Android.
  • I use the GoodReads api to get reviews for books.
  • I integrated with zxing for barcode scanning to read ISBNs.
  • Because of this missing feature in Android I had to draft my own login dialog for users to enter their google account credentials.
Now for the frustrating part. How they setup the registration/entry process to the ADC means if I want my application available on the market, I have to repackage. This means changing the AndroidManifest.xml and refactoring all the code to have a new package structure. That doesn't seem so bad, right?

Thursday, August 27, 2009

Launch Explorer.exe from Cygwin

Working in cygwin, I often need an explorer window to my current directory or a sub-directory there of. I called this script expl.sh.
#!/bin/bash
export p=`pwd`
export pc=`cygpath -w $p/$1`
explorer.exe /root,$pc &
Once you have this the directory on your path where you keep your scripts: perhaps ~/scripts:
expl.sh
expl.sh some/sub/directory

Monday, August 24, 2009

Google App Engine and GWT

Well, I started poking around with Goole app engine in Eclipse. By default they want to use GWT. fine. Someone once said, "when drinking the tainted cool-aid you might as well eat the cookie too." (if no one said it then I just did)

Well, I develop on Ubuntu and immediately ran into an UnsatisfiedLinkError.
** Unable to load Mozilla for hosted mode **
java.lang.UnsatisfiedLinkError: /home/user/projects/gwt-linux-1.5.3
/mozilla-1.7.12/libxpcom.so: libstdc++.so.5:
Thankfully, this was the first hit on by search. Thank you

Monday, August 3, 2009

When to Refactor

It's common knowledge that you don't write code in a software project to solve future problems. Don't implement code that is not needed.

It occurred to me that the inverse is true for refactoring. I will not delay a refactor because we expect to have a requirement that will make it obsolete. You never know which features/tasks will be canceled or delayed. You should ask yourself, "How long am I willing to support this ugly code?"

Tuesday, May 12, 2009

Subversive Eclipse on Jaunty Ubuntu

I got all obsessed over the weekend. I needed stable sound from my laptop. I mean really, who can code without music!? I don't want to talk about that. I had a painful path form Hardy to Jaunty. But that's not why I'm posting.

After a complete re-install of Ubuntu I was reinstalling Eclipse and Subversive. It failed. The "SVN Connectors" drop down was empty. Turned out I fell victim to a bad link over to Polarion. That was answered over on stackoverflow. As stated in that answer, this is the right update site url to get the connectors from Polarion: http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/


I wanted to use the javaHL connector, so I also needed this step.

  • sudo apt-get install libsvn-java
  • put "-Djava.library.path=/usr/lib/jni" in eclipse.ini


Thanks guys/gals. Hopefully I won't forget how to do this stuff. (next time an OC urge strikes to set myself back 3 days)

Sunday, March 1, 2009

J2EE Connector Architecture

J2EE Connector Architecture (JCA) is a little used aspect of J2EE that is probably now relegated to obscurity due to the popularity of web services. It is however a viable solution to many problems. You can still find it documented at sun. You can also rather nicely integrate Spring.

I put this short presentation together. Contact me if you would like the three Eclipse projects.

Tuesday, February 17, 2009

Android Custom Component Merge

I created my custom component that extends LinearLayout. In that post I show that the root element of the components XML is a <LinearLayout ...> element. That ended up getting in the way. When the LayoutInflater built the view in my Java PersonComposite extends LinearLayout the default behavior was that my java class now had one child, the LinearLayout that is the root of the XML. This meant that each use of <my.app.PersonComposite ...> in other view XML would never apply configuration to the Linearlayout that has any effect.

Wow. Even I don't understand that. Let's try this way. The LayoutInflater, actually created the following structure (details omitted for brevity):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout >
<LinearLayout >
<TextView .../>
<TextView .../>
</LinearLayout>
</LinearLayout>
So any attempts to use the component like this would never change the orientation of the two nested TextView Components because the configuration was applied to the outer LinearLayout:
<my.app.PersonComposite
android:id="@+id/person"
android:orientation="vertical"
/>
Solve this problem by using <merge> as the root element. And make sure you invoke LayoutInflater:

LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View inflatedView = inflater.inflate(R.layout.person_composite, this);
Now the person_composite.xml looks something like this:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<TextView .../>
<TextView .../>
</merge>
You can see how this works by getting the android source from git and looking at the source code for the LayoutInflater.inflate method. then search that same source tree for an xml that uses <merge> as the root element. You'll find more than one.