Subscribe:

Ads 468x60px

Labels

A behind the scenes look at CyanogenMod’s new Theme Engine

It has been but a year since but a year since CyanogenMod let out its theme engine, alongside the launch of CyanogenMod 11S on the OnePlus One. The Android ROM community, however, is hardly one to rest on its laurels and is once again working on a new theme engine in time for a Lollipop-based CyanogenMod 12 release. CM Theme Engine co-author Clark Scheff gives an overview of how the engine works and some of the idiosyncrasies theme designers have to consider.



The astute reader may have noticed that a previous CM12 update mentioned dropping support for themes based on the T-Mobile theme engine. That was the CM11 engine that the developers made in collaboration with the carrier. The new theme engine, however, will be based on code that has been contributed by Sony (once again, kudos to the manufacturer!) to the Android Open Source Project, and this engine revolves around the concept of "resource overlays".


In a nutshell, when an app starts, the Android system loads the resources, the icons, images, text strings, and others, that the app needs. This all happens at runtime, when the app is loaded, instead of compile time, when the app is built. When a theme is applied, Android first looks if there is a themed version available for a specific resource, say a button, and if so, it uses that instead of the default system version. This is basically how Sony's Runtime Resource Overlays or RRO works, but naturally, CyanogenMod wants to extend the idea further.



cm-rro



There are a few quirks to RRO, some of which can limit what CM and themers can do. In particular, the implementation processes some of the resources at build time in order to be more efficient. Sony's RRO also doesn't support changing things like fonts. For some of these, CyanogenMod had to roll out their own changes. For example, each CyanogenMod build includes the Android Asset Packaging Tool or aapt, the same tool used by app developers to process resources. Whenever a new theme is installed, aapt is run on those in order to do the same process and index resources for efficiency.


CyanogenMod has to perform a tough balancing act, however, to ensure that even with the power theme designers are given, they won't overstep their boundaries. For example, themes shouldn't be allowed to change app text, which would make for a security nightmare. The theme engine must also be able to provide a smooth fallback to the default system theme in case the user-installed one goes awry.


The new CM Theme Engine is still in its initial stages and it might be quite some time before we will be able to see a final, polished product. It will also be interesting to see how far CM will take this theming business, with rumors that Cyanogen, Inc. might look to paid themes as a way to make money on the sides.


SOURCE: CyanogenMod