[T-Mobile myTouch 4G Slide] Blue6IX:
Return to Contents Page - doubleshot Developers Reference

----

Part 1: Custom Sense Lockring on the MT4GS - easy step-by-step.

Part 2: This thread.

Part 3: Edit Mode10 Files for the MT4GS - step-by-step

--------

This installment will cover working with .9.png files, their special handling requirements, and a little bit about what makes them so special.

This is a slightly more advanced guide, and I won't be over-exaggerating explanation of simple things like copy and paste that were covered in part 1.

Working with .9.png files is easy once you know what steps to take and have the tools set up on your computer - it's just time consuming and tedious. So let's take a look at what you need.

What you need:

1 - Android SDK installed

2 - Java JDK installed.

3 - Apk Manager 4.9

4 - 7-Zip installed and ready.

5 - Photoshop ( or equivalent - directions for photoshop ) installed and ready.

6 - A copy of HTCCamera.apk from the Sense ROM you are changing the graphic in.

* - Guide written for a Windows XP machine, please adjust accordingly if your environment is different.

--------

This is a lot of stuff to manage, but if we take our time and do it in order it'll be a piece of cake. ( ~Tasty! )

First thing is to install the Android SDK and Java JDK - both actions are outside of the scope of this guide but well documented all over XDA.

This guide will pick up assuming both the Android SDK and the Java JDK are installed.

This guide also assumes that Apk Manager is installed. Please see the Apk Manager 4.9 thread for the tool if you have trouble in this area.

Lastly, this guide assumes you have read my guide: Custom Sense Lockring on the MT4GS - easy step-by-step. as I won't be explaining how to do things again that were already covered there.

( ... and of course, that you have Photoshop installed and ready...or another graphics program of your choice - but instructions are for Photoshop. )

--------

Okay, we have everything installed, now we need to get our hands on one of those .9.png files so we can play with it.

Let's talk about them for a minute first. Those .9.png files are pretty special, because they are a stretchable graphic.

This means that Android can use the same graphic in many different places, and these different places can be different sizes.

These graphics have some special information attached to them, outside of the border of the graphic there are black lines and dots that tell Android how far and in which directions it can stretch the graphics.

An important thing to note here:

These black lines and dots

MUST BE

black, and no other shade or color. If they are not perfectly black, it will not work.

If you simply extract the graphic from the .apk file with 7-Zip, edit it, and put it back in, your .apk file will break. The reason being is the extra information about how and where to stretch the graphic gets broken when you do this.

The only way to edit these files correctly is to de-compile the .apk, then edit the graphic, and then re-compile the .apk file.

The example we are going to use is from the HTCCamera.apk, and it is called 'scene_frame_pressed.9.png'. It is in the 'res' -> 'drawable-hdpi' folder in the .apk

--------

Preparation: Setup.

First things first, let's set ourselves up. Make a new folder on your desktop, and call it 'CameraEdit'

Next, get a copy of HTCCamera.apk and put it in this folder.

Now, find your apk_manager_4.9 folder, where you set up this tool, and open it.

You will see a handful of folders in here, but there are only two folders we will be working with:

1 - place-apk-here-for-modding

2 - projects

( There is a third, called 'keep', but it's not there yet. It will be generated later. )

Make a copy of your HTCCamera.apk file, and put it in the 'place-apk-here-for-modding' folder.

Okay, stop.

Now we have:

1 - A new folder on the desktop with a fresh copy of HTCCamera.apk in it. This is our final product when we are finished.

2 - A second copy of HTCCamera.apk in the 'place-apk-here-for-modding' folder in the apk manager tool.

So far, pretty simple.

--------

Part 1: De-compiling your apk.

Now that you have your .apk file in the 'place-apk-here-for-modding' folder, go into the apk_manager_4.9 folder and you will see an MS-DOS batch file called 'script'. Double left click this to open it up.

Now you see a cool green menu, with a lot of numbers and options - but don't worry i'm gonna walk you through it. Just make sure not to close this window until I tell you to - simply ignore it when you aren't using it.

First thing you have to do is type the number '22' and hit enter. This lets us select what .apk file we are going to work with.

The only option on the list is '1 - HTCCamera.apk'

Type the number 1, then press enter.

You now find yourself back at that main menu, and up in the top right corner of the window it will say 'Current-App: HTCCamera.apk |'

Now we are ready to decompile the apk file. Type the number 9 and press enter.

It will say 'decompiling apk' and when it is done you will see the main menu again, with a blinking cursor after 'Please make your decision' at the bottom.

Now, we can forget about this window for a little while. Don't close it, just ignore it.

You can find your de-compiled apk in the 'projects' folder.

--------

Part 2: Coloring.

Open up Photoshop, and once it's loaded go to File-> Open, and navigate to the 'projects' folder in the 'apk_manager_4.9' tool.

You will see a folder called 'HTCCamera.apk', go in here, then into the 'res' folder, and then into the 'drawable-hdpi' folder.

Once there, you will find 'scene_frame_pressed.9.png' - open this file into Photoshop.

Once you have this open, you will notice something you didn't see before - there are solid black lines on each of the four sides of the colored square of the graphic.

You do not want to touch, change, edit or in any way affect these black lines. To alter them even the slightest bit will make your whole .apk file broken - and we don't want that.

So what we are going to do is grab your 'Rectangle Marquee Tool' and select everything EXCEPT the black lines around the outside.

Once you have the whole picture selected, except the black lines, you will go up to the menu at the top of the Photoshop window and select 'Image'. From the drop-down list, select 'Adjustments' and then 'Hue/Saturation'

Now you have a dialog box for the Hue/Saturation control of the graphic.

The only thing we are going to change is the Hue, so make sure the 'Edit' box at the top of the window says 'Master' and then grab the Hue slider and drag it all the way to the right.

The text box above Hue should now say +180, and the color of the square has changed. ( If the color didn't change, make sure the 'preview' box is checked in the Hue/Saturation window )

Click on 'OK' and apply the change.

Save the file, and then close Photoshop.

--------

Pretty easy so far, right? not really that much to it - and we're almost done.

Next up we have to recompile the apk, and i'm going to make you take an extra step at the end of the process to reduce your chances of getting a bad apk from a compile error.

--------

Part 3: Re-compiling your apk.

Okay, find your apk manager window I told you not to close, and bring it back into focus.

You should see a blinking cursor at the bottom after 'Please make your decision'.

We are now going to type the number 11, and then press enter. This will tell it to compile the apk.

It will say 'Building Apk', and this part can take a little while - so just be patient.

When it is ready for you, the next thing it will say is:

Is this a system apk (y/n)
Type input:

You will type 'y' and press enter. Any apk that came from or goes into the /system/app folder on the device gets this answer.

Then it will say:

Aside from signatures, would you like to copy
over any additional files that you didn't modify
from the original apk in order to ensure the least
# of errors (y/n)
Type input:

You will again type 'y' and press enter.

A whole mess of text will shoot up in the window, and the very last line will be:

Press any key to continue...

Don't press anything yet, just ignore this program window for the moment.

Now, what you have to do is go back into the apk_manager_4.9 folder and you will find that 'keep' folder I mentioned before. It wasn't there until now, because it's a temporary folder the apk manager program is using to compile your apk with.

What you have to do is go into it, and delete any files you changed.

In this case it's easy, because we only changed one file.

Go into the 'keep' folder, then the 'res' folder, then the 'drawable-hdpi' folder, and find the 'scene_frame_pressed.9.png' file we edited.

Delete the 'scene_frame_pressed.9.png' file.

Now go back to the apk manager window, and press enter.

Let it do it's thing, and when it's done it'll be back at the main menu with a blinking cursor after 'Please make your decision:'

You can just hit the X in the top right corner to close the window, we're done with this wonderful tool now. ( yes - now you can finally close it. )

--------

Okay, now we have de-compiled, edited, and re-compiled our apk file - but we aren't done yet there are still some things to take care of.

Don't worry, it's almost done - and the hard part is over ( which wasn't really that hard, was it? )

--------

Part 4: Avoiding potential bugs.

Next, go into the 'place-apk-here-for-modding' folder in the apk_manager_4.9 folder.

You will see two .apk files:

1 - HTCCamera.apk

2 - unsignedHTCCamera.apk

The second one is the one you just edited, but you will notice the file size is much smaller then the original one.

Remember that folder on your desktop called 'CameraEdit' I had you make with a fresh copy of HTCCamera.apk in it? I want you to copy 'unsignedHTCCamera.apk' and paste it into this folder.

You now have two apk files in this folder, the fresh un-touched one, and the new one we did our work to.

So, use 7-Zip to extract the newly edited 'scene_frame_pressed.9.png' file from 'unsignedHTCCamera.apk' the way I taught you in Custom Sense Lockring on the MT4GS - easy step-by-step and drag it into the 'CameraEdit' folder.

You now have 3 files in this folder, the two .apk files and your newly edited .9.png graphic.

Simply add this graphic to the original HTCCamera.apk file with 7-Zip, and you can call this project done. All you have to do now is test it.

Install the new HTCCamera.apk file on your Android, take a picture, and then tap the thumbnail in the bottom corner that shows your new picture in the camera app.

It brings you to a screen where you see a full screen preview of the picture, so tap the screen and press 'grid view' from the options at the bottom.

When you see the grid of pictures, touch one and look at the color of the highlight that appears around the picture - this is what we changed.

Congratulations! You just edited your first .9.png file!

* - Don't forget to go back to the Apk Manager 4.9 thread and click thanks!

--------

Conclusion & Thoughts:

The reason we did that last step at the end is because we were only changing one small thing - there is no reason to risk the computer making a mistake while compiling the whole .apk file just to change one graphic.

By removing it from the newly compiled .apk, and placing it in the original one that you know works, you eliminate the potential for a lot of bugs and problems.

You don't have to take this extra step at the end, and could just use your re-compiled apk file - but if you've already put this much effort into it, wouldn't you want to minimize the risk of errors by taking an extra minute to do so?

Above and beyond editing a .9.png file, we have also learned how to de-compile, edit, and re-compile an .apk file for Android.

You can now de-compile an .apk file and change XML files or most anything else inside of it and re-compile a working .apk file.

Look for part 3 of this tutorial series that will teach you about .m10 files and how to work with them. Afterwards you will be able to work with all of the graphics (and most other files!) you come across in your Android system.

The only thing we changed in the graphic during the tutorial was the hue, because this isn't a guide on all the cool things you can do with Photoshop or a graphics program.

There are a lot of other creative things people can do with the graphics, and i'm looking forward to seeing what the rest of you come up with now that editing .9.png stretchable graphics is something the MT4GS community knows how to do.

Hope you all are as excited as I am!

Happy modding!