Adding Android support to Trident

November 27th, 2009

The main goal of Trident project is to provide a general purpose animation library for Java applications. Animations are a natural fit for modern client applications, and Trident has special built-in support for Java based UI toolkits such as Swing and SWT. The latest 1.2dev drop of Trident provides first support for Android, Google’s software stack for mobile devices.

First, a video that illustrates Trident looping timeline that animates the foreground color of an Android button running in an emulator:

And here is the code of the main activity behind this screen:

public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	Button button = new Button(this);
	button.setText("Hello, Android");
	setContentView(button);

	button.setTextColor(Color.BLUE);
	button.setTextSize(30);
	Timeline timeline = new Timeline();
	timeline.addPropertyToInterpolate(Timeline. property(
		"textColor").from(Color.BLUE).to(Color.RED).interpolatedWith(
		AndroidPropertyInterpolators.COLOR_INTERPOLATOR));
	timeline.setDuration(500);
	timeline.playLoop(RepeatBehavior.REVERSE);
}

Those of you who are familiar with the Trident APIs can see that it is the same exact approach as with Swing and SWT. The only difference for Android is the explicit usage of the color interpolator, since the Android APIs use integers for colors – and the built-in mechanism for auto-discovering the matching property interpolator cannot handle this case without explicit coding in either the app code or future Android code base.

Apart from the explicit usage of property interpolator, the application code does not need to handle the UI threading issues (making sure that the TextView.setTextColor is called on the matching UI thread).

If you’re interesting in using Trident in your Android apps, take the latest Trident 1.2dev (code named Cookie Jar) and add it to your Android project. The project documentation describes the basic terminology of Trident, and will provide more Android-specific examples in the next few weeks.

Some time has passed since Ken Orr has announced that he has teamed up with Kathryn Huxtable to work on a new Sea Glass look-and-feel for Swing applications, and i thought that it would be interesting to put Substance and its Jitterbug editor to the test.

Since i don’t have the full artwork for Sea Glass, I based the current implementation on the following mockup:
controls

And this is how a Substance sample Sea Glass skin looks like after about half an hour of work:

https://substance-samples.dev.java.net/images/seaglass/seaglass-substance1.png

https://substance-samples.dev.java.net/images/seaglass/seaglass-substance2.png

https://substance-samples.dev.java.net/images/seaglass/seaglass-substance3.png

The skin itself is a 122-line color scheme definition (created in Jitterbug) and about a 100 lines of Java code that associates the color schemes with the relevant control states and control visual areas. Note that this is not supposed to be a perfect reproduction of the target design, but more of an exploration of Substance skinning layer capabilities.

brownbearbrownbear i see a @redbird looking at me. @redbird, @redbird, #whatdoyousee?

about 2 hours ago from web


redbirdredbird i see a @yellowduck looking at me. @yellowduck, @yellowduck, #whatdoyousee?

about 2 hours ago from twitterfeed


yellowduckyellowduck i see a @bluehorse looking at me. @bluehorse, @bluehorse, #whatdoyousee?

about 2 hours ago from twitterfeed


bluehorsebluehorse i see a @greenfrog looking at me. @greenfrog, @greenfrog, #whatdoyousee?

about 2 hours ago from Tweetie


greenfroggreenfrog i see a @purplecat looking at me. @purplecat, @purplecat, #whatdoyousee?

about 1 hour ago from TweetDeck


purplecatpurplecat i see a @whitedog looking at me. @whitedog, @whitedog, #whatdoyousee?

about 1 hour ago from Tweetie


whitedogwhitedog i see a @blacksheep looking at me. @blacksheep, @blacksheep, #whatdoyousee?

50 minutes ago from API


blacksheepblacksheep i see a @goldfish looking at me. @goldfish, @goldfish, #whatdoyousee?

46 minutes ago from Twittelator


goldfishgoldfish i see a @teacher looking at me. @teacher, @teacher, #whatdoyousee?

31 minutes ago from Blu


teacherteacher i see a @children looking at me. @children, @children, #whatdoyousee?

15 minutes ago from Echofon


childrenchildren we see a @brownbear, @redbird, @yellowduck, @bluehorse, @greenfrog, @purplecat, @whitedog, @blacksheep and @goldfish looking at us. #thatswhatwesee

less than 5 seconds ago from web


Image credits: Marshmallow, Lee Coursey, Amy Loves Yah, Leonid Mamchenkov, Stephen Barnett, jon_a_ross, Photos8.com, úlfhams_víkingur, kevindooley and Tom@HK

http://farm2.static.flickr.com/1359/1252522330_78b53d7e16.jpg

Image by margolove

Every month this series is tracking the latest design trends and collecting the best examples of modern web designs. Here is the list for October 2009 with almost 2000 links from 58 aggregator posts: