[Tutorial][Linux]Themer's Portal and Guide

Search This thread

artvandelay440

Senior Member
Feb 8, 2011
1,422
1,122
"If you can't explain something simply, you don't know it well enough" -Albert Einstein

There are a ton of guides available for theming, but I have always found most to be either a) erroneous b) way over complicated or c) out of date. I'll try to keep this simple, easy to understand, and up to date.

Introduction

There are 2 main ways to theme. You can choose the more powerful “zip” style that gives you complete control but is more difficult and time consuming to maintain, or you can choose the “theme chooser” method that is much easier to maintain, but is more limited. A lot of themers will do a theme chooser apk and supplement it with an additional zip file that finishes things the theme chooser cannot. That’s what i do. I recommend Linux for theming since more of the advanced concepts are best done on linux. (Git, source building, etc) For the purpose of this guide, I’ll use my Elegant Dusk as a reference and Ubuntu 12.04 as my distribution of Linux.

Decompiling

Without building directly from source, you'll need apktool to decompile apps. We'll use Apkmultitool for this, since it will sign your apps with a debug key so you can actually install them to your device.

Download this ApkMultiTool, (Choose the "Linux Version 1.0" at the bottom) then extract it to your desktop, then rename the folder ApkMultiTool.

Once extracted, open a terminal and go to that directory by typing

cd /Desktop/ApkMultiTool
Now, we need to make the script executable. From the open terminal, type

then type ./Script.sh to execute it.

If you got an error about optipng and sox are not in your path, simply open another terminal and run this:

sudo apt-get install optipng p7zip-full sox
You should get a menu like this:

isINS8fhSe6Dv.png




Now, we need to patch the aapt to the newest version. In your Android SDK folder, look in the platform-tools folder and grab the aapt file from there and place it in the /other folder in ApkMultiTool. This ensures you have the latest aapt (Android Assets Packaging Tool)



Minimize that and place ElegantDusk.apk into the place-here-for-modding folder. Then maximize the script and choose option 9 to decompile. You should now have a /out folder with several things in it. This is our project folder to begin theming. Navigate to /out/res and let's begin.

Working with Images

First, you'll need an image editor. Since we're using Linux, i recommend the GIMP. Open a terminal (Ctrl + Alt + T) and run this:

apt-get install gimp
Once that's done, launch gimp (either from the dash or by typing gimp into a terminal) and we're ready to theme. I can't get into a full GIMP tutorial here, but that will get it installed, and you can either play with it or find some of the zillion gimp tutorials.

Ok, you've edited an image and are ready to test it on your phone. Let's say you want to change the settings background. That's controlled by frameworks_res_background_holo_dark.png in the drawable-nodpi folder of my theme. Change it however you want. If you're done and ready to compile, refer back to the recompile section above. Or, continue on for more tips.

What the heck is a .9.png file?

Android has devised a method of special metadata that can stretch an image in certain ways so it doesn't have to store tons of large image files in it's resources. In other words, it's an optimization technique. We can edit these easily within GIMP, or we can redraw them with a tool that comes with the AndroidSDK called draw9patch.bat. It's in the /tools folder. Let's look at one.

ab_bottom_solid_light_holo.9.png


See the 1 pixel black lines around it? The position of that tells android how and where to stretch the image, as well as where content (ie text) can be displayed inside it. The top and left sides tell android where to stretch and the bottom/right tell it where content can be displayed. As we see, content can be displayed everywhere, and the image is stretched in only a small part. For theming, you NEVER want to touch the black lines, so when you change something inside (the gray area), make extremely sure to never alter them in any way. It will cause literally dozens of compile errors with no warning as to which file caused it (a huge pain).

Working with XML

XML (eXtensible Markup Language) is the primary code language we'll be dealing with in theming. There are a TON of programs that can edit xml, but since we deal with it a lot, it's good to get one that looks nice and has syntax correction. I recommend Sublime Text 2. Let's install it with these 3 commands. Run them seperate.

sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text-2
Now let's look at a simple XML. Go to /res/values/colors.xml and open it with sublime text. (Right click>open with) You'll see this:

ikqdkEuzFex0.png


The values are on the right side listed as #ffffffff or similar. These are hexadecimal ARGB color codes. Each set of 2 letters/numbers represent something. The first two (Alpha) are the transparency. FF means fully opaque and 00 means fully transparent. 50 would be 50% transparent. The next set of two (R) represent the red value, or how much red is in the color shade. Again, FF is fully saturated pure red and 00 is no red at all. The same applies to the next two sets. (Green and Blue) This makes up ARGB, so the example of #ffffffff would be fully opaque and full colors of red, green, and blue, which make white. So the hex for white is #FFFFFFFF.

ICS Blue is #ff33b5e5, just in case you are wondering.

Change any values you like, and then simply hit save at the top menu.

Ok, so what about changing more than just colors that were already there? Read on:

Let's say you wanted to change an entire style. I'll use MMS as an example. There are tons of "inverted MMS" apps out there, mainly because it is one of the easiest apps to invert. We want to change the light style to a dark style, so how do we do that? There are a handful of edits we need to do, but since we are concentrating on styles, let's start there. Open /res/values/styles.xml and search for theme.holo.light.darkactionbar. Found it? Change it to theme.holo (so, delete the .light.darkactionbar part) we've just told MMS to use the android "holo" style, which is dark with white text. There's a lot more to it, but this is a simple example of redirecting styles within an app.





Compiling

This is where it gets fun. There can be a lot of errors at this point so be patient. After you've edited your images and .pngs you need to pack it all up again. Maximize your script.sh again and choose option 10 for compile. If you need, scroll up when it's done to see if it built ok. It should look like this:

iwBnBpD3MuggE.png


Odds are you might get some errors at this stage, so copy the log and post it in a pastebin or similar and i'll try to help as time permits. If no errors, you now need to sign it. If you look in the place-here-for-modding folder, there will now be an unsigned apk waiting. After choosing option 11 to sign, it will change to a signed apk, and you can rename it whatever you like and install like a regular app.
 
Last edited:

etoy

Senior Member
Dec 21, 2009
1,814
862
that's why i'm trying to set up a build environment to compile directly from source (without success for now hehe).

apktool is powerful but not enough, it causes many FCs with some APKs (deskclock, camera, contacts, etc..)
 
Last edited:

sonnysekhon

Inactive Recognized Themer
Aug 15, 2010
4,166
5,479
Vancouver
Not yet. I've even figured out how to make the dialer transparent. Too bad there is no easy way to compile it other than from the source.
 

artvandelay440

Senior Member
Feb 8, 2011
1,422
1,122
Is there a tutorial somewhere on how to build contacts from source? I'd really really really like to have it in my theme

Sent from my Galaxy Nexus using xda premium
 

etoy

Senior Member
Dec 21, 2009
1,814
862
i don't know exactly. you have to use linux for sure, then update jdk, download android sdk and so on..then sync with aokp github and compile. but in fact it's a little harder than i explained lol. there's a lot of guides but no one is complete and updated, i tried many of them but every one has some missing part and i can't proceed somehow.

we should find some dev that spends a little time to explain the fundamentals of compiling from source, then we can help each other with it.
 
  • Like
Reactions: agnostic900rr

chopper the dog

Senior Member
Oct 17, 2008
2,058
744
The blood bath known as Chicago IL.
Is there a tutorial somewhere on how to build contacts from source? I'd really really really like to have it in my theme

Sent from my Galaxy Nexus using xda premium
The only way to build one apk is, you need to make a full rom build first and then you can do a command for one apk. I was in the same boat and trav posted his contacts source and I told someone what xml's I wanted edited (to get rid of blue text) so that person built me the apk and I handled the images on my end cause I'm able to decompile/recompile contacts without errors (but yes phone F's me) so after compile of apk and my images I just 7zip them into the built one. You guys are more than welcome to kang the contacts/phone apk's (un holo'd) from my themes if it'll help (link in sig).


good day.
 

sonnysekhon

Inactive Recognized Themer
Aug 15, 2010
4,166
5,479
Vancouver
I am content with the way things are until the Theme Chooser gets updated for ICS. Theming will get so much easier then :).
 

artvandelay440

Senior Member
Feb 8, 2011
1,422
1,122
The only way to build one apk is, you need to make a full rom build first and then you can do a command for one apk. I was in the same boat and trav posted his contacts source and I told someone what xml's I wanted edited (to get rid of blue text) so that person built me the apk and I handled the images on my end cause I'm able to decompile/recompile contacts without errors (but yes phone F's me) so after compile of apk and my images I just 7zip them into the built one. You guys are more than welcome to kang the contacts/phone apk's (un holo'd) from my themes if it'll help (link in sig).


good day.

Thanks, i think i'll do that. Your theme colors are more fitting than what i have now. I'll be compiling a full rom on a spare virtual machine today, and if by some miracle, it works, then i can post source to it as well.
 

chopper the dog

Senior Member
Oct 17, 2008
2,058
744
The blood bath known as Chicago IL.
Thanks, i think i'll do that. Your theme colors are more fitting than what i have now. I'll be compiling a full rom on a spare virtual machine today, and if by some miracle, it works, then i can post source to it as well.
Any of the colors in those is handled all with images. I had the apk built with all the blue.holo text changed to 9a9a9a so that it could be a neutral theme. I just edit .9's and other images for multiple themes and use same apk base.


good day.
 
  • Like
Reactions: incredulous

artvandelay440

Senior Member
Feb 8, 2011
1,422
1,122
Any of the colors in those is handled all with images. I had the apk built with all the blue.holo text changed to 9a9a9a so that it could be a neutral theme. I just edit .9's and other images for multiple themes and use same apk base.


good day.

Ah, so technically, i could use 7zip to simply replace the images i want. Wouldn't that cause issues with .9 images, since they need to be compiled again to be drawn correctly?
 

chopper the dog

Senior Member
Oct 17, 2008
2,058
744
The blood bath known as Chicago IL.
Ah, so technically, i could use 7zip to simply replace the images i want. Wouldn't that cause issues with .9 images, since they need to be compiled again to be drawn correctly?
That's were I was saying I have no problems de/recompiling contacts so I use a sacrificial apk to decompile make all image edits compile and 7zip image folders into working apk.


good day.
 

sonnysekhon

Inactive Recognized Themer
Aug 15, 2010
4,166
5,479
Vancouver
That's were I was saying I have no problems de/recompiling contacts so I use a sacrificial apk to decompile make all image edits compile and 7zip image folders into working apk.


good day.

Just tried your apk and it's perfect for minimalist themes :).

Can you also please get rid of the blue strip on the top of the call screen or is that in Phone.apk?
 

artvandelay440

Senior Member
Feb 8, 2011
1,422
1,122
I need to figure out where that edit is at and have my smarter than me friend build me an apk. It has annoyed me but laziness has prevailed.


good day.

It's in wither framework or systemui, that i know. (i'm thinking systemui) Here's how it turned out. And i can build phone.apk just fine if you need as well.
 

Attachments

  • dialer.jpg
    dialer.jpg
    19.6 KB · Views: 358

etoy

Senior Member
Dec 21, 2009
1,814
862
i'd love a contacts.apk without that bastard dividers between contacts..

got rid of all of them in framework and phone.apk but that one is in values\colors.xml and can't be removed (yet)
 

Top Liked Posts

  • There are no posts matching your filters.
  • 19
    "If you can't explain something simply, you don't know it well enough" -Albert Einstein

    There are a ton of guides available for theming, but I have always found most to be either a) erroneous b) way over complicated or c) out of date. I'll try to keep this simple, easy to understand, and up to date.

    Introduction

    There are 2 main ways to theme. You can choose the more powerful “zip” style that gives you complete control but is more difficult and time consuming to maintain, or you can choose the “theme chooser” method that is much easier to maintain, but is more limited. A lot of themers will do a theme chooser apk and supplement it with an additional zip file that finishes things the theme chooser cannot. That’s what i do. I recommend Linux for theming since more of the advanced concepts are best done on linux. (Git, source building, etc) For the purpose of this guide, I’ll use my Elegant Dusk as a reference and Ubuntu 12.04 as my distribution of Linux.

    Decompiling

    Without building directly from source, you'll need apktool to decompile apps. We'll use Apkmultitool for this, since it will sign your apps with a debug key so you can actually install them to your device.

    Download this ApkMultiTool, (Choose the "Linux Version 1.0" at the bottom) then extract it to your desktop, then rename the folder ApkMultiTool.

    Once extracted, open a terminal and go to that directory by typing

    cd /Desktop/ApkMultiTool
    Now, we need to make the script executable. From the open terminal, type

    then type ./Script.sh to execute it.

    If you got an error about optipng and sox are not in your path, simply open another terminal and run this:

    sudo apt-get install optipng p7zip-full sox
    You should get a menu like this:

    isINS8fhSe6Dv.png




    Now, we need to patch the aapt to the newest version. In your Android SDK folder, look in the platform-tools folder and grab the aapt file from there and place it in the /other folder in ApkMultiTool. This ensures you have the latest aapt (Android Assets Packaging Tool)



    Minimize that and place ElegantDusk.apk into the place-here-for-modding folder. Then maximize the script and choose option 9 to decompile. You should now have a /out folder with several things in it. This is our project folder to begin theming. Navigate to /out/res and let's begin.

    Working with Images

    First, you'll need an image editor. Since we're using Linux, i recommend the GIMP. Open a terminal (Ctrl + Alt + T) and run this:

    apt-get install gimp
    Once that's done, launch gimp (either from the dash or by typing gimp into a terminal) and we're ready to theme. I can't get into a full GIMP tutorial here, but that will get it installed, and you can either play with it or find some of the zillion gimp tutorials.

    Ok, you've edited an image and are ready to test it on your phone. Let's say you want to change the settings background. That's controlled by frameworks_res_background_holo_dark.png in the drawable-nodpi folder of my theme. Change it however you want. If you're done and ready to compile, refer back to the recompile section above. Or, continue on for more tips.

    What the heck is a .9.png file?

    Android has devised a method of special metadata that can stretch an image in certain ways so it doesn't have to store tons of large image files in it's resources. In other words, it's an optimization technique. We can edit these easily within GIMP, or we can redraw them with a tool that comes with the AndroidSDK called draw9patch.bat. It's in the /tools folder. Let's look at one.

    ab_bottom_solid_light_holo.9.png


    See the 1 pixel black lines around it? The position of that tells android how and where to stretch the image, as well as where content (ie text) can be displayed inside it. The top and left sides tell android where to stretch and the bottom/right tell it where content can be displayed. As we see, content can be displayed everywhere, and the image is stretched in only a small part. For theming, you NEVER want to touch the black lines, so when you change something inside (the gray area), make extremely sure to never alter them in any way. It will cause literally dozens of compile errors with no warning as to which file caused it (a huge pain).

    Working with XML

    XML (eXtensible Markup Language) is the primary code language we'll be dealing with in theming. There are a TON of programs that can edit xml, but since we deal with it a lot, it's good to get one that looks nice and has syntax correction. I recommend Sublime Text 2. Let's install it with these 3 commands. Run them seperate.

    sudo add-apt-repository ppa:webupd8team/sublime-text-2
    sudo apt-get update
    sudo apt-get install sublime-text-2
    Now let's look at a simple XML. Go to /res/values/colors.xml and open it with sublime text. (Right click>open with) You'll see this:

    ikqdkEuzFex0.png


    The values are on the right side listed as #ffffffff or similar. These are hexadecimal ARGB color codes. Each set of 2 letters/numbers represent something. The first two (Alpha) are the transparency. FF means fully opaque and 00 means fully transparent. 50 would be 50% transparent. The next set of two (R) represent the red value, or how much red is in the color shade. Again, FF is fully saturated pure red and 00 is no red at all. The same applies to the next two sets. (Green and Blue) This makes up ARGB, so the example of #ffffffff would be fully opaque and full colors of red, green, and blue, which make white. So the hex for white is #FFFFFFFF.

    ICS Blue is #ff33b5e5, just in case you are wondering.

    Change any values you like, and then simply hit save at the top menu.

    Ok, so what about changing more than just colors that were already there? Read on:

    Let's say you wanted to change an entire style. I'll use MMS as an example. There are tons of "inverted MMS" apps out there, mainly because it is one of the easiest apps to invert. We want to change the light style to a dark style, so how do we do that? There are a handful of edits we need to do, but since we are concentrating on styles, let's start there. Open /res/values/styles.xml and search for theme.holo.light.darkactionbar. Found it? Change it to theme.holo (so, delete the .light.darkactionbar part) we've just told MMS to use the android "holo" style, which is dark with white text. There's a lot more to it, but this is a simple example of redirecting styles within an app.





    Compiling

    This is where it gets fun. There can be a lot of errors at this point so be patient. After you've edited your images and .pngs you need to pack it all up again. Maximize your script.sh again and choose option 10 for compile. If you need, scroll up when it's done to see if it built ok. It should look like this:

    iwBnBpD3MuggE.png


    Odds are you might get some errors at this stage, so copy the log and post it in a pastebin or similar and i'll try to help as time permits. If no errors, you now need to sign it. If you look in the place-here-for-modding folder, there will now be an unsigned apk waiting. After choosing option 11 to sign, it will change to a signed apk, and you can rename it whatever you like and install like a regular app.
    4
    This is from my discussion thread that got lost :p,


    Tools:

    Update your sdk to 4.0
    Latest Apkmanager (5.0.2) (make sure you replace the aapt with the latest one from your 4.0 sdk install)/ Apk Multi-Tool
    Latest Apktool

    Install the framework:

    Code:
    apktool if framework-res.apk

    Framework Compilation Errors:

    You will notice that you get a lot of 'plurals.xml line 79' errors when trying to compile the framework.

    You have to go the line 79 in each xml that gave an error and add a % in front of the 2nd %d.

    For example in values/plurals.xml, change the following:

    Code:
    <item quantity="other">%d of %d</item>

    to:

    Code:
    <item quantity="other">%d of %%d</item>

    It will compile ok after that.

    Clock/Carrier/Ticker/Text Highlight colors:

    In framework-res/res/values/colors.xml, change the following to your desired hex color code:

    Code:
    <color name="holo_blue_light"></color>
    <color name="holo_blue_dark"></color>
    <color name="highlighted_text_holo_dark"></color>
    <color name="highlighted_text_holo_light"></color>

    Notifications background color:

    In SystemUI/res/values/drawables.xml, change the following to your desired hex color code:

    Code:
        <item type="drawable" name="notification_item_background_color"></item>
        <item type="drawable" name="notification_item_background_color_pressed"></item>
        <item type="drawable" name="status_bar_notification_row_background_color"></item>
        </item>

    Changing the statusbar image:

    In SystemUI/res/values/drawables.xml, change this one line and change the corresponding image in drawable-hdpi/xhdpi:

    Code:
        <drawable name="status_bar_background">@drawable/status_bar_bg_tile</drawable>
        </item>

    Changing the notification pulldown image:

    In SystemUI/res/layout/status_bar_tracking.xml, add ---android:background="@drawable/pulldown"--- to the first line and add the corresponding image in drawable-hdpi/xhdpi:

    Code:
        <com.android.systemui.statusbar.phone.TrackingView android:orientation="vertical" android:background="@drawable/pulldown" android:paddingLeft="0.0px" android:paddingRight="0.0px" android:paddingBottom="0.0px" android:focusable="true" android:visibility="gone" android:descendantFocusability="afterDescendants"

    Removing the tint that Google inexplicably added to all the notifications:

    In SystemUI/res/values/dimens.xml, change this value to anything you like:

    Code:
        <item type="dimen" name="status_bar_icon_drawing_alpha"></item>
        </item>

    Changing it to 100% will get rid of the tint altogether.
    3
    3
    How to create themes for the Theme Chooser:
    There's a great guide at RootzWiki, and I'll link it when their site goes back up. Meanwhile:
    -Find a template apk to use and decompile it. I recommend a cm9 theme chooser apk, since the older cm7 ones have different package names often. Look at the naming structure in the drawables folder. You'll notice framework images are labeled like this: frameworks_res_imagename.png Essentially, every app's package name is added as a prefix to the beginning of the file to show it where to replace in the system. To begin with, just try replacing existing images, as this requires no additional edits.

    -BEFORE you resign and install, be sure to change the package name, author, app name, etc. in the androidmanifest.xml, and also change styles and strings.xml to reflect the exact same title. Otherwise your package will overwrite whatever you used as a base template.

    -Once you are comfortable replacing images, you can begin to generate new content. Let's say you want to theme the camera from your older zip style theme and incorporate it into the theme chooser apk. take all your old images and rename them according to the naming scheme. For camera this would add the prefix com_android_camera_imagename.png. Once all your images have this prefix, drop them into the drawables folder (xhdpi for the GNexus).
    - Now, you have to generate an xml to redirect the system to those images. The xml should have the same package name. For our camera example, this would be com.android.camera.xml, and it goes in the xml folder.

    As you can see, each image has to be redirected individually. Simple take the line from your existing camera xml (note: anything in the /layout folder will not work) and paste that line into the com_android_camera.xml. Once all your images are properly referenced in the corresponding xml, recompile, sign, and install, then select in the chooser!
    iko1ydVf8OZhY.PNG
    2
    Is there a tutorial somewhere on how to build contacts from source? I'd really really really like to have it in my theme

    Sent from my Galaxy Nexus using xda premium
    The only way to build one apk is, you need to make a full rom build first and then you can do a command for one apk. I was in the same boat and trav posted his contacts source and I told someone what xml's I wanted edited (to get rid of blue text) so that person built me the apk and I handled the images on my end cause I'm able to decompile/recompile contacts without errors (but yes phone F's me) so after compile of apk and my images I just 7zip them into the built one. You guys are more than welcome to kang the contacts/phone apk's (un holo'd) from my themes if it'll help (link in sig).


    good day.