[Sony Ericsson XPERIA X10 Mini] Emperor.dk:
XML-references [updated 13/2-13]

In the xml-folder we have all the XMLs that are responsible for theming apps.

We already had a sneak-peek at res/xml/android.xml above. Let's see how the redirection-XMLs work.

The master-XML is "redirections.xml". Here each themed app is referenced to an XML.

All themed app then have it's own XML that controles how the app is themed - both PNGs from drawable-folders and styles from "res/values/styles.xml".

It's not only standard apps that can be themed. Any app, also from Google Play, can be themed.

The most simple theme is just to change the apps icon in the app drawer. Most themes for the stock email app only changes the icon.

More theming would be to exchange drawables (PNGs), and the next more advanced step is theming styles, and if you are totally crazy you also make a lot of qualifier dependent theming (mostly language dependent).

This is an example from a theme, that themes all standard apps:

<?xml version="1.0" encoding="utf-8"?>
<theme-redirections
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:pluto="http://www.w3.org/2001/pluto.html">
[COLOR="Red"]<package-redirections android:name="android" android:resource="@xml/android" android:minSdkVersion="7" />[/COLOR]
<package-redirections android:name="com.android.systemui" android:resource="@xml/com_android_systemui" android:minSdkVersion="7" />
<package-redirections android:name="com.android.phone" android:resource="@xml/com_android_phone" android:minSdkVersion="7" />
<package-redirections android:name="com.android.settings" android:resource="@xml/com_android_settings" android:minSdkVersion="7" />
<package-redirections android:name="com.android.browser" android:resource="@xml/com_android_browser" android:minSdkVersion="7" />
<package-redirections android:name="com.android.calendar" android:resource="@xml/com_android_calendar" android:minSdkVersion="7" />
<package-redirections android:name="com.android.music" android:resource="@xml/com_android_music" android:minSdkVersion="7" />
<package-redirections android:name="com.android.camera" android:resource="@xml/com_android_camera" android:minSdkVersion="7" />
<package-redirections android:name="com.android.mms" android:resource="@xml/com_android_mms" android:minSdkVersion="7" />
<package-redirections android:name="com.android.contacts" android:resource="@xml/com_android_contacts" android:minSdkVersion="7" />
<package-redirections android:name="com.android.calculator2" android:resource="@xml/com_android_calculator2" android:minSdkVersion="7" />
<package-redirections android:name="com.android.deskclock" android:resource="@xml/com_android_deskclock" android:minSdkVersion="7" />
<package-redirections android:name="com.cooliris.media" android:resource="@xml/com_cooliris_media" android:minSdkVersion="7" />
<package-redirections android:name="com.android.email" android:resource="@xml/com_android_email" android:minSdkVersion="7" />
<package-redirections android:name="com.android.inputmethod.latin" android:resource="@xml/com_android_inputmethod_latin" android:minSdkVersion="7" />
<package-redirections android:name="com.google.android.apps.genie.geniewidget" android:resource="@xml/com_google_android_apps_genie_geniewidget" android:minSdkVersion="7" />
<package-redirections android:name="com.sonyericsson.home" android:resource="@xml/com_sonyericsson_home" android:minSdkVersion="7" />
<package-redirections android:name="com.android.providers.downloads.ui" android:resource="@xml/com_android_providers_downloads_ui" android:minSdkVersion="7" />
<package-redirections android:name="com.android.packageinstaller" android:resource="@xml/com_android_packageinstaller" android:minSdkVersion="7" />
</theme-redirections>

The reference to the framework-res.apk is a little special. See the red line at the top.

The rest uses the apps package-ID. Knowing the package-ID you can theme any app. Also apps from Google Play.

In each of the XMLs for each app, all file-redirections are defined.

So we want to theme Calculator.apk to make it look like in stock Eclair ROM.

We already themed the style above, now we want to theme the icon and all images used by Calculator.apk.

In the decompiled Calculator.apk from CM7 ROM we find 2 drawable-folders:

drawable

- blue_button.xml

- button.xml

drawable-mdpi

- advanced.png

- clear_history.png

- icon.png

- simple.png

In the decompiled Calculator.apk from stock Eclair ROM we find these 2 drawable-folders:

drawable

- blue_button.xml

- button.xml

- transparent_button.xml

drawable-ldpi

- advanced.png

- calculator_button.9.png

- calculator_button_pressed.9.png

- clear_history.png

- icon.png

- simple.png

First we notice that the 3 normal PNG files looks exactly the same, aside from MDPI/LDPI. In this case there is no need for theming those.

Also notice there is no folder for landscape, as there is no need for a different looking PNG/XML.

But we want to theme the icon and the two XMLs from drawable. Remember, that XMLs in the drawable-folder are seen as any other PNG in a drawable-folder.

The icon from stock Eclair is renamed into something easy to understand, like ic_launcher_calculator2.png, and copied to our theme-apk-folder res/drawable-ldpi.

We will also copy the two .9.PNGs, as we will use them to make button-animations (explained in next post below).

The content of "res/xml/com_android_calculator2.xml" will look like this for theming the icon and the two XMLs.

<?xml version="1.0" encoding="utf-8"?>
<resource-redirections>
[COLOR="red"]<item name="drawable/icon">@drawable/ic_launcher_calculator2</item>[/COLOR]
<item name="drawable/blue_button">@drawable/calculator_button</item>
<item name="drawable/button">@drawable/calculator_button</item>
</resource-redirections>

The red line makes a redirection for the icon as shown in the app-drawer to a PNG in our theme-APK "res/drawable-ldpi/ic_launcher_calculator2.png".

We also make redirections for the XML-drawables, but as all buttons looks the same in stock Eclair we redirect to the same file for both button-types. Read more in next post about Advanced image and color animation.

Notice, that we do not make any redirections to the two .9.PNGs as they do not replace anything.