• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[GUIDE] T-mobile theme engine for the faint at heart (non-linux users)

Search This thread

nhnt11

Senior Member
Sep 16, 2010
1,376
1,116
Bangalore
Hi guys,

This is a guide I put together to make themes for the T-Mobile theme engine based mostly on what i've figured out by digging into haxzamatic's awesome template.

This does not require you to be on linux or whatever.

This is mainly a temporary guide till an Eclipse template for the engine is released, or for those who dont want to use eclipse, etc.

Requirements:
-You should know how to decompile/recompile/sign apk files.
-You should know some basic xml editing and theming.
-basic terminal commands
-You must install the framework for apktool, navigate to the folder containing framework-res.apk and execute -
apktool if framework-res.apk


GUIDE:

1. Get the compiled Templatebread from here: http://bit.ly/hdEWsf

2. Decompile it with apktool or whatever you use.

3. Open the AndroidManifest.xml

4. Change the names according to your theme. Here's my manifest for my NTSense theme:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:hasCode="false" android:versionCode="2" android:versionName="1.1" android:installLocation="internalOnly" package="com.nhnt11.theme.ntsense"
  xmlns:android="http://schemas.android.com/apk/res/android" xmlns:pluto="http://www.w3.org/2001/pluto.html">
    <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="9" />
    <application android:label="@string/theme_name" android:icon="@drawable/icon">
        <activity android:label="@string/theme_name" android:name="com.tmobile.theme.Foo" />
    </application>
    <theme pluto:themeId="NTSense" pluto:styleId="@style/NTSense" pluto:name="@string/theme_name" pluto:preview="\@drawable/preview" pluto:author="@string/author" pluto:copyright="@string/copyright" pluto:wallpaperImage="@drawable/wallpaper" pluto:styleName="@string/style_appearance_name" pluto:ringtoneName="Standard" pluto:ringtoneFileName="media/audio/ringtones/Standard.mp3" pluto:notificationRingtoneName="Subtle" pluto:notificationRingtoneFileName="media/audio/notifications/Subtle.mp3" />
</manifest>

Note that the template xml file has "pluto:name="\@string/theme_name" - you need to remove this backslash, its a typo. it should be just "@string/theme_name" Should not be needed using latest version of apktool.

More detail about stuff in the manifest in 2nd post.

5. Open /res/values/strings.xml. Edit to match your theme. Here's mine again:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string name="app_name">NTSense Theme</string>
    <string name="theme_name">NTSense</string>
    <string name="style_appearance_name">NTSense</string>
    <string name="author">nhnt11</string>
    <string name="copyright">nhnt11</string>
</resources>

6. Same for /res/values/styles.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <style name="NTSense" parent="@android:style/Theme" />
</resources>

NOTE: the name of your style must be the same as the pluto:styleID in the manifest!!!

7. Now, if you are making a theme from scratch, go ahead and just edit the images already in the hdpi folder. compile and sign. done. But, read on anyway because i explain how the theme engine works below.

If you want to port a theme, here's what to do:

First, go ahead and delete all the drawable folders. Now, copy your THEMED drawable folders into the directory. You now have to add the following to your theme:
/res/drawable-_dpi/preview.png (prefarably hdpi I guess) (I suggest that you DO NOT remove the backslash in the manifest as different locations of preview.png do not work on different screen sized devices. RETAIN the backslash!! Your theme will not have a preview, but this is a small trade off to get themes working if you're not on linux.)
/res/drawable/wallpaper.png (this can be in drawable-_dpi for different screen res. too)
/res/drawable-_dpi/icon.png.
More detail on those in the second post.

8. Now go to /res/xml - there are a ton of xml's here. Open redirections.xml.
Here, there are entries for specifying which XML redirects which app. Add entries like so:

<package-redirections android:name="<app package name here>"
android:minSdkVersion="7"
android:resource="@xml/your_xml_file(without '.xml' at the end)" />

You have now specified that you want resources in <app> to be redirected based on what's in your_xml_file. Where and what is this your_xml_file and how do you add/modify it? That's what the rest of the xml's in the res/xml folder are.

The rest of these xmls are the heart of the theme engine. How they work is, when android asks for an image or other resource, they come in and switch that resource for your themed one. So its sort of like a proxy server.

Each xml contains the redirections for an app.
For example, redirections to framework-res.apk are in android.xml, and SystemUI is in com_android_systemui.xml
Delete files corresponding to apps you have not themed (for consistency, you might also want to delete the corresponding entry in redirections.xml. If you don't know how, just leave it). You can also add apps by using the convention, <package name>.xml where dots in the package name are separated by underscores, ie. your_package_name.xml for your.package.name

Package names of apps can be found in their respective AndroidManifest.xml's after decompiling. See 2nd post for more detail.

To redirect files, for eg. title_bar_portrait.9.png, just add the item to the systemui xml like so:

Code:
<item name="drawable/title_bar_portrait">@drawable/title_bar_portrait</item>

Note: To make it easy to add hundreds of drawables, I've written a little xml generator - here

Here, the "name" part tells the theme engine WHAT you're replacing.
the part inside the item tag ("@drawable/title_..... in this case") tells it WHAT to replace it with.

In all android packages, the @ sign means that you are referring to a resource in the package. Also, you can refer to a general system-wide resource by using @android:<whatever>

for example, you can replace the above title_bar_portrait with statusbar_background thats already in the android framework like so:

Code:
<item name="drawable/title_bar_portrait">@android:drawable/statusbar_background</item>

After the @ symbol, you have to specify the type of resource. in this case, "drawable".

Note that because the @ symbol refers to something INSIDE your package, you SHOULD NOT use it in the item name="<blablabla>" part.

See Variables in the second post for more detail.

Back to the xmls.

Pretty much all images are ALREADY entered in the xml. Just do a find and replace and get rid of all the "frameworks_res_" and "com_android_systemui_"
for eg, it already has <item name="drawable/title_bar_portrait">@drawable/com_android_systemui_title_bar_portrait</item>, so you need to get rid of the "com_android_systemui_" part.

Actually the professional/clean way to do it would be to rename all of your files to include "package_to_which_it_belongs_" at the front of the filename for better organisation. if you have the time and patience, do it this way!!!!

9. Delete the /res/values/public.xml. Its useless and annoying while compiling. It will be regenerated while compiling.

10. Try to compile the apk. you will probably get errors, because although all the resources are listed in the android.xml (or whatever) you deleted the HDPI folder so many might be missing! it will print what is missing when you compile though, so just go ahead and delete those lines.

11. you can also re-map styles, colors, drawables, etc.. for eg. battery percentage, add this to android.xml after putting the required battery xml in res/drawable:

<item name="drawable/stat_sys_battery">@drawable/stat_sys_battery</item>

also for a color, just add it to /res/values/colors.xml and then in android.xml, add

<item name="color/[name of color]">@color/[name of your color]</item>

See variables in the second post for more info.

12. Sign your compiled apk, and install it! If all goes well you will be able to apply and see the changes after you reboot.

Hope this helped!
 
Last edited:

nhnt11

Senior Member
Sep 16, 2010
1,376
1,116
Bangalore
More detail

Stuff in the Manifest
The manifest contains several general properties of your app file.
The following are a few which are referenced here.
  • To change the ringtone: Just put your desired ringtones/notification sound in /assets/media/audio/<Ringtones/Notifications> To prevent your theme from changing the ringtones, delete the corresponding lines from AndroidManifest.xml. I'm sure you can figure out which lines to delete. Also, you can remove the /assets folder, unless you have some other asset in it. (in which case just delete the ringtone buried inside as mentioned above)
  • Your theme's wallpaper is set to /res/drawable/wallpaper.png. Again, remove the required line from AndroidManifest.xml to make sure you dont mess up your users'wallpapers.
  • Your theme's theme chooser preview is set to /res/drawable/preview.png. (NEW - I suggest that you DO NOT remove the backslash from the manifest! (see first post))
  • The icon of your theme's apk file is set to /res/drawable-_dpi/icon.png. You should have an icon for at least one screen-size (preferably hdpi), but its nice to have it for all three.

Variables

This is to help those who don't have dev experience. In android packages, wherever you see an "@" symbol, the part following it will refer to a variable. A variable is basically a name given to refer to a resource for convenient use.
Here are a few types of variables you should know about (note that the explanations may not apply to the theme chooser, but are general):
1. drawable
2. color
3. style
4. string
5. dimen

1. Drawables - Drawbles are, well, drawable. These are resources which android can draw. That includes your theme images, wallpaper, preview, and also stuff like the battery percentage xml's, progress bar xml's etc.

1. Colors - Colors are colors!! Duh! LOL :). Anyway, in /res/values/colors.xml you will find an editable list of colors. Say you use green a lot in your theme. Instead of typing "#ff00ff00" everywhere, you can simply define a color called "green" here, by adding the following line:

Code:
<color name="green">#ff00ff00</color>

Now, you can substitute "@color/green" wherever you want to use green.

3. Styles - these are a little advanced. They allow you to define a set of attributes and apply the entire set to different components.

Here's an example style:

Code:
<style name="mytext" parent="@android:style/TextAppearance.Small">
     <item name="android:textColor">#ffff0000</item>
</style>

Let's break this down -
First of all, we're naming this style "mytext".
We're saying that its parent is "@android:style/TextAppearance.Small".
This means, that it automatically inherits ALL the properties of the android system style, "TextAppearance.Small" which can be found in the styles.xml in framework-res/res/values.

Now, we're adding an item with the android attribute, "textColor". There are many attributes to choose from, you can look in the attrs.xml in framework-res/res/values. (Note that an attribute may not be applicable to every situation)

Next we're giving the text color a value - in this case, red.

Now, this style can be applied anywhere to get red text in the normal system font size for small text.

Here's an example of how to use styles: post 88.

4. Strings - Strings let you make references to text. Maybe you have your theme name everywhere, and its really long. Maybe your theme name is "supercalifragilisticexpialidocious". Well, you dont want to type that every time. So you can add the following to /res/values/strings.xml:
Code:
<string name="myname">supercalifragilisticexpialidocious</string>
Now, wherever you want to use the word "supercalifragilisticexpialidocious", just substitute it with "@string/myname". And it will use whatever you defined for "myname" there.

5. Dimensions - These store values for sizes and so on. For example, its an easy way to remember a custom text size that you need a lot. Add the following to "/res/values/dimens.xml" (this does not exist by default)
Code:
<dimen name="mysize">33.4sp</dimen>
This will allow you to use the font size 33.4 by substituting "@dimen/mysize" wherever you want. For sizes in pixels, use "____.__dip" instead of "sp".

Comments
Comments are useful little dev tools. Comments basically let a developer (but they're useful to themers too) make comments in the code. Basically, the syntax of a comment (more on that in just a bit) tells the compiler to ignore that line(s). A side effect is that you can "comment" parts of your code - which means that you are marking it as a comment - which are not used (or not yet ready to be used), before compiling and releasing, while retaining the old code for future reference.

How to make a comment in xml files:

Simply surround the code you want to comment with "<!-- ......... -->.
The "<!--" part tells the compiler where a comment starts, and "-->" tells it where the comment ends.

More stuff will come here as I think of it.
 
Last edited:

keunhuvac

Senior Member
Nov 2, 2010
786
179
I received many error:
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_timepicker_input_selected.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_timepicker_up_disabled.9.png malformed.
No marked region found along edge.
Found along top edge.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_timepicker_up_disabled.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_timepicker_up_disabled_focused.9.png malformed.
Frame pixels must be either solid or transparent (not intermediate alphas).
Found at pixel #8 along top edge.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_timepicker_up_disabled_focused.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_timepicker_up_normal.9.png malformed.
No marked region found along edge.
Found along top edge.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_timepicker_up_normal.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_timepicker_up_pressed.9.png malformed.
No marked region found along edge.
Found along top edge.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_timepicker_up_pressed.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_timepicker_up_selected.9.png malformed.
No marked region found along edge.
Found along top edge.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_timepicker_up_selected.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_title_bar.9.png malformed.
Must have one-pixel frame that is either transparent or white.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_title_bar.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-land-hdpi\frameworks_res_title_bar.9.png malformed.
Must have one-pixel frame that is either transparent or white.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-land-hdpi\frameworks_res_title_bar.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_title_bar_medium.9.png malformed.
Must have one-pixel frame that is either transparent or white.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_title_bar_medium.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-land-hdpi\frameworks_res_title_bar_medium.9.png malformed.
Must have one-pixel frame that is either transparent or white.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-land-hdpi\frameworks_res_title_bar_medium.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_title_bar_portrait.9.png malformed.
Must have one-pixel frame that is either transparent or white.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_title_bar_portrait.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_title_bar_portrait_cust.9.png malformed.
Must have one-pixel frame that is either transparent or white.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_title_bar_portrait_cust.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_title_bar_shadow.9.png malformed.
Must have one-pixel frame that is either transparent or white.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_title_bar_shadow.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_title_bar_tall.9.png malformed.
Must have one-pixel frame that is either transparent or white.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_title_bar_tall.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-land-hdpi\frameworks_res_title_bar_tall.9.png malformed.
Must have one-pixel frame that is either transparent or white.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-land-hdpi\frameworks_res_title_bar_tall.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_toast_frame.9.png malformed.
No marked region found along edge.
Found along top edge.
ERROR: Failure processing PNG image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_toast_frame.9.png
ERROR: 9-patch image C:\Users\ADMIN\.\templatebread\res\drawable-hdpi\frameworks_res_zoom_plate.9.png malformed.
No marked region found along edge.
Found along top edge.
 

keunhuvac

Senior Member
Nov 2, 2010
786
179
If i replaced some pngs with other my prefer pngs, then resigned, everything was OK. But if i wanted to add new pngs, i got that errors!
 

nhnt11

Senior Member
Sep 16, 2010
1,376
1,116
Bangalore
Strange... you shouldn't be getting nine-patch errors if you simply added some extra pngs. are you SURE you're doing it right?

Did you add the pngs from an already compiled framework or did you decompile them? or did you make them from scratch?
 

nhnt11

Senior Member
Sep 16, 2010
1,376
1,116
Bangalore
Yeah, I heard about that. But I'm using the normal non-t-mobile aapt that came bundled with apktool, and it works fine for me.

Edit: AFAIK, you only need the T-mo aapt the first time you compile, after that decompiling and recompiling with apktool works. Correct me if I'm wrong please.
 
Last edited:
  • Like
Reactions: Dario000

Haraldr Blaatand

Senior Member
Sep 30, 2010
117
10
Gah! I've been led astray. I've been talking with one of the developers to ask for features, and learn more about the engine. I just didn't bother trying to build a theme, because of what I learned about the aapt change.


FYI to all t-mobile engine themers:
There are currently 2 "skinning" implementations on the table before Google. T-mo's current implementation is not the favored one. Currently, the t-mo team is working on a new engine that will hopefully make Google happy (or happier).

Sony-Ericson is developing the other concept, but it is not ready for inclusion into AOSP either. While they have Google's attention, their approach is currently focused on OEM skinning. (i.e. no root = no skinning)
 

nhnt11

Senior Member
Sep 16, 2010
1,376
1,116
Bangalore
Confirming, I just recompiled my theme in windows using apktool. It compiles and applies fine. This guide is valid for all OSes.

By the way, Just wanted to mention that like i said in the first post, this is sort of a temporary workaround for theming. Not in any way the best way to do it, but it's clean (at least, almost) and it works, and is, in my opinion, far more convenient than modifying and releasing and reflashing system files all the time.
 
Last edited:

Haraldr Blaatand

Senior Member
Sep 30, 2010
117
10
<snip> it works, and is, in my opinion, far more convenient than modifying and releasing and reflashing system files all the time.

I completely agree there.

I went looking into the CM source. I think an uber-genius avoided the need to the custom aapt. Sweet!

Now to have some fun...



BTW, I'm looking to put together something so "we" can share parts of themes (i.e. pack up UI changes, icon sets, mods, etc. in separate zips). Then people could mix and match to one's liking. (Based off the concepts from apk manager 4.9, ZipThemer, and my own special sauce.)
 

nhnt11

Senior Member
Sep 16, 2010
1,376
1,116
Bangalore
Cool! Looking forward to what you come up with. I was actually thinking kind of the same thing, like, making a base theme, and then being able to have add on packs to override only a few things in the theme like icons, etc.

Sent from my HTC Wildfire using XDA App
 

Haraldr Blaatand

Senior Member
Sep 30, 2010
117
10
I'm after simple and straightforward.

You unpack the apk you want to theme/skin in directory <package name>, make your changes, then delete all the unchanged files. ZIP up one more more of these package trees, and distribute.

To build a theme/skin of your very own, download the ZIPs you like, combine (resolve 'conflicts'), package, and voila.

The BIG advantage of my approach will be that you won't have to do squat with file names! The program will take care of that for you.
 

nhnt11

Senior Member
Sep 16, 2010
1,376
1,116
Bangalore
Hmmm, that would work, pretty straightforward way to share resources between theme devs.
But what I think would be cool is if we could make packages for users to apply ON TOP of an already applied theme. That would obviously need to be implemented in the theme engine though.

Sent from my HTC Wildfire using XDA App
 

Haraldr Blaatand

Senior Member
Sep 30, 2010
117
10
Hmmm, that would work, pretty straightforward way to share resources between theme devs.
But what I think would be cool is if we could make packages for users to apply ON TOP of an already applied theme. That would obviously need to be implemented in the theme engine though.

http://code.google.com/p/cyanogenmod/issues/detail?id=2812

The reason I got in touch with the t-mo dev was so I could toss in my 2 cents. He liked the idea, but he is concerned that, for a simple user, it could be too complicated and/or confusing. Adding support for multiple APKs to ThemeManager would not be difficult. It is that Theme Chooser needs a user friendly UI that can handle multiple APKs and overlaps/conflicts. (I have in my minds eye what one could/would look like. I'm just not going to be the one writing it.)
 

nhnt11

Senior Member
Sep 16, 2010
1,376
1,116
Bangalore
It can't be that hard, as you said, or even complicated for a user. Two menus - one with full themes, one with addons (maybe a special flag in the package indicating what it is). All addons override everything in the theme with what they have. And you can order applied addons to prioritize which gets the final say. That's it. Not too confusing IMO.

Sent from my HTC Wildfire using XDA App
 

Haraldr Blaatand

Senior Member
Sep 30, 2010
117
10
It can't be that hard, as you said, or even complicated for a user. Two menus - one with full themes, one with addons (maybe a special flag in the package indicating what it is). All addons override everything in the theme with what they have. And you can order applied addons to prioritize which gets the final say. That's it. Not too confusing IMO.


I didn't think 2 listings are needed. Good naming and descriptions would be extremely helpful, but not actually required.

Just 1 multi-select "list" (could be like the current chooser with a check box added). Then an ordering screen only if an overlap is detected.
 

natehoch96

Senior Member
Jul 24, 2010
319
81
I get this error in apktool. There is more to it but I didnt include it because it was so long and just repeats of beginning only to different files.

C:\Program Files\Android\android-sdk-windows\tools\com.fyb3roptik.theme.androidi
an\res\drawable\zzz_btn_application_selector.xml:4: error: Error: No resource fo
und that matches the given name (at 'drawable' with value '@drawable/pressed_app
lication_background_static').
C:\Program Files\Android\android-sdk-windows\tools\com.fyb3roptik.theme.androidi
an\res\drawable\zzz_btn_application_selector.xml:5: error: Error: No resource fo
und that matches the given name (at 'drawable' with value '@drawable/focused_app
lication_background_static').
Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutExce
ption: could not exec command: [aapt, p, -F, C:\DOCUME~1\Nate\LOCALS~1\Temp\APKT
OOL2146181265913808293.tmp, -x, -I, C:\Documents and Settings\Nate\apktool\frame
work\1.apk, -S, C:\Program Files\Android\android-sdk-windows\tools\com.fyb3ropti
k.theme.androidian\res, -M, C:\Program Files\Android\android-sdk-windows\tools\c
om.fyb3roptik.theme.androidian\AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(Unknown Source)
at brut.androlib.Androlib.buildResourcesFull(Unknown Source)
at brut.androlib.Androlib.buildResources(Unknown Source)
at brut.androlib.Androlib.build(Unknown Source)
at brut.androlib.Androlib.build(Unknown Source)
at brut.apktool.Main.cmdBuild(Unknown Source)
at brut.apktool.Main.main(Unknown Source)
Caused by: brut.common.BrutException: could not exec command: [aapt, p, -F, C:\D
OCUME~1\Nate\LOCALS~1\Temp\APKTOOL2146181265913808293.tmp, -x, -I, C:\Documents
and Settings\Nate\apktool\framework\1.apk, -S, C:\Program Files\Android\android-
sdk-windows\tools\com.fyb3roptik.theme.androidian\res, -M, C:\Program Files\Andr
oid\android-sdk-windows\tools\com.fyb3roptik.theme.androidian\AndroidManifest.xm
l]
at brut.util.OS.exec(Unknown Source)
... 7 more

Can anyone help please? Thanks!
 
  • Like
Reactions: karlezero

Top Liked Posts

  • There are no posts matching your filters.
  • 107
    Hi guys,

    This is a guide I put together to make themes for the T-Mobile theme engine based mostly on what i've figured out by digging into haxzamatic's awesome template.

    This does not require you to be on linux or whatever.

    This is mainly a temporary guide till an Eclipse template for the engine is released, or for those who dont want to use eclipse, etc.

    Requirements:
    -You should know how to decompile/recompile/sign apk files.
    -You should know some basic xml editing and theming.
    -basic terminal commands
    -You must install the framework for apktool, navigate to the folder containing framework-res.apk and execute -
    apktool if framework-res.apk


    GUIDE:

    1. Get the compiled Templatebread from here: http://bit.ly/hdEWsf

    2. Decompile it with apktool or whatever you use.

    3. Open the AndroidManifest.xml

    4. Change the names according to your theme. Here's my manifest for my NTSense theme:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <manifest android:hasCode="false" android:versionCode="2" android:versionName="1.1" android:installLocation="internalOnly" package="com.nhnt11.theme.ntsense"
      xmlns:android="http://schemas.android.com/apk/res/android" xmlns:pluto="http://www.w3.org/2001/pluto.html">
        <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="9" />
        <application android:label="@string/theme_name" android:icon="@drawable/icon">
            <activity android:label="@string/theme_name" android:name="com.tmobile.theme.Foo" />
        </application>
        <theme pluto:themeId="NTSense" pluto:styleId="@style/NTSense" pluto:name="@string/theme_name" pluto:preview="\@drawable/preview" pluto:author="@string/author" pluto:copyright="@string/copyright" pluto:wallpaperImage="@drawable/wallpaper" pluto:styleName="@string/style_appearance_name" pluto:ringtoneName="Standard" pluto:ringtoneFileName="media/audio/ringtones/Standard.mp3" pluto:notificationRingtoneName="Subtle" pluto:notificationRingtoneFileName="media/audio/notifications/Subtle.mp3" />
    </manifest>

    Note that the template xml file has "pluto:name="\@string/theme_name" - you need to remove this backslash, its a typo. it should be just "@string/theme_name" Should not be needed using latest version of apktool.

    More detail about stuff in the manifest in 2nd post.

    5. Open /res/values/strings.xml. Edit to match your theme. Here's mine again:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
        <string name="app_name">NTSense Theme</string>
        <string name="theme_name">NTSense</string>
        <string name="style_appearance_name">NTSense</string>
        <string name="author">nhnt11</string>
        <string name="copyright">nhnt11</string>
    </resources>

    6. Same for /res/values/styles.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
        <style name="NTSense" parent="@android:style/Theme" />
    </resources>

    NOTE: the name of your style must be the same as the pluto:styleID in the manifest!!!

    7. Now, if you are making a theme from scratch, go ahead and just edit the images already in the hdpi folder. compile and sign. done. But, read on anyway because i explain how the theme engine works below.

    If you want to port a theme, here's what to do:

    First, go ahead and delete all the drawable folders. Now, copy your THEMED drawable folders into the directory. You now have to add the following to your theme:
    /res/drawable-_dpi/preview.png (prefarably hdpi I guess) (I suggest that you DO NOT remove the backslash in the manifest as different locations of preview.png do not work on different screen sized devices. RETAIN the backslash!! Your theme will not have a preview, but this is a small trade off to get themes working if you're not on linux.)
    /res/drawable/wallpaper.png (this can be in drawable-_dpi for different screen res. too)
    /res/drawable-_dpi/icon.png.
    More detail on those in the second post.

    8. Now go to /res/xml - there are a ton of xml's here. Open redirections.xml.
    Here, there are entries for specifying which XML redirects which app. Add entries like so:

    <package-redirections android:name="<app package name here>"
    android:minSdkVersion="7"
    android:resource="@xml/your_xml_file(without '.xml' at the end)" />

    You have now specified that you want resources in <app> to be redirected based on what's in your_xml_file. Where and what is this your_xml_file and how do you add/modify it? That's what the rest of the xml's in the res/xml folder are.

    The rest of these xmls are the heart of the theme engine. How they work is, when android asks for an image or other resource, they come in and switch that resource for your themed one. So its sort of like a proxy server.

    Each xml contains the redirections for an app.
    For example, redirections to framework-res.apk are in android.xml, and SystemUI is in com_android_systemui.xml
    Delete files corresponding to apps you have not themed (for consistency, you might also want to delete the corresponding entry in redirections.xml. If you don't know how, just leave it). You can also add apps by using the convention, <package name>.xml where dots in the package name are separated by underscores, ie. your_package_name.xml for your.package.name

    Package names of apps can be found in their respective AndroidManifest.xml's after decompiling. See 2nd post for more detail.

    To redirect files, for eg. title_bar_portrait.9.png, just add the item to the systemui xml like so:

    Code:
    <item name="drawable/title_bar_portrait">@drawable/title_bar_portrait</item>

    Note: To make it easy to add hundreds of drawables, I've written a little xml generator - here

    Here, the "name" part tells the theme engine WHAT you're replacing.
    the part inside the item tag ("@drawable/title_..... in this case") tells it WHAT to replace it with.

    In all android packages, the @ sign means that you are referring to a resource in the package. Also, you can refer to a general system-wide resource by using @android:<whatever>

    for example, you can replace the above title_bar_portrait with statusbar_background thats already in the android framework like so:

    Code:
    <item name="drawable/title_bar_portrait">@android:drawable/statusbar_background</item>

    After the @ symbol, you have to specify the type of resource. in this case, "drawable".

    Note that because the @ symbol refers to something INSIDE your package, you SHOULD NOT use it in the item name="<blablabla>" part.

    See Variables in the second post for more detail.

    Back to the xmls.

    Pretty much all images are ALREADY entered in the xml. Just do a find and replace and get rid of all the "frameworks_res_" and "com_android_systemui_"
    for eg, it already has <item name="drawable/title_bar_portrait">@drawable/com_android_systemui_title_bar_portrait</item>, so you need to get rid of the "com_android_systemui_" part.

    Actually the professional/clean way to do it would be to rename all of your files to include "package_to_which_it_belongs_" at the front of the filename for better organisation. if you have the time and patience, do it this way!!!!

    9. Delete the /res/values/public.xml. Its useless and annoying while compiling. It will be regenerated while compiling.

    10. Try to compile the apk. you will probably get errors, because although all the resources are listed in the android.xml (or whatever) you deleted the HDPI folder so many might be missing! it will print what is missing when you compile though, so just go ahead and delete those lines.

    11. you can also re-map styles, colors, drawables, etc.. for eg. battery percentage, add this to android.xml after putting the required battery xml in res/drawable:

    <item name="drawable/stat_sys_battery">@drawable/stat_sys_battery</item>

    also for a color, just add it to /res/values/colors.xml and then in android.xml, add

    <item name="color/[name of color]">@color/[name of your color]</item>

    See variables in the second post for more info.

    12. Sign your compiled apk, and install it! If all goes well you will be able to apply and see the changes after you reboot.

    Hope this helped!
    42
    More detail

    Stuff in the Manifest
    The manifest contains several general properties of your app file.
    The following are a few which are referenced here.
    • To change the ringtone: Just put your desired ringtones/notification sound in /assets/media/audio/<Ringtones/Notifications> To prevent your theme from changing the ringtones, delete the corresponding lines from AndroidManifest.xml. I'm sure you can figure out which lines to delete. Also, you can remove the /assets folder, unless you have some other asset in it. (in which case just delete the ringtone buried inside as mentioned above)
    • Your theme's wallpaper is set to /res/drawable/wallpaper.png. Again, remove the required line from AndroidManifest.xml to make sure you dont mess up your users'wallpapers.
    • Your theme's theme chooser preview is set to /res/drawable/preview.png. (NEW - I suggest that you DO NOT remove the backslash from the manifest! (see first post))
    • The icon of your theme's apk file is set to /res/drawable-_dpi/icon.png. You should have an icon for at least one screen-size (preferably hdpi), but its nice to have it for all three.

    Variables

    This is to help those who don't have dev experience. In android packages, wherever you see an "@" symbol, the part following it will refer to a variable. A variable is basically a name given to refer to a resource for convenient use.
    Here are a few types of variables you should know about (note that the explanations may not apply to the theme chooser, but are general):
    1. drawable
    2. color
    3. style
    4. string
    5. dimen

    1. Drawables - Drawbles are, well, drawable. These are resources which android can draw. That includes your theme images, wallpaper, preview, and also stuff like the battery percentage xml's, progress bar xml's etc.

    1. Colors - Colors are colors!! Duh! LOL :). Anyway, in /res/values/colors.xml you will find an editable list of colors. Say you use green a lot in your theme. Instead of typing "#ff00ff00" everywhere, you can simply define a color called "green" here, by adding the following line:

    Code:
    <color name="green">#ff00ff00</color>

    Now, you can substitute "@color/green" wherever you want to use green.

    3. Styles - these are a little advanced. They allow you to define a set of attributes and apply the entire set to different components.

    Here's an example style:

    Code:
    <style name="mytext" parent="@android:style/TextAppearance.Small">
         <item name="android:textColor">#ffff0000</item>
    </style>

    Let's break this down -
    First of all, we're naming this style "mytext".
    We're saying that its parent is "@android:style/TextAppearance.Small".
    This means, that it automatically inherits ALL the properties of the android system style, "TextAppearance.Small" which can be found in the styles.xml in framework-res/res/values.

    Now, we're adding an item with the android attribute, "textColor". There are many attributes to choose from, you can look in the attrs.xml in framework-res/res/values. (Note that an attribute may not be applicable to every situation)

    Next we're giving the text color a value - in this case, red.

    Now, this style can be applied anywhere to get red text in the normal system font size for small text.

    Here's an example of how to use styles: post 88.

    4. Strings - Strings let you make references to text. Maybe you have your theme name everywhere, and its really long. Maybe your theme name is "supercalifragilisticexpialidocious". Well, you dont want to type that every time. So you can add the following to /res/values/strings.xml:
    Code:
    <string name="myname">supercalifragilisticexpialidocious</string>
    Now, wherever you want to use the word "supercalifragilisticexpialidocious", just substitute it with "@string/myname". And it will use whatever you defined for "myname" there.

    5. Dimensions - These store values for sizes and so on. For example, its an easy way to remember a custom text size that you need a lot. Add the following to "/res/values/dimens.xml" (this does not exist by default)
    Code:
    <dimen name="mysize">33.4sp</dimen>
    This will allow you to use the font size 33.4 by substituting "@dimen/mysize" wherever you want. For sizes in pixels, use "____.__dip" instead of "sp".

    Comments
    Comments are useful little dev tools. Comments basically let a developer (but they're useful to themers too) make comments in the code. Basically, the syntax of a comment (more on that in just a bit) tells the compiler to ignore that line(s). A side effect is that you can "comment" parts of your code - which means that you are marking it as a comment - which are not used (or not yet ready to be used), before compiling and releasing, while retaining the old code for future reference.

    How to make a comment in xml files:

    Simply surround the code you want to comment with "<!-- ......... -->.
    The "<!--" part tells the compiler where a comment starts, and "-->" tells it where the comment ends.

    More stuff will come here as I think of it.
    27
    try using com.android.calendar.CalendarApplication, but keep in mind that CAPS in app name were disallowing to theme them, this is not literally package name that uses CAPS so it can be not a real matter

    I compiled a Windows aapt that does allow the use of uppercase characters a while back. You can download it here:

    http://d-h.st/DBi

    Just replace the current aapt.exe with my compiled version and voila, you can compile with uppercase characters in xml filenames ;)

    Sent with my Samsung Galaxy S2 HD LTE
    14
    I was able to change the keyboard text predictions color as well using the color variable. But changing the text color in any layout xml is tricky and I just can't figure out which variable to use.


    OK, I figured out how to change notification/status bar text colors using styles, I was making a mistake with the attributes all this time.

    Add the following to your styles.xml -

    Code:
        <style name="TextAppearance.StatusBar" parent="@android:style/Theme">
            <item name="android:textSize">14.0sp</item>
            <item name="android:textStyle">normal</item>
            <item name="android:textColor">#ffffffff</item>
        </style>
        <style name="TextAppearance.StatusBar.EventContent" parent="@style/TextAppearance.StatusBar">
            <item name="android:textSize">14.0sp</item>
            <item name="android:textColor">#ff000000</item>
        </style>
        <style name="TextAppearance.StatusBar.EventContent.Title" parent="@style/TextAppearance.StatusBar.EventContent">
            <item name="android:textSize">16.0sp</item>
            <item name="android:textStyle">bold</item>
            <item name="android:textColor">#ff000000</item>
        </style>

    Then you can edit the textColor values to your liking.

    The first one is the status bar itself, second one is notification descriptions, third one is notification titles.

    Then add the following to android.xml:

    Code:
        <item name="style/TextAppearance.StatusBar">@style/TextAppearance.StatusBar</item>
        <item name="style/TextAppearance.StatusBar.EventContent">@style/TextAppearance.StatusBar.EventContent</item>
        <item name="style/TextAppearance.StatusBar.EventContent.Title">@style/TextAppearance.StatusBar.EventContent.Title</item>

    and you should be all set.
    10
    I'm not a themer and I have no right to post in this thread but I just want to thank all of you for your hard work.

    I can only imagine the frustrations (and also the pleasures) of working with a new theme engine.

    Though it may not seem so most of the time we do appreciate the work you all do. Thank you.