Sunday, 15 November 2009

Android Reflective Surface

Reflection effect is pretty easy once you understand UI basics under Android.

Before going to platform specific implementation though, let's consider how this effect can be achieved in a graphics editing program (e.g. Inkscape, Photoshop)

First we select an area to be reflected, then we copy it to the desired place and flip it vertically. That's it, we may optionally overlay it with some gradient to achieve this cool fading out effect.

Now, back to Android implementation. I want to place my UI elements within a RelativeLayout and have it reflected to some ImageView every time whenever an element within that RelativeLayout gets redrawn.

Every UI element inherits from View class and so does RelativeLayout. View.onDraw(Canvas) gets called when a view needs to render its content. We need to override this method so that it triggers reflection. Within that method we need to notify ImageView to redraw itself using postInvalidate method. To do that I have created ReflectableLayout class.

Now here is a trick, we override ImageView's onDraw method as well, to do so I created ReflectiveSurface class. Inside that method we call ReflectableLayout's draw(Canvas) method with RelfectiveSurface's canvas as a parameter. This causes ReflectableLayout to render its content onto ReflectiveSurface. We just need then to add some canvas translations to the process.

That's basically it. If you need some gradient to your reflection you may add it in the XML layout file by placing gradient image over ReflectiveSurface. Source code (GPLv3 license) to this example is attached here.

Tuesday, 19 May 2009

Jamendo Player for Android

"Music should be free. Free as the air and the sky"
Prattchet, Terry. Soul Music.

These days big label companies and organizations like MPAA, RIAA are trying to force their laws on us, limiting our freedom. Just worth to mention: IPRED, 3-strikes or The Telecom Package ongoing battle.

Time to say NO.... and there are various ways to do so.

For over 2 moths now I have been working at Teleca Poland. More specifically, I participated in one R&D project - Jamendo Android Player, screenshot on your left :)

So what is Jamendo? Basically, it is a new way of music distribution. It protects artist copyrights instead of label's. Moreover labels are excluded from the process as distribution takes place over the internet - listeners can directly donate money to the artists if they like their music.

I sincerely hope this application will attract more people to Creative Commons - both musicians and listeners. Currently some may feel a little bit disappointed by a lack of big names in the Jamendo music catalogue. This will certainly improve over time, given more people join the community (we're over half a million already!).

Feature list available here

Friday, 15 May 2009

Android source code released

It took some time at HQ to release the source code, but hey it's finally there :)

Now get the compiler and have fun!

Friday, 23 January 2009 client for Android

Last year, October 2008, I started the development of - the client for Android. The inspiration was a demo trailer of the iPhone client I found somewhere on the net. I just wanted to know if I can write something similar. I didn't have and still don't have a real device so it was all done on the emulator.

After about a month, when my app matured, I contacted stuff to obtain the api key for my app - this is where I learned they were going to write something I had already working... well maybe not entirely :)

Anyway, we joined the forces, which was a good thing after all. I ported useful bits from my old application to the new official client... of course some parts had to be altered or completely rewritten. Working with stuff proved to be beneficial to the app - more people have been working over the code and the client itself gained a better UI design. Just after one month with the Christmas holidays in the meantime we deliver something working, hopefully.

All in all, the official client should be available in the Android Market in a matter of hours or is already available. It's the first public release so expect the bugs to pop up randomly - most certainly they will be fixed asap. In the future some new functionalities will be added.


Last year there was no a single post on this blog... I didn't feel like writing so just get over it ;[