Friday, November 26, 2010

At the release meeting ...




Saturday, November 20, 2010

Using formatted text (in code) on Android

Putting text into a TextView on Android is easy - you just use TextView.setText(text) unlike other overloaded methods with the same name, you can not just use a String with Html formatting to format the passed text.

In order to do so, you either need to obtain the text from a resource file, use Html.fromHtml(String html) helper method or create a SpannableString that can then be passed to the method.

Html.fromHtml() is actually very convenient:

String s = "This is a <b>fat</b> string";
TextView tv = .. ;

But while working on Zwitscher I saw that Html.fromHtml() is actually very expensive to use, as internally it is using the whole arsenal of XML parsing.

Plan B is using SpannableString...

Creating such a text is a bit complicated as you need to deal with individual Spans and so on, which I found inconvenient.

So I've introduced a SpannableBuilder helper class to make this process easier.

Usage is as follows:

SpannableBuilder builder = new SpannableBuilder(context);
      .append(R.string.resent_by, Typeface.NORMAL)                
      .append(status.getUser().getName(), Typeface.BOLD);

Using this helper class does not trigger any XML parsing and is thus a lot faster than Html.fromHtml().

So far only methods that deal with TypeFaces are implemented, but extending the class for modifications of the background would be easy.

Using the camera (from your programs) on Android is easy ...

... if you know how to do it.

If you don't know it, it can be a PITA as I have e.g. described at the Android-Tech-Talk in Stuttgart.

For Zwitscher I was for quite some time trying to enable it to take pictures and upload them to pictures services like with other Twitter clients. So I started looking at the documentation and found a How To entry which basically points to the documentation for the Camera.  So I've been trying around with the preview stuff and was googling like crazy and so on, but this turned out to be too complicated for me to follow in the short term.

Yesterday I was reading about Intents in the Documentation and what Google Intents are available. This brought me to the idea of investigating if the camera could also be called that way.

So I've googled for "android camera app intent" and found this forum post which explains how to do it.

Basically start the camera via:

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 1);

and then later when the picture has been taken fetch the picture in the onActivityResult() callback:

public void onActivityResult(int requestCode, int resultCode,Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==1&& resultCode==RESULT_OK) {
Bitmap bitmap = (Bitmap) data.getExtras().get("data");

This takes a small picture suitable for e.g. Twitter.

To take a larger picture you need to tell the intent where to store a larger picture and pick it up from that location.

intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, path)

So you see - if you know all this, it is fairly easy to start the camera, take a picture and then use it later. No dealing with PreviewHolder and all that stuff.


Thursday, November 04, 2010

Small tip when repeatedly doing upgrade testing

Suppose you want to test upgrading your software from version x to y. This often includes updates of database schemas, tables and content.

The obvious way to do this is

do {
install version x
quit x
install version y
verify upgrade
} while (upgrade was bad)

The install version x step here is usually time consuming and involves UI interactions.

A better approach here is to

install version x
create a db backup
verified = false
while (not verified ) {
install version y
if ( upgrade good )
verified = true
install db backup

With PostgreSQL taking a backup would look like this:

pg_dump -f outfile -b -C dbname


pg_dump -f ~/jon231.dump -b -C jon231

and then the re-install:

pg_restore outfile


pg_restore ~/jon231.dump

Wednesday, November 03, 2010

Mein erster Android-Vortrag - und wie geht nun es weiter?

Gestern habe ich bei der STUGTUG in Zusammenarbeit mit der JUGS beim Android TechTalk meinen ersten Vortrag zum Thema gehalten.

Ich wurde gefragt, ob ich so über meine ersten Erfahrungen erzählen könne, was ich dann auch gemacht habe - nachdem ich mich an Hand von konkreten Beispielen in eine Materie einarbeiten muss habe ich eben von den Erfahrungen mit meiner ersten App, Zwitscher, berichtet (Folien gibt es hier und hier das Video). Peter Hoffmann hat einen Review geschrieben, wie auch Benny. Alle Videos sind in diesem Album zusammengefasst.

Die Auswertung der Feedback-Bögen gibt ein eher gemischtes Bild. Von "Sehr gut" bis "Kann ich nichts mit anfangen, weil ..."  "... ich nicht weiss was eine Activity ist", "... ich das schon seit Jahren mache" war alles dabei. Der Notendurchschnitt lag bei 2,8.

Mein Fehler war hier offensichtlich, für Anfänger in der Android-Programmierung schon zu tief in der Materie gewesen zu sein, während für die "alten Hasen" nicht so viel Neues dabei war.

Deswegen habe ich mir jetzt mal vorgenommen, möglichst bald einen Workshop für Einsteiger anzubieten, bei dem eine kleine Applikation von Null aus aufgebaut werden soll. Der Workshop wird dabei nicht nur "Frontalunterricht" sein, sondern die Teilnehmer sollen / müssen selbst Hand anlegen (Java SE Kenntnisse müssen vorhanden sein).

Hierzu nun ein paar Fragen:

  • Wird so was (= Einsteiger-Workshop) überhaupt gewünscht?
  • Was ist ein möglicher Zeitrahmen (am Abend, Samstag, Wochenende, Weihnachtsfeiertag, ...)
  • Was darf es kosten? Der Workshop ist non-Profit, aber Räume, WLAN, Getränke und Brötchen / Pizza kosten einfach Geld
  • Was für eine App soll es werden?

Ich habe auch eine Idee für einen umfangreicheren Workshop im Hinterkopf, möchte dazu erst mal noch nichts verraten ;-)



Tuesday, November 02, 2010

RHQ tab sweep

It has been a while since the last tab sweep, so quite some material has accumulated:

First and notably: we now have contributor guidelines, which should make it easier for everyone to get contributions into RHQ.

Alexander Kiefer has finsihed his master thesis work on the Nagios Plugin and the dynamic types detection. The later work needs to picked up and worked on further. A big part of the resource type (and metric scheduling and .... code depends on the static nature of the metadata in the plugin descriptors. The code is currently in the nagios branch in git.

Anyway: congrats Alex and many thanks for your work and also thanks to your employer, AG der Dillinger Hütten,for sponsoring this work.

Steve Millidge contributed a large overhaul of the MySQL plugin to RHQ - thanks Steve!

The team is currently working on transitioning the UI to GWT for RHQ 4. To see what is going on, you can have a look at a short video overview or play with the first developer preview.

And then there was conference season for me and I gave talks at JUDCon Berlin and 1daytalk Munich:

Mazz has written an interesting article on how to do some RHQ agent profiling via Byteman. He also wrote about remotely installing agents on yet unmanaged machines.

Joseph Marques has written a short article on the new search functionality and a longer analysis on GWT compile performance - this is quite interesting and for sure also helpful for other projects that want to use GWT.

John Sanda has written a whole series of articles on usage of the RHQ cli:

Jay Shaughnessy has also written an article about the RHQ CLI. He is talking about using the provisioning feature from the CLI.

Lukáš Krejčí has also written a series of articles:


As always, please give us (and / or the article writers feedback).