FORUMS
Remove All Ads from XDA

[Guide] Porting CM10/.1 themes to XTheme

2,845 posts
Thanks Meter: 3,413
 
By dully79, Senior Member on 22nd June 2013, 07:48 PM
Post Reply Email Thread



Quote:


Want to port CM11 themes? Go here:
CMX- Port CM11 themes in one click.



I will update the information whenever time allows.
Please feel free to contribute or discuss.

In this first post I'm going to try and explain what XTheme and the theme apk's are and how they work. Why? Because you'll have a better understanding of the workings, this will hopefully enable better self sufficiency.
In the second post i'll describe how to set up an environment to port themes and the process of how to port CM 10 themes to XTheme.

I'm going to assume you know nothing about anything to try and cover everything. I myself don't know everything, but what i do know I will try to share.
I'm going to try and keep this as basic as possible so anyone with no knowledge can follow along.

There are already some brilliant guides out there that will help if you read them, so i will link to them instead of regurgitating info from them.


Knowledge is power!





Quote:

You can find the XTheme thread here containing install instructions, compatible devices and more.

Basically it performs in a similar manner to the theme chooser engine for CM based ROM's... but for ROM bases other than just CM. Until now-18/04/13, the theme chooser engine was restricted to CM based ROM's. XTheme makes it possible to theme stock ROM's.





Quote:

The theme chooser engine allows you to choose a theme and apply it whilst your device is turned on without overwriting your stock images (requires a reboot to see full changes).
This is opposed to a different method of theming, zip flashing or Metamorphing. These methods overwrites either whole apk's or just the relevant images depending on the method you use.

The beauty of the theme chooser is if you decide to change theme or remove it, there is no fallout from the theme that was applied, so all the images are returned back to stock. This isn't really possible through Metamorph or zip flashing unless you use VRTheme or the Universal theme zip which creates a backup. Even so i've found this doesn't work 100%. And restoring your original images through Metamorph and zip flashing can be a painful and tiresome task.

The theme chooser works by redirecting images from inside a theme apk, provided that the relevant images and redirection are present.
If the images or redirections are not present for battery icons for example, then the battery icons will not be themed.
A simple and clean method to theme.





Quote:

Now you know how the engine works we'll talk about the theme apk.

Within the apk is a folder named "res", this contains all the images and xml files that is used within the theme.

Inside the "res" directory are a number folders. Depending on the theme you are porting/creating, some folders will not be used. The folders are mainly self explanatory and these include:

  • anim ~Controls animations, e.g. screen fades, rotations etc.
  • color ~xmls control colors used in the theme.
  • drawable ~Contains xmls that control drawables.
  • drawable-*dpi ~Contains theme images and possibly xml's.
  • layout ~Contains xml's that controls the layout values of elements in the theme.
  • mipmap-*dpi ~Houses "ic_launcher" icons.
  • values ~Contains xmls including strings, styles, drawables which we will discuss later.
  • xml ~Contains the redirection xmls. This is where the magic happens.
You can find more in depth details here:
http://developer.android.com/guide/t...resources.html

If you are unsure where to house elements when adding to your theme, simply look inside the original apk.
For example if i want to theme the icon of Gmail, i would extract the Gmail apk and search for the location of the launcher icon. This is located in mipmap-*dpi, so i would add it to the mipmap-*dpi directory in my theme with the relevant redirections.





Quote:

The redirections xml diverts the original package resources to the theme resources.

Here's a little workflow for changing the Gmail launcher icon.

This is achieved by adding the relevant syntax to the redirection.xml like so:

Code:
<?xml version="1.0" encoding="utf-8"?>
<theme-redirections
  xmlns:android="http://schemas.android.com/apk/res/android" xmlns:pluto="http://www.w3.org/2001/pluto.html">
    <package-redirections android:name="com.google.android.gm" android:resource="@xml/com_google_android_gm" android:minSdkVersion="16" />    
</theme-redirections>
I have highlighted the package redirection above to break it down.
  • Red= Package redirection syntax.
  • Blue= Original package name. Found in the "AndroidManifest"
  • Green= Redirection package name. you can call this anything but i strongly suggest you stick with the original and change "." to "_" as above.
This has told the engine to divert "com.google.android.gm" (Gmail.apk) to use the resources defined in "com_google_android_gm".xml in the theme xml folder.


Now we need to create an xml inside the xml folder named "com_google_android_gm".
Within this xml we add the correct syntax for the resources to be used:


Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="mipmap/ic_launcher_mail">@mipmap/com_google_android_gm_ic_launcher_mail</item>
</resources>
  • Red= Resource redirection syntax.
  • Blue= Original directory and resource
  • Green= Redirection directory and resource
This is telling the engine to display "com_google_android_gm_ic_launcher_mail".png located in the mipmap-*dpi directory within the theme apk.
Now we add the "com_google_android_gm_ic_launcher_mail".png into the mipmap-*dpi directory to complete the redirection process.

You can see why i suggest to keep the redirection package name the same. it keeps a consistency that's easy to follow.

The Following 22 Users Say Thank You to dully79 For This Useful Post: [ View ] Gift dully79 Ad-Free
 
 
22nd June 2013, 07:50 PM |#2  
dully79's Avatar
OP Senior Member
res/drawable
Thanks Meter: 3,413
 
Donate to Me
More


Time Taken:
Setting up 10 minutes
Porting 10 minutes

Difficulty:





Quote:


Post any other threads here and i will add them to the above list.






Quote:

Now we know the basics of how the engine and redirections work we can start creating/porting some themes.

We need to gather some tools for the process:

  • Java Link
  • ApkManager/Multitool Link
  • CM10 theme to port Take your pick.
  • SampleTheme.apk Link at bottom of the page.
  • Notepad++ Link
  • 7zip Link
  • Weapon of choice- i chose a beverage with alcoholic content. Link


Java.
Download, install and add bin path to your environment variables.

Windows 7.
  1. Select Computer from the Start menu
  2. Choose System Properties from the context menu
  3. Click Advanced system settings > Advanced tab
  4. Click on Environment Variables, under System Variables, click "new".
  5. In the "variable name" field enter JAVA_HOME
  6. In the "variable value" field enter the "bin" location from the java folder.
    My location is "C:\Program Files\Java\jre7\bin"
  7. Reboot.
  8. Open a cmd window and type java. If you added the path correctly you will receive an help menu. If not try to add the path again.

For more help see below or use Google.
http://www.java.com/en/download/help/path.xml

ApkManager/Multitool.

Extract and read the "README"
You can also follow instructions here:
http://forum.xda-developers.com/show....php?t=1310151






Alternative method. Thanks pier10.

Quote:

Firstly let me say. If you do not have a redirections.xml in the CM theme xml folder you will need to create one.
See this post for details.


Once we have our environment setup we can get started.

XTheme creator ruqqq has described how to port CM themes in his thread but ill try to expand it.
http://forum.xda-developers.com/show...25&postcount=2

1 .Run the setup.bat and select option 3 to create directories.
2. Place your CM10 and SampleTheme.apk's in "place-apk-here-for-modding". Sample theme link. CM10 theme link.
3. Run script.bat and choose option 24 to set project.
4. Select your CM 10 theme apk and choose option 9 to decompile.
5. Repeat the process with the sample theme
6. Your now presented with 2 output folders in "projects" with the same name as the apk.
7. Enter "projects/SampleTheme.apk" and delete the "res" folder.
8. Goto the CM10 theme in projects and copy the "res" folder across into the SampleTheme.apk folder.
9. Open both "AndroidManifest.xml" with notepad++
10. In the SampleTheme AndroidManifest change

Code:
package="sg.ruqqq.theme.SampleTheme"
with the package name from the CM10 AndroidManifest. Add an X or Xtheme to the end of the package name to differentiate it from the original.

Code:
package="sg.ruqqq.theme.SampleTheme"
Becomes
Code:
package="com.vicino.theme.honeycombl.xtheme"
Or
Code:
package="com.vicino.theme.honeycomb.x"


We can also reflect the change in res/values/strings.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">HoneycombTheme</string>
    <string name="theme_name">HoneycombTheme</string>
    <string name="style_appearance_name">HoneycombTheme</string>
    <string name="author">vicino</string>
    <string name="copyright">vicino</string>
</resources>
Becomes
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">HoneycombTheme X</string>
    <string name="theme_name">HoneycombTheme X</string>
    <string name="style_appearance_name">HoneycombTheme</string>
    <string name="author">vicino</string>
    <string name="copyright">vicino</string>
</resources>

11. Check If the theme contains a redirections.xml (res/xml/redirections.xml), if it doesn't you must create one. See the post above headed "redirections.xml" orsee this post for details on editing. You should have a line of code for each package xml file in the xml folder.
This applies to every ROM. If the theme does not contain a redirections.xml it will not redirect resources.
Delete any unused lines of code.

If you are using a "stock" ROM, example TouchWiz(Samsung), Sense(HTC), Semc(Sony), open up "android.xml" in res/xml and add redirections for your OEM images.
For Sony based ROM's you can find my redirections below. For other ROM's you will have to create them or find them
http://forum.xda-developers.com/show...69&postcount=5

TIP:
My redirections syntax refer to framework images as "framework_res", if the theme you are porting uses "frameworks_res" for example follow this:
  • Open up the android xml with NotePad ++.
  • Click the search tab at the top and select replace.
  • In the field "Find what" enter @drawable/framework_res.
  • In the field "Replace with" enter @drawable/frameworks_res.
  • Click replace all, save and close.

12. Compile the project by selecting 12. When prompted select option 2.
13. You will recieve a "unsignedSampleTheme.apk" in the "place-apk-here-for-modding" folder. Select option 13 to sign the apk.
14. You now have a "signedSampleTheme.apk" in "place-apk-here-for-modding", you can rename this to the CM10 theme name.
15. Place the apk on your device, install, apply and reboot.





Quote:

@ruqqq for the XTheme engine.
CM team for the Theme chooser engine.
All the authors of the guides and posts.
@MrDSL for helping me out with Theme Chooser.
@mcsqwizzys98, @Rycon33, @josephnero, @peetr_ and many others over on the Xperia T forum (sorry if i forgot anyone).
@Brut.all, @iBotPeaches, @JesusFreke, @Daneshm90, and @raziel23x for apktool, smali/ baksmali, apkManager/multiTool,
@rovo89 and @Tungstwenty for making this possible with Xposed framework.
@vicino for using Honeycomb theme as an example.
Everyone else who they credited.






Q.Why does the ported theme not look 100% as the original theme?
A.

Quote:
Originally Posted by ruqqq

There are 2 reason for this. Firstly, as stated in the previous post, styles.xml is not working for XThemeEngine. Hence, the ported themes would not work 100%. For better success, port a theme which is closer to Holo styles (dark background, bright text). Second reason, which is the most common reason, is that the theme is made for CM10. CM10 is very close to AOSP while your device which is running stock rom only retain some parts of AOSP. The theme need to be properly ported (analyze your stock rom frameworks and redirect the proper files in your ported theme etc.) to fully support your device.

Q. My theme is not recognized.
A. Make sure you have permissions in the android.manifest.xml.
Code:
<uses-permission android:name="sg.ruqqq.XThemeEngine.permission.SYSTEM_THEME" />
Q. Nothing is themed!?.
A. You must have a "redirections.xml" and package.xml's in the "res/xml" folder


If you plan on releasing any ported themes then ask the author of the theme for permission and give credits and link back to their thread. Not only is this good community manners, it's XDA rules.

XDA rule 12:


Quote:

12. Using the work of others.

If you are developing something that is based on the work of another Member, you MUST first seek their permission, and you must give credit to the member whose work you used. If a dispute occurs about who developed / created a piece of work, first try to settle the matter by private message and NOT in open forum. If this fails then you may contact a moderator with clear evidence that the work was created by you.

Convincing evidence will result in copied work being removed. If there is no clear evidence you created the work then in the spirit of sharing all work will remain posted on the forums.

As an addition, developers have the right to hold exclusivity over their work for as long as it is deemed necessary by the dev or freely share it. However, if the work is claimed as exclusive, it must remain as such. No selective sharing will be allowed (ie allowing certain people to use it and not others). Should the dev decide to start sharing the work with others, the work automatically becomes fair game for all to use.

In regards to permissions, same rules remain for this but if permission was already given, unless there is a very valid reason, it cannot be revoked (same applies to major updates on the work). Under that same premise, permissions cannot be denied unless the work is exclusive or under severe circumstances.

In plain English: If you want to keep your work exclusive, go for it. However, if you are going to share your work, do it fairly.

These rules apply to all software posted on XDA (including but not limited to ROMs, RUUs, apps, games, kernels, themes, icons, etc) unless that software comes with a license that waives these rules.

The Following 23 Users Say Thank You to dully79 For This Useful Post: [ View ] Gift dully79 Ad-Free
22nd June 2013, 07:52 PM |#3  
dully79's Avatar
OP Senior Member
res/drawable
Thanks Meter: 3,413
 
Donate to Me
More


[YOUTUBE]yyGGKwH7pmU[/YOUTUBE]

Thanks to @vicino, as i used his "Honeycomb Lite Theme" as an example.


[YOUTUBE]EmyjKzAcWKs[/YOUTUBE]
The Following 8 Users Say Thank You to dully79 For This Useful Post: [ View ] Gift dully79 Ad-Free
22nd June 2013, 08:07 PM |#4  
cartmenicus's Avatar
Senior Member
Flag British columbia
Thanks Meter: 1,976
 
Donate to Me
More
Awesome guide it will help many people!!!

Sent from my LT30p using Tapatalk 4 Beta
The Following User Says Thank You to cartmenicus For This Useful Post: [ View ] Gift cartmenicus Ad-Free
22nd June 2013, 09:53 PM |#5  
josephnero's Avatar
Senior Member
Flag Sanford NC
Thanks Meter: 712
 
More
you never fail to amaze mate.thank you
The Following User Says Thank You to josephnero For This Useful Post: [ View ] Gift josephnero Ad-Free
25th June 2013, 01:32 PM |#6  
Rycon33's Avatar
Senior Member
Thanks Meter: 2,132
 
Donate to Me
More
very nice guide dully

it's very comprehensible

i'd like to add some redirections for Xperia(coz Sony always do some funny funny things )

at android.xml:
- for screenshot dialog image
Code:
    <item name="drawable/semc_ic_dialog_screenshot">@drawable/frameworks_res_ic_lock_screenshot</item>
at com_android_systemui.xml:
- for data H+
Code:
    <item name="drawable/stat_sys_data_connected_h_plus">@drawable/com_android_systemui_stat_sys_data_connected_hp</item>
    <item name="drawable/stat_sys_data_fully_connected_h_plus">@drawable/com_android_systemui_stat_sys_data_fully_connected_hp</item>
The Following 2 Users Say Thank You to Rycon33 For This Useful Post: [ View ] Gift Rycon33 Ad-Free
25th June 2013, 01:37 PM |#7  
cartmenicus's Avatar
Senior Member
Flag British columbia
Thanks Meter: 1,976
 
Donate to Me
More
Rycon and his hplus icon

Sent from my LT30p using Tapatalk 4 Beta
The Following 2 Users Say Thank You to cartmenicus For This Useful Post: [ View ] Gift cartmenicus Ad-Free
25th June 2013, 01:50 PM |#8  
Rycon33's Avatar
Senior Member
Thanks Meter: 2,132
 
Donate to Me
More
Quote:
Originally Posted by mcsqwizzys98

Rycon and his hplus icon

Sent from my LT30p using Tapatalk 4 Beta

hahaha, true mate, as you know i'm mostly on mobile

i'll add some more later, those i can remember

EDIT: Another option for ApkManager is TickleMyAndroid tool for de/recompiling, signing apks.

EDIT2: If you want to have a nice Sony accent theme that can blend well to any ported themes, try to mod an existing Sony accent theme. I personally used white accent(ccffffff) so the default toggles, panel clock, etc won't look out of place when using any ported XTheme theme.
The Following 2 Users Say Thank You to Rycon33 For This Useful Post: [ View ] Gift Rycon33 Ad-Free
25th June 2013, 02:24 PM |#9  
dully79's Avatar
OP Senior Member
res/drawable
Thanks Meter: 3,413
 
Donate to Me
More
Cheers fellas. I've updated the guide to use the SampleTheme method as described in the XTheme thread. It seems to be less temperamental.
The Following 3 Users Say Thank You to dully79 For This Useful Post: [ View ] Gift dully79 Ad-Free
27th June 2013, 12:15 PM |#10  
Drockk_Xm's Avatar
Senior Member
Dhaka
Thanks Meter: 310
 
More
i port a theme flowing your guide
Bt when i click apply its shows failed please help
i m using xtheme engine beta5
only i skip step 10 is it mandatory?
27th June 2013, 12:22 PM |#11  
dully79's Avatar
OP Senior Member
res/drawable
Thanks Meter: 3,413
 
Donate to Me
More
Quote:
Originally Posted by Drockk_Xm

i port a theme flowing your guide
Bt when i click apply its shows failed please help
i m using xtheme engine beta5
only i skip step 10 is it mandatory?

Only if your using an OEM ROM and want the theme to work fully on your device.

Can you post your AndroidManifest.xml or post the contents and wrap code tags around it, thanks.
Post Reply Subscribe to Thread

Tags
how to port cm10, xposed, xtheme engine

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes