This is a guide I put together to make themes for the T-Mobile theme engine based mostly on what i've figured out by digging into haxzamatic's awesome template.
This does not require you to be on linux or whatever.
This is mainly a temporary guide till an Eclipse template for the engine is released, or for those who dont want to use eclipse, etc.
-You should know how to decompile/recompile/sign apk files.
-You should know some basic xml editing and theming.
-basic terminal commands
-You must install the framework for apktool, navigate to the folder containing framework-res.apk and execute -
apktool if framework-res.apk
1. Get the compiled Templatebread from here: http://bit.ly/hdEWsf
2. Decompile it with apktool or whatever you use.
3. Open the AndroidManifest.xml
4. Change the names according to your theme. Here's my manifest for my NTSense theme:
<?xml version="1.0" encoding="UTF-8"?> <manifest android:hasCode="false" android:versionCode="2" android:versionName="1.1" android:installLocation="internalOnly" package="com.nhnt11.theme.ntsense" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:pluto="http://www.w3.org/2001/pluto.html"> <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="9" /> <application android:label="@string/theme_name" android:icon="@drawable/icon"> <activity android:label="@string/theme_name" android:name="com.tmobile.theme.Foo" /> </application> <theme pluto:themeId="NTSense" pluto:styleId="@style/NTSense" pluto:name="@string/theme_name" pluto:preview="\@drawable/preview" pluto:author="@string/author" pluto:copyright="@string/copyright" pluto:wallpaperImage="@drawable/wallpaper" pluto:styleName="@string/style_appearance_name" pluto:ringtoneName="Standard" pluto:ringtoneFileName="media/audio/ringtones/Standard.mp3" pluto:notificationRingtoneName="Subtle" pluto:notificationRingtoneFileName="media/audio/notifications/Subtle.mp3" /> </manifest>
More detail about stuff in the manifest in 2nd post.
5. Open /res/values/strings.xml. Edit to match your theme. Here's mine again:
<?xml version="1.0" encoding="UTF-8"?> <resources> <string name="app_name">NTSense Theme</string> <string name="theme_name">NTSense</string> <string name="style_appearance_name">NTSense</string> <string name="author">nhnt11</string> <string name="copyright">nhnt11</string> </resources>
<?xml version="1.0" encoding="UTF-8"?> <resources> <style name="NTSense" parent="@android:style/Theme" /> </resources>
7. Now, if you are making a theme from scratch, go ahead and just edit the images already in the hdpi folder. compile and sign. done. But, read on anyway because i explain how the theme engine works below.
If you want to port a theme, here's what to do:
First, go ahead and delete all the drawable folders. Now, copy your THEMED drawable folders into the directory. You now have to add the following to your theme:
/res/drawable-_dpi/preview.png (prefarably hdpi I guess) (I suggest that you DO NOT remove the backslash in the manifest as different locations of preview.png do not work on different screen sized devices. RETAIN the backslash!! Your theme will not have a preview, but this is a small trade off to get themes working if you're not on linux.)
/res/drawable/wallpaper.png (this can be in drawable-_dpi for different screen res. too)
More detail on those in the second post.
8. Now go to /res/xml - there are a ton of xml's here. Open redirections.xml.
Here, there are entries for specifying which XML redirects which app. Add entries like so:
<package-redirections android:name="<app package name here>"
android:resource="@xml/your_xml_file(without '.xml' at the end)" />
You have now specified that you want resources in <app> to be redirected based on what's in your_xml_file. Where and what is this your_xml_file and how do you add/modify it? That's what the rest of the xml's in the res/xml folder are.
The rest of these xmls are the heart of the theme engine. How they work is, when android asks for an image or other resource, they come in and switch that resource for your themed one. So its sort of like a proxy server.
Each xml contains the redirections for an app.
For example, redirections to framework-res.apk are in android.xml, and SystemUI is in com_android_systemui.xml
Delete files corresponding to apps you have not themed (for consistency, you might also want to delete the corresponding entry in redirections.xml. If you don't know how, just leave it). You can also add apps by using the convention, <package name>.xml where dots in the package name are separated by underscores, ie. your_package_name.xml for your.package.name
Package names of apps can be found in their respective AndroidManifest.xml's after decompiling. See 2nd post for more detail.
To redirect files, for eg. title_bar_portrait.9.png, just add the item to the systemui xml like so:
Here, the "name" part tells the theme engine WHAT you're replacing.
the part inside the item tag ("@drawable/title_..... in this case") tells it WHAT to replace it with.
In all android packages, the @ sign means that you are referring to a resource in the package. Also, you can refer to a general system-wide resource by using @android:<whatever>
for example, you can replace the above title_bar_portrait with statusbar_background thats already in the android framework like so:
Note that because the @ symbol refers to something INSIDE your package, you SHOULD NOT use it in the item name="<blablabla>" part.
See Variables in the second post for more detail.
Back to the xmls.
Pretty much all images are ALREADY entered in the xml. Just do a find and replace and get rid of all the "frameworks_res_" and "com_android_systemui_"
for eg, it already has <item name="drawable/title_bar_portrait">@drawable/com_android_systemui_title_bar_portrait</item>, so you need to get rid of the "com_android_systemui_" part.
Actually the professional/clean way to do it would be to rename all of your files to include "package_to_which_it_belongs_" at the front of the filename for better organisation. if you have the time and patience, do it this way!!!!
9. Delete the /res/values/public.xml. Its useless and annoying while compiling. It will be regenerated while compiling.
10. Try to compile the apk. you will probably get errors, because although all the resources are listed in the android.xml (or whatever) you deleted the HDPI folder so many might be missing! it will print what is missing when you compile though, so just go ahead and delete those lines.
11. you can also re-map styles, colors, drawables, etc.. for eg. battery percentage, add this to android.xml after putting the required battery xml in res/drawable:
also for a color, just add it to /res/values/colors.xml and then in android.xml, add
<item name="color/[name of color]">@color/[name of your color]</item>
See variables in the second post for more info.
12. Sign your compiled apk, and install it! If all goes well you will be able to apply and see the changes after you reboot.
Hope this helped!