redesigned android live wallpaper backend

Redesigned android lwp backend for libGDX.
All known bugs of current libGDX implementation had been fixed.
Based on libGDX 0.9.8.

Please read also msg sent to badlogicgames at gmail.com.

I have developed my own live wallpaper with help of libGDX enhanced with this code. You can track user comments and generally how it works on various devices:

True Water Free:
https://play.google.com/store/apps/details?id=com.jw.lwp.aqua.free

True Water:
https://play.google.com/store/apps/details?id=com.jw.lwp.aqua.pro


- - - - - - - - - - - - - - - - - - - 
About new design of LWP backend (sorry for my not the best english..):

libGDX is based on singletons (Gdx.app etc), moreover user can implement his own singletons and it just works when libGDX is used to make desktop applications, android activities etc. Live Wallpaper backend was designed in wrong way (from libGDX point of view), this design tried to force libGDX to work in environment it was not designed to. Should be only one instance of libGDX singletons in application, but libgdx wallpapers work on many engines with many SurfaceHolders..

I just moved things to (in my opinion) right direction: I forced live wallpapers API to create environment libGDX is designed to.
Redesigned AndroidLiveWallpaperService manages all this madness linked with switching wallpaper 'engines' by itself. Rest of user application, libGDX internals etc. works normally and exactly the same as in other types of applications (there is only one instantion of ApplicationListener, AndroidGraphicsLiveWallpaper, GLSurfaceView etc). It should be possible to run any of existing libgdx apps as wallpaper now (perhaps after solving few little issues - I'm new in libGDX:)).

All lifecycle issues was resolved. With this LW backend user can switch wallpapers as fast as he want, can sleep phone in live wallpaper preview, it now runs without problems on devices on which it crashed before.
No null gl contexts inside render() method.
Much faster wallpaper loading (ex in preview)
Much faster resuming after phone was in sleep mode.
Classes duplicated for lwp backend are no longer used an can be deleted (GL..SurfaceViewLW etc).

If end developer want to implement custom application behavior in wallpaper preview, there is additional interface called AndroidWallpaperListener, he should implement it in his application listener and respond for event called when preview is opened/closed (see modified LiveWallpaper test).


- - - - - - - - - - - - - - - - - - - - 
What I did (technically):

+ Completely new implementation of AndroidLiveWallpaperService. There can be many engines in runtime, and any of them is linked with own SurfaceHolder on wallpaper should draw. But.. only one engine is active at specific time. Wallpaper service switches smartly between them and update GLSurfaceView to use currently active SurfaceHolder and render on it. This is transparent for rest of application, and for GLSurfaceView itself too! I just simulates events called when surface holder is lost or restored. GLSurfaceView 'think' its surface was lost and restored, but really it was just switched to another surface holder (linked with active wallpaper engine).

+ AndroidGraphicsLiveWallpaper now uses GLSurfaceView and GLSurfaceViewCapcake as original AndroidGraphics (with slight modifications). GL..SurfaceViewLW classes are deprecated, not used, and can be removed completely.

+ AndroidGraphisLiveWallpaper synchronized with current AndroidGraphics
and AndroidGraphicsDaydream (now it is near mirror copy of original AndroidGraphics, I think you should merge this three classes in near feature before they will be resynchronized again, it shouldn't be hard to do)

+ AndroidWallpaperListener, interface that can be implemented in addition to ApplicationListener in libgdx application to autimatically add support for live wallpaper specific events

+ updated LiveWallpaper test

+ constructor in com.badlogic.gdx.graphics.Mesh - optimizations for dynamic meshes (not linked with lwp)


- - - - - - - - - - - - - - - - - - - - 
Modified files:

com.badlogic.gdx.backends.android.AndroidLiveWallpaper
com.badlogic.gdx.backends.android.AndroidLiveWallpaperService <- completely new implementation
com.badlogic.gdx.backends.android.AndroidGraphicsLiveWallpaper <- now uses GLSurfaceView
com.badlogic.tests.android.LiveWallpaper

com.badlogic.gdx.graphics.Mesh 	<- changes not linked with live wallpapers


- - - - - - - - - - - - - - - - - - - - 
Files no longer used:
Any files with suffixes ..LW can be removed - they aren't used by current wallpaper backend.


- - - - - - - - - - - - - - - - - - - - 
Added files:
com.badlogic.gdx.android.AndroidWallpaperListener <- callback allowing ApplicationListener to receive wallpaper specific events, if you don't like this solution, you could refactor it to WallpaperListener and read it as 'generic purpose wallpaper listener, currently supported only on android':)