[Galaxy S II General] Mekrel:
There's certainly a lot of choice out there when it comes to firmware, however, I've found that a lot of custom ROMs on XDA include a lot of themes that I'm not really interested in.

Usually, when I find a modified file with the feature that I'm looking for, it also includes something else that I don't want. I've also seen a lot of posts in threads where people ask "Great! Can you make this mod for firmware version XXX?"

So I've decided to create this guide, it will show you how to look for changes to the files that developers post, so you can merge it with the file from your phone.

Prerequisites:

Latest Android-SDK downloaded and installed, with directories added to your PATH

Java runtime enviroment >= 1.6

Apktool, install instructions are on the page of this link

WinMerge installed

Your ROM is deodexed

In this example, I'm going to add Rawrat's green icons to my phone, but I don't want to add his modified transparant notification drop down. Rawrat at the time only provided files for XXKG6 but my personal ROM is based on XXKH3.

1. Create the following directory structure (this doesn't have to be named exactly as I have, it just keeps the files organised I find):

2. Download the developers modified files and place them in "Modded ROM files" - in my example, this is framework-res.apk and SystemUI.apk

3. Ensure USB debugging is enabled, connect phone via the USB cable. In windows command prompt, change directory to "Current ROM files" and pull the following files:

adb pull /system/framework/framework-res.apk
adb pull /system/framework/twframework-res.apk
adb pull /system/app/SystemUI.apk

You have to pull the framework-res.apk & twframework-res.apk if you're modifying most system applications. SystemUI.apk is the file I'm editing in this example. If you're modifying different ones to me or more, then pull those as well or instead of.

4. Whilst command prompt is in the same directory (Current ROM files), you'll need to install the framework files for Apktool to use:

5. If the above worked correctly, you should have a message from apktool saying the framework was installed to 1-galaxy.apk and 2-galaxy.apk and your files should have been pulled into "Current ROM files":

6. Whilst command prompt is in the same directory (Current ROM files), we'll need to decompile the *.apks:

apktool d -t galaxy framework-res.apk framework-res
apktool d -t galaxy SystemUI.apk SystemUI

I'm not modifying twframework-res.apk, I just pulled that as it's a dependant file, so no need to decompile this unless it's one of the files the developer edited.

You shouldn't get any errors and it was successfully decompiled if it looks like so:

7. In command pompt, change to "Modded ROM Files" directory and decompile the developers files that we placed there earlier:

apktool d -t galaxy framework-res.apk framework-res
apktool d -t galaxy SystemUI.apk SystemUI

8. Now that we've decompiled both the current files on the phone and the modified ones, we're going to use WinMerge to compare the directories:

Open WinMerge and go to file -> open

For the left pane, click browse and browse to your "Current ROM files" folder, then framework-res, then click open

For the left pane, click browse and browse to your "Modded ROM files" folder, then framework-res, then click open

Check "Include subfolders" then click OK

8. Once WinMerge has compared the directories, go to view and make sure only the following is ticked in the top part of the view menu:

This basically shows all the files that are different between the two directories.

9. Now, we're going to look down the list of files that are different and copy them from right to left (Modified file to current file)

Exercise some caution here especially if you're applying the mod to a file that's from a different Samsung firmware. Usually when applying a mod to a different firmware version, you'll notice a lot of strings.xml differences listed. This is because Samsung have updated the translations for different languages. So don't copy these over.

Regarding other xml files, apktool inputs some entries into drawables.xml and public.xml so these files also show up as different. Again, don't copy these over.

Developers do make changes to xml files, either way, to ensure you're not over writing older xml documents with new ones, just right click the file and compare. As you can see, opening bools.xml, I can see there's a difference to:

<bool name="config_animateScreenLights">true</bool>

As Rawrat changed this to false to enable CRT-Off animation, I want this animation on my KH3 ROM. So I'm going to right click bools.xml and copy right to left.

Warning! Again, when dealing with two files from two different firmware bases, NEVER EVER copy any .smali files. This is because Samsung would have made changes most likely. Instead, compare the files as above and manually change the .smal file in the left pane with the changes the developer made. You can then save the file.

10. Repeat the WinMerge steps for the other decompiled application folders, in my example, I did the same for SystemUI.apk and to ensure I was only copying the green icrons for signal, WiFi and mobile data; I right clicked the different *.png files and chose open right with registered application. This opens the .png with your default image editor.

11. Go back to command prompt and change directory to your "Current ROM files" directory. Use apktool to compile:

apktool b framework-res

You should not receive any errors, apart from warnings about there not being any translation. Those errors are normal.

Obviously, compile all the other .apks too!

12. In Windows Explorer, navigate to the "Current ROM files"/framework-res/dist folder

This is the location of your newly compiled framework-res.apk with the changes you made. Open this apk with your archive editor (WinRar, 7zip, WinZip etc). Keep this open.

13. In Windows Explorer, navigate to the "Modded ROM files" folder

Open the original framework-res.apk with your archive editor, then drag the META-INF folder and AndroidManifest.xml file from the original .apk to the other archive editor window that has your modified .apk open.

Replace the files on your phone with the new ones! :)