Wednesday, April 28, 2010

Musix On The BlackBerry Device

I got a demo device from TriPlay to show off Musix running on the blackberry device using the blackberry native LWUIT port.

The UI worked pretty smoothly and was relatively easy to port, most of the work in porting was related to networking on the RIM devices which is really complicated.

While the menus/UI is in Hebrew the application shows off background downloading with decryption on the fly of DRM protected music. It also shows off album purchase (e.g. the Pixies album in the video).

Tuesday, April 20, 2010

New Article From Biswajit On Styles & Themes

Biswajit Sarkar has written another java.net article about styles, painters & themes. Its more up to date with the current style architecture in LWUIT than other articles covering the subject.
His article also covers some other new LWUIT features such as tables.

On an unrelated note Ofir got tasked last week with getting a LWUIT application to run efficiently on Symbian OS 8. He benchmarked the application and discovered that the cause of performance issues is the existence of an alpha channel in the images. The performance difference he showed us was staggering!
We always new bitmap fonts were slower on such devices (an image with an alpha channel) but it seems that even simpler transparency (without translucency) might make a huge difference.

Sunday, April 11, 2010

Back On The Touch

I always liked the aesthetics of the iPhone back behavior, placing the back button as a small arrow within the title bar is a stroke of UI design genius. I don't share Apple's disdain for physical buttons so I'm much more in favor of a physical back button, however having that button in the title area is both handy and none intrusive.

Often people ask us to customize the title area for things other than Labels, normally when a use case is so common we comply even when it goes against our core aesthetics of UI design. However, this is a special case where making such a change would break the simplicity of customization to everyone else involved.

However, in the spirit of LWUIT for making everything reasonably easy to accomplish even these iPhone like back buttons are very possible and easy to accomplish. There are two challenges involved: the shape of the button and its position in the title.

The shape of the button is solved by creating an image border with the proper shape and updating the theme, I won't publish the resource file since the images here aren't owned by myself.

Placing the button in the title of the UI Demo requires the following change to the Demo.java class in the UI Demo. In the run() method change the demo form creation to this:
final Form demoForm = new BackTitleForm(backCommand);

And add the BackTitleForm as an inner class (pasted bellow). Back title form is a simple form extension that essentially creates a content pane within the content pane and creates an alternate title component that can be anything.

    class BackTitleForm extends Form {
private Container contentPane = new Container();
private Container title = new Container(new BoxLayout(BoxLayout.X_AXIS));

public BackTitleForm(Command backCommand) {
super.getContentPane().setLayout(new BorderLayout());
super.getContentPane().addComponent(BorderLayout.CENTER, contentPane);
super.getContentPane().addComponent(BorderLayout.NORTH, title);
Label titleLabel = new Label(getName());
title.getStyle().setPadding(0, 0, 0, 0);
title.getStyle().setMargin(0, 0, 0, 0);
titleLabel.getStyle().setPadding(0, 0, 0, 0);
titleLabel.getStyle().setMargin(0, 0, 40, 0);
titleLabel.getStyle().setBgTransparency(0);
title.setUIID("Title");
Button backButton = new Button(backCommand);
backButton.setUIID("BackButton");
backButton.setPreferredH(42);
title.addComponent(backButton);
title.addComponent(titleLabel);
}

public Container getContentPane() {
return contentPane;
}

/**
* Removes all Components from the Content Pane
*/

public void removeAll() {
contentPane.removeAll();
}


/**
* @inheritDoc
*/

public void setLayout(Layout layout) {
contentPane.setLayout(layout);
}

/**
* Adds Component to the Form's Content Pane
*
* @param cmp the added param
*/

public void addComponent(Component cmp) {
contentPane.addComponent(cmp);
}

/**
* @inheritDoc
*/

public void addComponent(Object constraints, Component cmp) {
contentPane.addComponent(constraints, cmp);
}

/**
* @inheritDoc
*/

public void addComponent(int index, Object constraints, Component cmp) {
contentPane.addComponent(index, constraints, cmp);
}

/**
* Adds Component to the Form's Content Pane
*
* @param cmp the added param
*/

public void addComponent(int index, Component cmp) {
contentPane.addComponent(index, cmp);
}

/**
* @inheritDoc
*/

public void replace(Component current, Component next, Transition t) {
contentPane.replace(current, next, t);
}

/**
* @inheritDoc
*/

public void replaceAndWait(Component current, Component next, Transition t) {
contentPane.replaceAndWait(current, next, t);
}

/**
* Removes a component from the Form's Content Pane
*
* @param cmp the component to be removed
*/

public void removeComponent(Component cmp) {
contentPane.removeComponent(cmp);
}
}

Sunday, April 4, 2010

Biswajit Sarkar Talking About J2ME & LWUIT

With the current holidays around here and quite a bit of work I didn't keep up the blog as I probably should. I'll try to get back into posting soon when everything calms down around here. While waiting for me to get my act together here is a talk that Biswajit Sarkar (author of the LWUIT 1.1 book) gave at the IndicThreads conference in India.
This talk is mostly for introduction to J2ME development and covers LWUIT among many of the subjects mentioned.
Its probably too introductory level for most of the readers of this blog, however it might be very useful to pass along to colleagues as a means of introducing them to J2ME/LWUIT. Biswajit is as usual very thorough in his details which is always important when discussing something as elaborate as mobile development.