Cyril Mottier

β€œIt’s the little details that are vital. Little things make big things happen.” – John Wooden

New GreenDroid Release: Library Project & ActionBarItem

I’ve recently updated the GreenDroid library (available on GitHub). Here is a list of the main changes:

  • Improvements to the ActionBar
  • New “applying” system
  • Bugs fixed

Improvements to the ActionBar

With the first release of GDListActivity and GDTabActivity it wasn’t possible to create “non regular” items. This release introduces ActionBarItem. An ActionBarItem is an object representing a single action button in the ActionBar. It may act differently depending on its purpose. For instance, a LoaderActionBarItem switches from a regular button to a circular ProgressBar once pressed. A NormalActionBarItem displays a simple Drawable.

1
2
3
4
5
/*
 * This will add a "refresh" button that switches from button with two rounded arrows
 * to an indeterminate ProgressBar
 */
addActionBarItem(Type.Refresh);

To prevent developers from designing icons, GreenDroid also includes several base items … (Refresh, Export, Locate, etc.). Do not hesitate to use it as it makes ActionBar development easier and increases consistency through Android applications.

1
2
3
4
5
6
7
/*
 * Here is a sample that show how to create a NormalActionBarItem with custom Drawable
 * and content description.
 */
ActionBarItem item = getActionBar().newActionBarItem(NormalActionBarItem.class);
item.setDrawable(R.drawable.ic_title_export).setContentDescription(R.string.gd_export);
addActionBarItem(item);

Note: The ActionBarItem icons I’ve included to GreenDroid are those that are, to my mind, essential to Android applications. If you think some other icons are essential, fill free to contribute. Just make sure they are in accordance with Android guidelines (shape, colors, size, etc.).

New “applying” system

When I created GreenDroid it wasn’t possible to use projects as “libraries”. Fortunately, the latest release of ADT includes a brand new amazing feature: library projects. A complete description is given on the Android Developers Website so I won’t spend time describing it here.

Thanks to that feature, I’ve removed the previous Python script that were used to copy files from the GreenDroid library to your own projects. To apply GreenDroid to your projects, simply follow the process detailed here. The main advantage of this modification is GreenDroid is now more user-friendly and way easier to use. It is also fully compatible with Windows, Mac OS X or Linux.

I hope you’ll have a lot of fun with this new GreenDroid release. As usual, feel free to leave a comment here if you have a GreenDroid-remated question or if you simply want to thank me! Happy coding!