# [TOOL] CM7 APK theme XMLGenerator/Renamer - RZ Theme Engine Tools



## raidzero (Jun 10, 2011)

Part of this toolset is a hack of this excellent utility, written by nhnt11 of XDA. I have modified it to support xml's as well as png's, and I have added a lot more packages recognized by default. These are the recognized packages:

"frameworks_res_", "com_android_systemui_", "com_android_browser_", "com_android_calculator2_", "com_android_calendar_", "com_android_camera_", "com_android_contacts_", "com_android_deskclock_", "com_android_email_", "com_android_fm_", "com_android_inputmethod_latin_", "com_android_launcher_", "com_android_mms_", "com_android_music_", "com_android_phone_", "com_android_providers_calendar_", "com_android_providers_downloads_ui_", "com_android_quicksearchbox_", "com_android_settings_", "com_android_wallpaper_", "com_cooliris_media_", "com_google_android_apps_genie_geniewidget_", "com_google_android_carhome_", "com_google_android_gm_", "com_google_android_googlequicksearchbox_", "com_google_android_talk_", "net_cactii_flash2_", "com_android_providers_subscribedfeeds_", "com_android_providers_downloads_", "com_android_vending_", "com_android_setupwizard_", "com_google_android_gsf_", "com_google_android_apps_plus_", "com_facebook_katana_", "com_google_earth_", "com_android_protips_", "com_google_android_apps_maps_", "com_koushikdutta_rommanager_", "com_mhuang_overclocking_", "com_noshufou_android_su_", "com_tmobile_themechooser_" ,"com_google_android_voicesearch_", "com_google_android_youtube_"

I have also written a quick batch script to automate the use of XMLGenerator.jar:
generate_xml.bat:

```
<br />
@echo off<br />
rem set THEME=%1 uncomment this to pass theme as argument<br />
set THEME=RZ_Blue<br />
echo ^<?xml version="1.0" encoding="utf-8"?^> > %THEME%\res\xml\android.xml<br />
echo ^<resource-redirections^> >> %THEME%\res\xml\android.xml<br />
for /F "tokens=*" %%A in ('dir /a:d /b %THEME%\res\drawable*') do java -jar XMLGenerator.jar %THEME%\res\%%A temp-%%A.xml<br />
for /F "tokens=*" %%A in ('dir /b temp-*.xml') do type "%%A" >> %THEME%\res\xml\android.xml && echo. >> %THEME%\res\xml\android.xml && del %%A<br />
echo ^</resource-redirections^> >> %THEME%\res\xml\android.xml<br />
```
rename.bat:

```
<br />
@echo off<br />
rem set THEME=%1 uncomment to use arguments instead<br />
rem set ORIG=%2<br />
set THEME=RZ_Blue<br />
set ORIG=Cyanbread<br />
cd %THEME%<br />
del res\values\public.xml<br />
for /F "tokens=*" %%A in ('dir /s /b *.?ml') do ..\replace.bat %ORIG% %THEME% %%A >> %%A_2 && move %%A_2 %%A<br />
```
which uses this (I found online):
replace.bat:

```
<br />
@echo off<br />
REM -- Prepare the Command Processor --<br />
SETLOCAL ENABLEEXTENSIONS<br />
SETLOCAL DISABLEDELAYEDEXPANSION<br />
<br />
::BatchSubstitude - parses a File line by line and replaces a substring"<br />
::syntax: BatchSubstitude.bat OldStr NewStr File<br />
::          OldStr [in] - string to be replaced<br />
::          NewStr [in] - string to replace with<br />
::          File   [in] - file to be parsed<br />
:$changed 20100115<br />
:$source [URL=http://www.dostips]http://www.dostips[/URL].com<br />
if "%~1"=="" findstr "^::" "%~f0"&GOTO:EOF<br />
for /f "tokens=1,* delims=]" %%A in ('"type %3|find /n /v """') do (<br />
    set "line=%%B"<br />
    if defined line (<br />
        call set "line=echo.%%line:%~1=%~2%%"<br />
        for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X<br />
    ) ELSE echo.<br />
)<br />
```
This means you can fill up your theme's res directory with all the drawable folders you could ever want, and this script will automatically generate an android.xml for you (using XMLGenerator, again written by nhnt11 NOT ME - I just hacked it to support xml drawables)

to use any of these, just make a folder, decompile an APK into its own folder, put all of these tools at the top level (alongside the decompiled APK directory) and run them, either via arguments on the command line or simply edit the vars in them for double-click runnability 

I have only just learned how to make APK themes yesterday... but I think these scripts when put with a modified XMLGenerator are very handy 

all you have to do is make the content, these scripts handle the renaming of the package & the redirection xml generation for you:tongue2: hope it helps

If you find XMLGenerator useful, please head over to the thread at the top and thanks nhnt11!

until next time...


----------



## Jaxidian (Jun 6, 2011)

This is cool stuff! One of these days I'm going to have to actually start some basic theming...


----------

