Jump to content

Check us out:

- - - - -

how to theme your own droid


28 replies to this topic

#1 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 04:34 PM

I want to thank Jairomeo, Manup456, ArmyRanger251, Stericson, Brandenk, SirMez, Beagz, david1171 for this (mod sticky this if you would like)
ok first you need some tools to get this rolling
1.Android sdk

Please Login HERE or Register HERE to see this link!


2.Eclipes

Please Login HERE or Register HERE to see this link!


3. AXMLPrinter(this bad boy changes XML`s into text files)

Please Login HERE or Register HERE to see this link!


4.An extractor
5. Smali and Basksmali

Please Login HERE or Register HERE to see this link!


6.Signing tool

Please Login HERE or Register HERE to see this link!


(Note, this will not work if your SDK or the path that you place this in has any spaces in the dir name!
7. Photo-editing software like Photoshop,Paint.net,GIMP
8.Git for windows(you don`t need this if you have linux)

Please Login HERE or Register HERE to see this link!


9. HxD or something else to edit the XML files, and TextPad or something else to edit smali files. Don’t use the notepad in windows, this will add in the return characters and screw things up.
10 A tool to compare your stock ROM’s zip.
a. Use Beyond Compare as suggested by bgill or something else along those lines. This will allow you to compare the files so you can see what files have actually changed, so you know what to update and what doesn’t need to be updated.
11.An image optimizer
12.color code conversion

Please Login HERE or Register HERE to see this link!


================================================================= OK you need to learn how to use the auto signing tool there is a whole lot of walk throughs out there this is one of them
Very Important!
You do not usually need to resign every apk that you change! Usually you only need to resign the update.zip! However there may be times that you may need to resign an apk. So dont sign the apks...if you have problems with the update then try to resign the apks.
JesusFreke was kind enough to build a custom signing tool for me that would allow me to right click on an apk and resign it from there. I am posting it here for others to use as well. Note that this is a courtesy of JF, so thank him for it. I cannot stress how much time this has saved me and will save you.
Automatic version!
Do not use this to sign APK files in Vista or windows 7! It will cause your theme to loop phones when placed on a device. Only use this to sign update files if your using those O/S's
Note, this will not work if your SDK or the path that you place this in has any spaces in the dir name!
An Example of this is c:\users\Nikki and Stephen\sdk\tools
Try to put the SDK and the contents of the zip in a dir where the names are all together and not like the one above.

I have made a batch file that will automate the entire process of setting up to use the signing tool made by JF. This batch file will set the CLASSPATH, set the PATH, install the registries, and will even allow you to sign files manually if you wish. I plan on building onto this batch file to include other things. However, for the moment, it will only include what you see here.

In order to use this you should have downloaded the sdk already. Simply extract all of the files into the tools dir of your sdk, and run autosign.bat follow the instructions and go through the options one by one, starting with 1 working through 4. You can however, put the contents of this zip anywhere on your computer and it will work. It is just better to put them into the tools dir of your SDK. Especially for the consideration of future versions

Remove Advertisements Sponsored Links

    MyDroidWorld.com



#2 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 04:35 PM

Want to set up the signing tool manually?

Before using this you need to know how to set this up:

Now you will need to add the tools dir of your sdk to the environment variable CLASSPATH.

FOR XP:

Right click on My Computer click properties, then choose the tab that says advanced.
Click the button that says environmental variables.
Go to system variables find the one that says CLASSPATH
double click it
go to the end of variable value.
There should be a semicolon ; at the end, type in the path to the testsign.jar located in the tools directory of your SDK

for example the path to my testsign.jar was c:\sdk\android-sdk-windows-1.0_r1\tools\testsign.jar

If CLASSPATH is not in your system variables then create it.
Secondly, Find the system variable called PATH and add to the end of it, the full path to your sdk directory.

For example, mine was c:\sdk\android-sdk-windows-1.0_r2\tools

FOR VISTA:

Open a cmd prompt.

Replace THEEXACTPATHTO-TESTSIGN with the path to the dir that holds the file testsign.jar.


Type:
echo %CLASSPATH%

If it is returns %CLASSPATH%
Type the following:
set CLASSPATH=THEXACTPATHTO-TESTSIGN\testsign.jar


If it comes back with something else then
Type the following:
set CLASSPATH=%CLASSPATH%;.;THEXACTPATHTO-TESTSIGN\testsign.jar


For Example, when I type this it looks like:
set CLASSPATH=%CLASSPATH%;.;c:\Android\SDK\tools\tests ign.jar

To set the PATH

Replace THEEXACTPATHTO-SDK with the path to the tools dir of your SDK.

Now type:

set PATH=%PATH%;.;THEXACTPATHTO-SDK\tools


For example, when I type this out it looks like this:

path-%PATH%;.;c:\Android\SDK\tools


Now through doing this you have done two things, first off you have made the resigning process extremely easy, secondly you will not have to cd to the tools dir of the sdk to use adb or any other tool in the sdk.

#3 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 04:37 PM

Signing the Files:

Now right click the reg file that you extracted and choose to install it, or merge.

Now, right click an apk, do you see an option that says ResignApk? That's how you will resign your .apks and .zips.

When you choose it a cmd window should open for a few seconds and then close. the file you signed will be overwritten with the new resigned file.

If you find the right click menu not working for some reason you can type the following in cmd to sign your files: java testsign whateverfiletosign


General Info:

You will need to be specific in addressing what version your theme is for, RC8, RC30, or ADP1. Make sure you test the update.zip before you release it.


Every .apk contains the images relating to itself. However, every apk has the ability to use the images in framework-res.apk. The images for every apk is located inside of itself. To find these images open up the apk, you can rename it to .zip or open it with an archiver of your choice, winrar, winace, etc. Then after opening the apk open the folder called res and inside of that there are folders that are named Drawable, drawable-land, drawable-port, etc. This is where the images are stored.

There are some things you cannot edit unless you rebuild the entire apk from source, which we will not go into here.(another tutorial, another time) Just know that at this time you SHOULD NOT edit, or even open images with the extension .9.png doing so will corrupt the .9.png and cause the image to distort. You can however compile the images with eclipse.
I would not mess with .9 files unless you are change the size of images or anything, you really don’t need to mess with the headaches of making your own .9 files, which is where I give my tip:

#4 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 04:40 PM

1.Download an archive manager that allows you to open archives inside of archives without creating new windows. My recommendation for this is the application 7-zip. It is tiny, free, easy to use, and on all my computers it has replaced winzip and winrar.

Please Login HERE or Register HERE to see this link!


2.2. Now take a theme .zip file from a ROM maker or you can use another theme as your starting point. You should also have the original ROM so if there is a problem you can easily reflash back to the default ROM to overwrite any issues.

3. Open the .zip and inside are typically 3 files, framework, system or app, and META-INF. Leave META-INF alone, you won’t be touching that, this area tells the phone where to install the folders. Inside framework and system/app is where the files are that you can change. In this case we will open the .zip, then double click framework and then double click framework-res.apk (this is where the next archive will open inside the same window, your life just got a little easier).

4. Now you are looking at assets, META-INF, res, and a couple other random files. Now open up the folder res and you will see the treasure we are searching for, folders with the name drawable. All of the folders that start with the name drawable are where we can edit the themes; this includes drawable, drawable-land, drawable-port, and drawable-finger.

5. Now drag and drop the folders drawable and drawable-land onto the desktop. Once they are on the desktop you can edit the .png files in those folders until you are ready to put your theme together.

6. Now in your still open window at \framework\framework-res.apk\res\ you will open the drawable folders one at a time and drag and drop your edited files into the archive, only dragging and dropping the files you edited and not just everything inside the folder.

7. Once you have your new images copied into the archive in the correct place you can just hit the close button or browse up a couple directories and find other files to edit. Any time you edit an apk and browse out of it or close it you will be prompted to update it in the archive by 7-zip (this is my secret shortcut), always press ok.

8. Now you have a freshly created theme ready to install, all you have to do is right click, chose to Resign the file, and once it’s done you can copy it to your SDcard and flash your new theme.

It’s literally that easy! And you use this same technique in the system/app folder to edit the apk files for the individual apps on the phone. Explore around in the theme's .zip and see what you can find, I only told you about the major items but there is plenty more to find and change. You can always copy a folder out of the archive and if you can’t edit anything just toss it but if you can find something to edit, do so and throw it back in the archive. You guys now have all the info I had when I started plus all my tricks to making that process 10x easier.

#5 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 04:46 PM

To get started here are some links about .9’s and there tools:
This first link is from the Android source itself and the draw9patch tool that comes with the Android SDK

Please Login HERE or Register HERE to see this link!


This link is one written on XDA with some tips on using Photoshop to create .9’s

Please Login HERE or Register HERE to see this link!


ONCE AGAIN Unless you are trying to change the size of images or anything, you really don’t need to mess with the headaches of making your own .9 files, which is where I give my tip:Download the source code from either Cyanogen’s github or from the Android source itself.
Android Source

Please Login HERE or Register HERE to see this link!


Cyanogen’s github -http://github.com/cyanogen
The apps themselves should be pretty straight forward to find. Inside the apk’s you’ll see the icons, which usually starts with ic_launcher, and whatever else is along with it.

The framework-res is not so much. This can be found in android_frameworks_base/core/res if you are looking at Cyanogen’s or platform/frameworks/base.git if you are getting it from the Android Source. The framework-res.apk contains most of the images you see, the text fields, buttons, the status bars, status bar icons, most of the menu icons (including ones you see inside apps) the title bars, etc. This is where most of the theme work goes on.

#6 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 04:55 PM

Something not everyone does, but would be a huge help in your themes, is to use some kind of software to optimize your images. This can reduce the size of your theme by a few MB, which will stop your theme for being responsible for lagging people’s phones. This is especially important when you are not optimizing things like, the launcher, wallpapers and/or widgets.

When you index images and then open them up again late in Photoshop; sometimes they will no longer appear transparent. Personally I keep 2 copies of my work, one pre-optimized, and the other post, this way if I need something I can get the original. A tip that came from Ted417, if you download paint.net, you can open them using that and save them off, this will rid you of the indexing so you can edit them in Photoshop, unless you’d prefer to edit them in paint.net, which makes sense to me.
XML Files
As provided earlier one of the easiest things to start with is getting the AXMLPrinter tool and also having HxD or any other software that will allow you to open and edit the XML files.
Another tool for AXMLPrinter is a GUi interface that BigBeadMDC on Modaco made, that deanesn lead me to
When using HxD you are looking for the code 0800001C, most edits are in this format. There are some that are slightly different. For example, listed below is the Music.apk where it comes in a form where you are looking for 42 43 44 for the black text.
Another example of this was provided by amac25 on XDA, the color code line in Calculator.apk/res/drawable/blue_button.xml is not 08 00 00 1C but rather it is 08 00 00 1D. This find opens a door for us to learn and understand more edits.
As an appendix to this document, you will find a write up by Stericson, detailing XML files.

List of Fil The ones that are that you want to edit are
framework-res.apk/layout:
status_bar.xml - this is for the status bar notifications themselves
status_bar_expanded - this is for the ongoing notifications in the pull down
status_bar_latest_event_content – this is for the notifications in the pull down
framework-res.apk/drawable/progress_horizontal.xml – this is the progress bar for downloads, volume, and slider bars

#7 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 05:07 PM

The ones that are that you want to edit are
framework-res.apk/layout:
status_bar.xml - this is for the status bar notifications themselves
status_bar_expanded - this is for the ongoing notifications in the pull down
status_bar_latest_event_content – this is for the notifications in the pull down
framework-res.apk/drawable/progress_horizontal.xml – this is the progress bar for downloads, volume, and slider bars
DownloadProvider.apk/layout/status_bar_ongoing_event_progress_bar.xml – this is for Market and Browser Downloads
Phone.apk\res\layout\ongoing_call_notification.xml – This controls your current call notifications
Music.apk\res\layout\statusbar.xml
Notes from David1171 on editing the progress horizontal


In progress_horizontal.xml there are 9 instances for 08 00 00 1C, the first 3 are the background colors, the next 6 are for the bar itself.
Make the first three the same color and the last 6 the same color.

When you enter the code into HxD it will have to be reversed to BBGGRRAA. though the individual parts of the code itself will not be flipped. so from the example above 8F will still be 8F not F8. (got it so far) for example we have RRGGBB=13DAF5 (i have no clue what color this is) we will invert it for HxD into BBGGRR=F5DA13.
Now we can edit the .xml
Open the .xml with HxD
Press ctrl+f then enter into search for: 08 00 00 1C
For data type select hex values
For search direction select forward.
Don’t worry about Unicode string or case sensitive.
Once you get to the color code, just enter the hex code you got using the method above

#8 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 05:10 PM

I will help you learn but I will not do it for you.

The first thing to go over is what you will need.
Download Textpad, and HXD. Look on Google for these, consider it homework.

You no longer need to download the source for a reference.
You can find the entire source here:

Please Login HERE or Register HERE to see this link!


I use it as a reference all the time when I'm on windows.

I have uploaded a file called resourcetypes/h that contains alot of information in it about how things are translated to binary, in fact everything I will document below was retrieved from that file.

Keep in mind that Android looks at things in bits when compiling this code into hex. And since in hex all we deal with are bytes we need to do some quick math.

In every byte (00) there are 8 bits When you see something in the code like this: uint16_t size; That is android talking about 16 bits which in hex is 2 bytes because every byte is equal to 8 bits.

Got it? Good...
Lets take a look at some code!



Code:
// Number of bytes in this structure.
uint16_t size;This means the first two bytes reference how many bytes are in this structure. Specifically speaking, for the most part everything we will deal with here is five bytes long. So the first values in hex would be 05 00 if there were five bytes in this structure...



Code:
// Always set to 0.
uint8_t res0;This means the next byte will always be zero, since its 8 bits its only one byte. Which would look like this in hex 00 So combined with what we have above we should see 05 00 00



Code:

// Type of the data value.
enum {enum in this case means that the next byte will be one of the following values depending on what it is we are translating to binary.



Code:
// Contains no data.
TYPE_NULL = 0x00,
Means this byte should be 00 and the byte after it holds no data... So the structure would be 05 00 00 00 ... so far....



Code:
// The 'data' holds a ResTable_ref, a reference to another resource
// table entry.
TYPE_REFERENCE = 0x01,Means the byte(s) after this byte 01 holds a pointer to a resource, which could be an image or any other type of resource stored with Resources.arsc. So combined with what we have above we should see 05 00 00 01



Code:
// The 'data' holds an attribute resource identifier.
TYPE_ATTRIBUTE = 0x02,Means the byte(s) after this byte 02 points to an attribute in the resources.arsc. So combined with what we have above we should see 05 00 00 02



Code:
// The 'data' holds an index into the containing resource table's
// global value string pool.
TYPE_STRING = 0x03,Means the byte(s) after this byte 03 points to a string in the string table of resources.arsc. So combined with what we have above we should see 05 00 00 03



Code:
// The 'data' holds a single-precision floating point number.
TYPE_FLOAT = 0x04,Means the byte(s) after this byte 04 Holds a floating point number...
So combined with what we have above we should see 05 00 00 04



Code:
// The 'data' holds a complex number encoding a dimension value,
// such as "100in".
TYPE_DIMENSION = 0x05,Means the byte(s) after this byte 05 holds the value of dimension...a lot of times this can be a vlaue for a height or a width of an object, such as an image. So combined with what we have above we should see 05 00 00 05



Code:
// The 'data' holds a complex number encoding a fraction of a
// container.
TYPE_FRACTION = 0x06,Means the byte(s) after this byte 06 holds a complex number encoding a fraction of a container. So combined with what we have above we should see 05 00 00 06



Code:
// Beginning of integer flavors...
TYPE_FIRST_INT = 0x10,

// The 'data' is a raw integer value of the form n..n.
TYPE_INT_DEC = 0x10,
// The 'data' is a raw integer value of the form 0xn..n.
TYPE_INT_HEX = 0x11,
// The 'data' is either 0 or 1, for input "false" or "true" respectively.
TYPE_INT_BOOLEAN = 0x12,Same rules apply here...I dont think I have to keep explaining them all....



Code:
// Beginning of color integer flavors...
TYPE_FIRST_COLOR_INT = 0x1c,

// The 'data' is a raw integer value of the form #aarrggbb.
TYPE_INT_COLOR_ARGB8 = 0x1c,
// The 'data' is a raw integer value of the form #rrggbb.
TYPE_INT_COLOR_RGB8 = 0x1d,
// The 'data' is a raw integer value of the form #argb.
TYPE_INT_COLOR_ARGB4 = 0x1e,
// The 'data' is a raw integer value of the form #rgb.
TYPE_INT_COLOR_RGB4 = 0x1f,

// ...end of integer flavors.
TYPE_LAST_COLOR_INT = 0x1f,

// ...end of integer flavors.
TYPE_LAST_INT = 0x1f
};Means the byte(s) after this byte holds a color value. If the 4th byte is 1C Then the bytes afterwards will define a color value that is in the format #FFFFFFFF transparency, red, green, blue.

If the byte is 1E Then the bytes following will represent a color value in the format #FFF Red, green, blue.

HOWEVER, one thing important to know here is that regardless of the format of the color value whether it be RGB or AARRGGBB Android will convert it to hex and it will appear as FF FF FF FF



Code:
uint8_t dataType;This is where the FIFTH byte gets added, whatever it may be...it will be one of the values listed above.


I will add more stuff later. The file posted below has everything I've added and more....If you want to know more...open that files up and read it...study it...

#9 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 05:13 PM

Commands for using smali and baksmali –

java -jar baksmali-0.93.jar -o <output directory> <.dex file, typically classes.dex>

For example: java -jar baksmali-0.93.jar -o out/rogers/dexout/ rogers-classes.dex

java -Xmx512M -jar smali-0.92.jar <output directory from above step> -o <name for new .dex output file>

For example: java -Xmx512M -jar smali-0.92.jar out/rogers/dexout/ -o new-rogers.dex
First smali file to edit \com\android\server\status\StatusBarIcon.smali
.line 46
const/high16 v6, -0x100
invoke-virtual {v4, v6}, Landroid/widget/TextView;->setTextColor(I)V
This is the change for the clock color. The -0x100 indicates black as the color, change this to:
const v6, -0x1
Where -0x1 indicates white. If you want to use colors, you can use HEX color codes, however the code in the small is 1’s complement of the RRGGBB code. I have provided a brief lesson in Hex, Binary and 1’s complement in Section 4.1
The following are located in \com\android\server\status\StatusBarService.smali
// date coloriput-object v7, p0, Lcom/android/server/status/StatusBarService;->mDateView:Lcom/android/server/status/DateView;
// ongoing coloriput-object v7, p0, Lcom/android/server/status/StatusBarService;->mOngoingTitle:Landroid/widget/TextView;
// latest coloriput-object v7, p0, Lcom/android/server/status/StatusBarService;->mLatestTitle:Landroid/widget/TextView;
// no notifications coloriput-object v7, p0, Lcom/android/server/status/StatusBarService;->mNoNotificationsTitle:Landroid/widget/TextView;
// roam text coloriput-object v7, p0, Lcom/android/server/status/StatusBarService;->mSpnLabel:Landroid/widget/TextView;
// network text coloriput-object v7, p0, Lcom/android/server/status/StatusBarService;->mPlmnLabel:Landroid/widget/TextView;
Above each of these lines you will want to add:
const v8, -0x1
invoke-virtual {v7, v8}, Landroid/widget/TextView;->setTextColor(I)V

#10 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 05:19 PM

Code:
java -jar baksmali-0.93.jar -o <output directory> <.dex file, typically classes.dex>
For example: java -jar baksmali-0.93.jar -o out/rogers/dexout/ rogers-classes.dex

java -Xmx512M -jar smali-0.92.jar <output directory from above step> -o <name for new .dex output file>
For example: java -Xmx512M -jar smali-0.92.jar out/rogers/dexout/ new-rogers.dexFirst command disassembles the .dex file, second command reassembles it (hopefully after you went in and made some cool changes to some of the .smali files)

Re-read your post, these are not for editing XML files. That is a whole other ball of wax. Most devs are not as interested in making post-build modifications now that the source for everything is available. You can set up a build environment and edit the XML files in plain text before you compile everything. Which is a lot easier than hex editing binary XML files...

This is how enomther (so all credit goes to him) explained to me on how to change it.

You can get smali/baksmali here.

I use PSPad to edit the files in windows. I right click and select open with PSPad.



Once you crack open services.jar/classes.dex with baksmali ....there are (2) files of concern, the first is com/android/server/status/StatusBarIcon.smali ... locate this file and open it up and search for ...



Code:
invoke-virtual {v4, v6}, Landroid/widget/TextView;->setTextColor(I)VAbove that line (2 lines up) ... you'll see ...



Code:
const/high16 v6, -0x100That's black .. change to ...



Code:
const v6, -0x1That's white ... this is a simply color change and easier since invoke-virtual is going to give us color out right ... we just have to change the color.

Then locate file ... com/android/server/status/com/android/server/status/StatusBarService.smali

There are (3) lines you need to search for here ... now they don't have inherent color change properties anymore ... which is why colorChange.jar is jacked up for you.

The threes lines to search for (and yes they are each in different places of the file) ... are ...



Code:
iput-object v7, p0, Lcom/android/server/status/StatusBarService;->mDateView:Lcom/android/server/status/DateView;

iput-object v7, p0, Lcom/android/server/status/StatusBarService;->mSpnLabel:Landroid/widget/TextView

iput-object v7, p0, Lcom/android/server/status/StatusBarService;->mPlmnLabel:Landroid/widget/TextView;Again, since these are iput-object calls ... there's no inherent color changing properties ....

You must add the (2) color change lines above each of these lines ... the first lines set a variable for the color value (which in the example) ... the second line forces the text to that color with a call to setTextColor(). So when you're done ... those three lines will be 9 lines (3 lines in 3 seperate places in the file) ... as such ...



Code:
const v8, -0x1

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setTextColor(I)V

iput-object v7, p0, Lcom/android/server/status/StatusBarService;->mDateView:Lcom/android/server/status/DateView;
Code:
const v8, -0x1

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setTextColor(I)V

iput-object v7, p0, Lcom/android/server/status/StatusBarService;->mSpnLabel:Landroid/widget/TextView;
Code:
const v8, -0x1

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setTextColor(I)V

iput-object v7, p0, Lcom/android/server/status/StatusBarService;->mPlmnLabel:Landroid/widget/TextView;See how we're now setting a color variable and calling invoke-virtual prior to iput-object? ... that's the magic.

Save all that up and then run smali ... reinsert your classes.dex ... and you should be all set.

~enom~

#11 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 05:36 PM

As stated above, the color codes in smali are 1’s complement Hex codes. This means they are in Hex, but we have to add some math to convert them to be able to use them.

You first start with the Hex color code you want to use. You will have to first convert your number into binary, instead of making you have to look that up, I have included tables below. You will then invert the binary digit (0 becomes 1 and 1 becomes 0) and then you will want to convert this back into Hex. This is the color you want to use in the smali file.

hex code 0 , 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,A ,B ,C, D, ,E ,F
binary code 0000,0001,0010 0011,0100,0101,0110, 0111,1000,1001,1010,1011,1100,1101,1110,1111
(complement
binary) 1111,1110,1101,1100,1011,1010,1001,1000,0111,0110,0101,0100,0011,0010,0001,0000
new hex F E D C B A 9 8 7 6 5 4 3 2 1 0
To provide an example for you to follow, the Hex code I use is 0DA4F1 to convert this using the table,

· 0 becomes F

· D becomes 2

· A becomes 5

· 4 becomes B

· F becomes 0

· 1 becomes E

So we now have F25B0E, so your smali edit will become -0xF25BOE

#12 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 05:40 PM

(we can`t use metamorph but I will post it anyway) thanks to David 1171
This is what the interior of that template .xml file looks like.


Code:
<?xml version="1.0"?>

<themename></themename>
<themeversion></themeversion>
<screenshot></screenshot>
<author></author>
<authorweblink></authorweblink>
<phone></phone>
<rom></rom>
<themedescription></themedescription>

<item></item>
<path></path>
<description></description>The following is needed as the first line of EVERY .xml file that you make


Code:
<?xml version="1.0"?>Body/Descriptors of the .xml file

The next part of the .xml file is what lets the users know what your morph contains. None of this is actually needed, but it is nice for users so that they may be as well informed of what they are applying as possible.



Code:
<themename></themename>
<themeversion></themeversion>
<screenshot></screenshot>
<author></author>
<authorweblink></authorweblink>
<phone></phone>
<rom></rom>
<themedescription></themedescription>This next section will break each part of this down.

themename


Code:
<themename></themename>This is where you place the name of your theme.

example:


Code:
<themename>example</themename>themeversion


Code:
<themeversion></themeversion>This is where you place what version of your morph this is. In the future, this could prove useful when version checking is added.

example:


Code:
<themeversion>1.0</themeversion>screenshot


Code:
<screenshot></screenshot>I have not been able to get a screen shot to appear in MetaMorph (or know where it would appear inside the app, if someone knows how, then please let me know and I will update this section with more detailed instructions).
The screen shot MUST be in .png format. No other format is supported.
Do not included .png in the name of the image.

example:


Code:
<screenshot>example_screenshot</screenshot>author


Code:
<author></author>This is the area where you place your name as the creator of your morph.

example:


Code:
<author>david1171</author>authorweblink


Code:
<authorweblink></authorweblink>Here is where you can place a link to your website, twitter, thread, or anything else used to define you.
MetaMorph has a problem with some special characters not showing up, so you can use a link shortening service to place your links if they do not work inside of MetaMorph.

example:


Code:
<authorweblink>http://bit.ly/8V5CLL</authorweblink>phone


Code:
<phone></phone>This is where you place the phone you have tested it on, or the version of Android that you have tested it on if it will work on multiple phones.

examples:


Code:
<phone>2.1</phone>
Code:
<phone>Nexus One</phone>rom


Code:
<rom></rom>This is where you place the ROM and ROM version or any other requirements necessary for your morph to work.

examples:


Code:
<rom>CM 5.0.5.3</rom>
Code:
<rom>2.1 with hdpi used</rom>themedescription


Code:
<themedescription></themedescription>This is where you place a BRIEF description of what your morph changes overall.

example:


Code:
<themedescription>Makes phone sexeh!!</themedescription>Location of files

This is the last part of the .xml file and tells MetaMorph what to change and the location of what is changing or being pushed to the phone.

ALWAYS, ALWAYS, ALWAYS Place framework-res.apk as the last item in your .xml file.
Pushing framework-res.apk on certain ROMs can cause a reboot, so it needs to placed as the last item in your .xml file, so that the entire morph can be applied.



Code:
<item></item>
<path></path>
<description></description>Now to break this part of the .xml file down.

item


Code:
<item></item>This is where you place the name .apk/.jar that you are modifying.
The name that you place in between the tags MUST BE THE EXACT SAME AS THE NAME IT HAS ON THE PHONE no exceptions.

examples:


Code:
<item>Laucher2.apk</item>
Code:
<item>DeskClock.apk</item>
Code:
<item>services.jar</item>
Code:
<item>framework-res.apk</item>path


Code:
<path></path>This the path that MetaMorph pulls/pushes the .apk/.jar from the phone to modify it. It must be the exact same location as it resides on the phone.

examples:
<path>/system/app/</path>
<path>/system/framework/</path>

description
Code:
<description></description>You can place a small description of what is changed in the .apk/.jar here.

examples:


Code:
<description>Makes analog clock widget stock green</description>
Code:
<description>Changes the text to white</description>Completed Example .xml file



Code:
<?xml version="1.0"?>

<themename>Stock Analog Clock Widget</themename>
<themeversion>1.0</themeversion>
<screenshot>clock</screenshot>
<author>david1171</author>
<authorweblink>http://bit.ly/8V5CLL</authorweblink>
<phone>Any with DeskClock.apk and hdpi</phone>
<rom>Any with DeskClock.apk and hdpi</rom>
<themedescription>Changes the analog clock widget back to stock green.</themedescription>

<item>DeskClock.apk</item>
<path>/system/app/</path>
<description>Reverts to stock green colors.</description>Questions

Q.Can I make a morph compatible with the .thm and .xml version of MetaMorph?

A.You should be able to, just include the .thm file and the .xml file in the morph.

Q.How can I make .xml files in Windows?

A.I use PSPad to make my .xml files. To make one, open PSPad, go to File, New file..., then scroll down to XML and select it. Once that is done, then you can go about filling the .xml file with your information. I do not know about other operating systems as I primarily use Windows. Yeah, I know you're telling me to sit and spin right now

#13 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 05:46 PM

Zipalign is something a lot of people don’t know about, and even when they do, they don’t use it. The definition by Google on zipalign is:




zipalign is an archive alignment tool that provides important optimization to Android application (.apk) files. The purpose is to ensure that all uncompressed data starts with a particular alignment relative to the start of the file. Specifically, it causes all uncompressed data within the .apk, such as images or raw files, to be aligned on 4-byte boundaries. This allows all portions to be accessed directly with mmap() even if they contain binary data with alignment restrictions. The benefit is a reduction in the amount of RAM consumed when running the application.

This tool should always be used to align your .apk file before distributing it to end-users. The Android build tools can handle this for you. When using Eclipse with the ADT plugin, the Export Wizard will automatically zipalign your .apk after it signs it with your private key. The build scripts used when compiling your application with Ant will also zipalign your .apk, as long as you have provided the path to your keystore and the key alias in your project build.properties file, so that the build tools can sign the package
zipalign is an archive alignment tool that provides important optimization to Android application (.apk) files. The purpose is to ensure that all uncompressed data starts with a particular alignment relative to the start of the file. Specifically, it causes all uncompressed data within the .apk, such as images or raw files, to be aligned on 4-byte boundaries. This allows all portions to be accessed directly with mmap() even if they contain binary data with alignment restrictions. The benefit is a reduction in the amount of RAM consumed when running the application.
Caution: zipalign must only be performed after the .apk file has been signed with your private key. If you perform zipalign before signing, then the signing procedure will undo the alignment. Also, do not make alterations to the aligned package. Alterations to the archive, such as renaming or deleting entries, will potentially disrupt the alignment of the modified entry and all later entries. And any files added to an "aligned" archive will not be aligned.

The adjustment is made by altering the size of the "extra" field in the zip Local File Header sections. Existing data in the "extra" fields may be altered by this process.................Usage
To align infile.apk and save it as outfile.apk:

zipalign [-f] [-v] <alignment> infile.apk outfile.apkTo confirm the alignment of existing.apk:

zipalign -c -v <alignment> existing.apkThe <alignment> is an integer that defines the byte-alignment boundaries. This must always be 4 (which provides 32-bit alignment) or else it effectively does nothing.

Flags:

•-f : overwrite existing outfile.zip
•-v : verbose output
•-c : confirm the alignment of the given file

#14 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 05:47 PM

Signing Made Easy by Stericon:

Please Login HERE or Register HERE to see this link!



Stericson made a batch file that makes signing your update.zips very simple, all you need to do is use his tool located at

Please Login HERE or Register HERE to see this link!



Stericson’s notes on this from the original post are:




Note, this will not work if your SDK or the path that you place this in has any spaces in the dir name!
An Example of this is c:\users\Nikki and Stephen\sdk\tools
Try to put the SDK and the contents of the zip in a dir where the names are all together and not like the one above.


Ok, so I have made a batch file that will automate the entire process of setting up to use the signing tool made by JF. This batch file will set the CLASSPATH, set the PATH, install the registries, let you sign the files manually, and let you push/pull files to the phone.

In order to use this you should have downloaded the sdk already. Simply extract all of the files into the tools dir of your sdk, and run autosign.bat follow the instructions and go through the options one by one, starting with 1 working through 4. You can however, put the contents of this zip anywhere on your computer and it will work. It is just better to put them into the tools dir of your SDK. Especially for the consideration of future versions.

#15 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 05:58 PM

still working on this

#16 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 06:04 PM

I will be adding information to help people complete XML hacks here, however, This is not a simple thing to do!
This is not something you just fall into. Sure, I can tell you what to change for certain effects but you wont learn anything. So other then taking what somebody has done and using it yourself I will not give direct directions on how to create certain effects.

I will help you learn but I will not do it for you.

The first thing to go over is what you will need.
Download TextPad, and HXD. Look on Google for these, consider it homework.

You no longer need to download the source for a reference.
You can find the entire source here:

Please Login HERE or Register HERE to see this link!


I use it as a reference all the time when I'm on windows.

I have uploaded a file called resourcetypes/h that contains alot of information in it about how things are translated to binary, in fact everything I will document below was retrieved from that file.

Keep in mind that Android looks at things in bits when compiling this code into hex. And since in hex all we deal with are bytes we need to do some quick math.

In every byte (00) there are 8 bits When you see something in the code like this: uint16_t size; That is android talking about 16 bits which in hex is 2 bytes because every byte is equal to 8 bits.

Got it? Good...
Lets take a look at some code!

Code:

// Number of bytes in this structure.
uint16_t size;
This means the first two bytes reference how many bytes are in this structure. Specifically speaking, for the most part everything we will deal with here is five bytes long. So the first values in hex would be 05 00 if there were five bytes in this structure...

Code:

// Always set to 0.
uint8_t res0;
This means the next byte will always be zero, since its 8 bits its only one byte. Which would look like this in hex 00 So combined with what we have above we should see 05 00 00

Code:

// Type of the data value.
enum {
enum in this case means that the next byte will be one of the following values depending on what it is we are translating to binary.

Code:

// Contains no data.
TYPE_NULL = 0x00,

Means this byte should be 00 and the byte after it holds no data... So the structure would be 05 00 00 00 ... so far....

Code:

// The 'data' holds a ResTable_ref, a reference to another resource
// table entry.
TYPE_REFERENCE = 0x01,
Means the byte(s) after this byte 01 holds a pointer to a resource, which could be an image or any other type of resource stored with Resources.arsc. So combined with what we have above we should see 05 00 00 01

Code:

// The 'data' holds an attribute resource identifier.
TYPE_ATTRIBUTE = 0x02,
Means the byte(s) after this byte 02 points to an attribute in the resources.arsc. So combined with what we have above we should see 05 00 00 02

Code:

// The 'data' holds an index into the containing resource table's
// global value string pool.
TYPE_STRING = 0x03,
Means the byte(s) after this byte 03 points to a string in the string table of resources.arsc. So combined with what we have above we should see 05 00 00 03

Code:

// The 'data' holds a single-precision floating point number.
TYPE_FLOAT = 0x04,
Means the byte(s) after this byte 04 Holds a floating point number...
So combined with what we have above we should see 05 00 00 04

Code:

// The 'data' holds a complex number encoding a dimension value,
// such as "100in".
TYPE_DIMENSION = 0x05,
Means the byte(s) after this byte 05 holds the value of dimension...a lot of times this can be a vlaue for a height or a width of an object, such as an image. So combined with what we have above we should see 05 00 00 05

Code:

// The 'data' holds a complex number encoding a fraction of a
// container.
TYPE_FRACTION = 0x06,
Means the byte(s) after this byte 06 holds a complex number encoding a fraction of a container. So combined with what we have above we should see 05 00 00 06

Code:

// Beginning of integer flavors...
TYPE_FIRST_INT = 0x10,
// The 'data' is a raw integer value of the form n..n.
TYPE_INT_DEC = 0x10,
// The 'data' is a raw integer value of the form 0xn..n.
TYPE_INT_HEX = 0x11,
// The 'data' is either 0 or 1, for input "false" or "true" respectively.
TYPE_INT_BOOLEAN = 0x12,
Same rules apply here...I dont think I have to keep explaining them all....

Code:

// Beginning of color integer flavors...
TYPE_FIRST_COLOR_INT = 0x1c,
// The 'data' is a raw integer value of the form #aarrggbb.
TYPE_INT_COLOR_ARGB8 = 0x1c,
// The 'data' is a raw integer value of the form #rrggbb.
TYPE_INT_COLOR_RGB8 = 0x1d,
// The 'data' is a raw integer value of the form #argb.
TYPE_INT_COLOR_ARGB4 = 0x1e,
// The 'data' is a raw integer value of the form #rgb.
TYPE_INT_COLOR_RGB4 = 0x1f,
// ...end of integer flavors.
TYPE_LAST_COLOR_INT = 0x1f,
// ...end of integer flavors.
TYPE_LAST_INT = 0x1f
};
Means the byte(s) after this byte holds a color value. If the 4th byte is 1C Then the bytes afterwards will define a color value that is in the format #FFFFFFFF transparency, red, green, blue.

If the byte is 1E Then the bytes following will represent a color value in the format #FFF Red, green, blue.

HOWEVER, one thing important to know here is that regardless of the format of the color value whether it be RGB or AARRGGBB Android will convert it to hex and it will appear as FF FF FF FF

Code:

uint8_t dataType;
This is where the FIFTH byte gets added, whatever it may be...it will be one of the values listed above.


I will add more stuff later. The file posted below has everything I've added and more....If you want to know more...open that files up and read it...study it...

#17 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 06:07 PM

let me know what you think about this and if I should update as things come along

#18 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 04 July 2010 - 06:15 PM

this is a color code chart

Please Login HERE or Register HERE to see this link!



#19 OFFLINE   agreenbhm

    Android Pro

  • Members
  • 629 posts
  • Device:Droid

Posted 05 July 2010 - 04:56 AM

I'm not going to lie; tldnr at the moment. Thanks Brian for this incredibly extensive How-To that I'm sure many will get great use out of! When I have the time I'll be coming back and reading all the way through. Good work!

#20 OFFLINE   brian

    MDW Writer

  • Members
  • 603 posts
  • Device:EVO Shooter aka EVO 3d / Nexus S

Posted 05 July 2010 - 10:23 AM

YES YOU MUST BE ROOTED. PLEASE ALWAYS MAKE A BACK UP OF THE ORIGINAL LiveWallpapers.apk JUST IN CASE YOU NEED IT.


If this is to much for you to do go here for my Custom liveWallpapers for Ultimate Droid.

Ok first things first you will need the necessary programs to edit your images and make your files-

1. A photo editing program (i use photoshop but ive heard of gimp and others)


2. 7zip get that here


3. also i suggest WinRaR (for making your update.zips) get that here

Some of the files you will need-


1. the live wallpapers update.zip template


2. You will need the LiveWallpapers.apk specific to your ROM

Next is the files needed to customize your Live Wallpapers-


the original nexus.rs from the neural network(droid) LWP Found in your LiveWallpapers.apk


the 4 color modified one here

Ok now that thats out of the way we can start.


1. the first thing you will need to do is to get the LiveWallpapers.apk out of your /system/app/. this can be done using root explorer or any other root file manager. (you can also use adb pull but i dont know the script)


2. Once you have that onto your the ROOT of your SD Card. hook up you droid to your computer and mount it. goto to your droid and move the LiveWallpapers.apk to your Desktop.


3. Right click the LiveWallpapers.apk and goto 7zip>open archive.


4. now that your in 7zip goto res>drawable-hdpi this is the image folder within you livewallpapers. go to the image called pyramid_Back.... you can simply click and drag this to your desktop or another easy to access location.


5. now open your image editing software and change the image to what you want (but keep the Resolution/size the same). now when it comes to saving save it as the same name and as a normal .png file. once you've saved it check to make sure your withing 30 KB of the original(original file size is 325 KB)


6. go into 7zip and delete the original file and put the new on in(i do this as a security measure to make sure its in properly.)

Now to edit the Fazer colors-


1. now download the nexus.rs file above and once you have it one to your desktop open it in notepad.


2. find the strand of text that looks like this
void setColor(int c) {

if (c == 0) {

// silver

color(0.75f, 0.75f, 0.75f, 0.9f);

} else if (c == 1) {

// Blue

color(0.0f, 0.0f, 1.0f, 0.9f);

} else if (c == 2) {

// silver

color(0.75f, 0.75f, 0.75f, 0.9f);

} else if (c == 3) {

// blue

color(0.0f, 0.0f, 1.0f, 0.9f);

}

}


3. to edit this go here and find the RGB code for the color


For example if i wanted blue and silver as above, i would find blue the code is 0-0-255. divide all the numbers by 255 so you would get 0.0, 0.0, 1.0, and the last number is the amount of transparency. 1.0 being all color and 0.0 being all transparent. you must also add the color name in the corect capitulization format (Blue or Royal Blue) not (blue or royal blue)


4. lets say i wanted Orange Red the code is 255-69-0 so my strand would look like this:
void setColor(int c) {

if (c == 0) {

// silver

color(0.75f, 0.75f, 0.75f, 0.9f);

} else if (c == 1) {

// Orange Red

color(1.0f, 0.27f, 0.0f, 0.9f);

} else if (c == 2) {

// silver

color(0.75f, 0.75f, 0.75f, 0.9f);

} else if (c == 3) {

// Orange Red

color(1.0f, 0.27f, 0.0f, 0.9f);

}

}


as you can see 69 cannot be divide by 255 so i gives me a number like this 0.270588.... round to the hundredths place to get 0.27f.


you can have up to 4 different colors.


5. goto file save then exit note pad.


6. goto 7zip again and delete the original nexus.rs and put the new one in.

Now to Get the LiveWallpapers.apk to your Phone-


This can be done two ways, i suggest doing it with adb shell first then you can make your update.zip.

Adb shell Way

1.plug your phone in mount it, then move the new LiveWallpapers.apk into the root of your SD Card. then unmount.


2. shut down your phone and boot into recovery while your phone is still pluged in.


3. goto mount> and mount system and SDCard. also you must have the android SDK installed on your comuter. heres a tutorial on how to set that up. read the first one only.


4. open command prompt on your computer and type cd C:\tools or cd C:\were ever you put them hit enter. then type
Code:
adb shell
then
Code:
#cd sdcard (hit enter)
#busybox cp -R LiveWallpapers.apk /system/app/ (again enter)
#exit (again enter)
5. unmount sytem then SD card and reboot your phone.


6. goto livewallpapers and see if they worked. enjoy!

Now for the Update.zip method-


1. download the update.zip template above


2 open this in winrar and goto system>app>and replace yourlivewallpapers.apk with the modified livewallpapers.apk


3 rename to update.zip put on the root of your sd card. then reboot into recovery goto install>allow update.zip>install update.zip from sdcard.


4.reboot and enjoy!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users