FORUMS

 View Poll Results: Would you like to see me continue developing this tool?

Yes- I find it useful.
 
12 Vote(s)
100.00%
No- Don't waste your time.
 
0 Vote(s)
0%

[Tool][Windows]CMX: Port CM11 Themes to X/HKTheme engine in one click

2,845 posts
Thanks Meter: 3,415
 
By dully79, Senior Member on 29th August 2014, 10:27 PM
Thread Closed Email Thread
Logo



Thread Index:
Quote:

  • Post 1 - Information. PLEASE READ!
  • Post 2 - Usage and porting info.
  • Post 3 - Features status. To request features use the tab at the top of the thread.
  • Post 4 - Ported themes and links.


When posting I only ask of 3 simple requirements.
1) Please search or read first. If the question has been asked/answered i will not reply.
2) Post any log extracts and pictures within the "hide" tags to keep the thread clutter free.
3) Do not quote posts in full. If you have to, use the hide tags
Hide



What is CMX?

Quote:

This is a batch script that runs on Windows to port CM11 themes to work with XTheme/HKTheme engine.

Unless porting png's solely, this is designed to take most of the leg work out of porting themes across, so expect some errors when working with the xml's. It is difficult to encompass all the different CM11 themes and quirks they bring with them without downloading and testing each and every theme available.

Ive tried to make the script as unobtrusive and self sufficient as possible with minimal user input in automatic mode.
If you include xml's, some manual labour may be necessary depending on the theme so expect to get your hands dirty. From the themes I've tested with xml's included, 50% have ported straight through and 50% have failed and required some extra attention.

When the script runs through the asset configuring phase (png's/xml's) it will open up a window for each package folder one at a time. One folder must finish processing before the other begins.


Requirements:

  • Java development kit (jdk) -Link. Installed and in your environment path -Link
  • CM11 theme to port Take your pick.
  • The ability to solve apktool log errors. I will help, but I will not spoonfeed!!.

Time Taken:
  • Setting up 10 minutes (inc. Java install)
  • Porting (depending on theme)
    • png's only- 2 minutes.
      Difficulty- 2/10. Common error- 9 patch faults.
    • inc. xml's- 5 minutes.
      Difficulty- Dependant on theme. Common error- xml faults.


Basically my script will work as follows when ran and "Automatic" is selected:
  1. Set up required folders.
  2. Automatically detect the apk in "CMThemeIn" folder and set it as the project or prompt the user to insert an apk.
  3. Decompile set theme.
  4. Create all the redirection.xml's required.
  5. Cycle through the
    Code:
    assetsoverlays*InsertPackageNameHere*resdrawable
    folders, and move them to the corresponding folder in the XTheme folder.
  6. Gather xmls from res "drawable" and values" and insert appropriate redirections for that package name.
  7. Ask the user to input a package name in AndroidManifest.xml.
  8. Ask the user to input a theme, app, author and original themer name in strings.xml.
  9. Compile, sign, zipalign and then place the output in "XThemeFinished" folder" ready for installing.

Currently the ports are best served with AOSP but there is an option to add redirections for TouchWiz and Semc (JellyBean 4.2 framework-res.apk).
The script offers you the option to include xml's or not.
Depending on the android version you are using certain xml's may not work or cause conflicts resulting in SOD's, force closes and bootloops.
To recover from a bootloop read the FAQ below.
Currently I wont be porting boot animations and fonts. Although I may add an option to port boot animations etc to a flashable zip.

Finally, the ported themes will NEVER look like the CM counterpart due to the Xposed limitation of themeing "styles.xml". This is not a restriction of the CMX tool, theme .apk or the theme engine

To find out more about the structure and for a better understanding go here and read more:
http://forum.xda-developers.com/showthread.php?t=2334637



FAQ

Quote:

Q). It says Java not found, how do I add the Java path?
A). Check "What is CMX?" for a guide.

Q). The script fails in auto, what's wrong?
A). Read the log.txt and assets,txt in tools and look for any errors, if you cannot understand them then post your log either as a .txt file or as a snippet wrapped in hide tags as shown above.

Q). Whats the difference between CM10 and CM11 themes?
A). All the drawable resources for CM11 themes now reside in "assetsoverlays" and not "resdrawables" as they previously did. Also they no longer use redirection xml's.
Due to this change, XTheme and HKTheme engines do not support CM11 themes...until now.

Q). Why doesn't the theme look like the CM11 counterpart?
A). This is due to styles.xml not being supported and xml restrictions if not included.

Q). I've got a bootloop, how can I fix it?
A). Go and follow the instructions here: http://tinyurl.com/nm4eups

Q). Why does it take longer when porting than it used to?
A). I have muted the opening of seperate windows. Each folder in the CM11Themeassets directory is processed one at a time to prevent errors. This must be done correctly or this will have detrimental effects to the xml's being created and
cause compiling errors.

Q). What are the duties of the folders?
A).

  • "tools": Contains all the resources needed to help porting.
  • "CMThemeIn": This is the folder you place your desired CM theme to be ported.
  • "CMThemeOut": When apktool decompiles the apk from "CMThemeIn", this is the source/reference for porting.
  • "XTheme": Contains the resources from "CMThemeOut" that have been configured and modified to be X/HKTheme compatible.
  • "XThemeFinished: This folder is used to store the newly created, X/HKTheme compatible apk.

Q). How do I remove "ON" and "OFF" from the switches?
A). See this post: Link.

Q). I get "invalid resource directory name" in the error log, how do I fix it?
A). Something has broken the script process and caused the creation of unnecessary folders. Goto "XThemeXThemeBase.apkres" and remove the folders detailed in the log.
Example: "XThemeXThemeBase.apkresdrawable-SomeRandomName" delete "SomeRandomName" folder



Credits:

Quote:

  • @brut.all, @iBotPeaches and @JesusFreke for apktool and smali/baksmali respectively.
  • @nhnt11 for his xml generator.jar.
  • @existz and @xIC-MACIx for letting me test on their themes.
  • @rovo89, @ruqqq and @hdbk1986 for Xposed, Xtheme and HKTheme respectively.
  • @pierx for TouchWiz 4.2 framework-res redirections.
  • All the beta-testers.



XDA:DevDB Information
CMX, Tool/Utility for all devices (see above for details)

Contributors
dully79

Version Information
Status: Beta
Current Beta Version: v3
Beta Release Date: 2014-09-15

Created 2014-08-29
Last Updated 2014-09-27
The Following 15 Users Say Thank You to dully79 For This Useful Post: [ View ] Gift dully79 Ad-Free
29th August 2014, 10:27 PM |#2  
dully79's Avatar
OP Senior Member
res/drawable
Thanks Meter: 3,415
 
Donate to Me
More
Sign Using the script and porting.
Instuctions:
  1. Download the zip.
    • Downloads can be found in the "Download" tab above.
    • Or if your browsing via mobile you can use this mirror: CMX beta v3
  2. Unzip the "CMX" folder to a directory containing no spaces or rename the folder.
    Any spaces within the containing folder will result in the jar files not being able to run.
    • BAD= C:/Users/My name/desktop/CMX beta T1000
    • GOOD= C:/Users/My_name/desktop/CMX_beta_T1000
  3. I've also included Jarsigner.exe in the download. Move it to your "Java\bin" folder if you do not have it installed, otherwise you can delete it.
  4. Start ".RunMe.bat".
  5. Your now presented with 2 main options with regards to porting.
    1. Automatic.
    2. Manual.
I've covered automatic above in "What is CMX" so i'll explain manual.
Basically all the options in the manual menu (other than options 0 and 1) are what the automatic mode cycles through in the same order. This can be useful if you receive any errors and want to carry on from where automatic failed.
The options are self explanatory but I'll give basic details:

Manual
  1. Choose apk. Can be used to override the automatic built in selection. Useful if you have a number of apks in the "CMThemeIn" folder, although it is recommended to just keep one apk to prevent possible bugs.
  2. Decompile apk. Decompiles the chosen apk for assets extraction.
  3. Create main redirections.xml. Creates the main redirection xml containing all the package redirections.THIS MUST RUN BEFORE 4+5.
  4. Configure CM11 xml's. Configures and ports CM11 xml's to work with X/HKTheme.
  5. Configure CM11 png's.Create package (app) redirections.xml's and copies all the images to the appropriate folders in XThemeBase.apk inc. theme icon and wallpaper.
  6. Set package and strings.xml name. Asks the user to declare the new package name in AndroidManifest.xml. Ideally use the same as the theme but with an "X" prefixing. e.g "com.mac.theme.gem" becomes "Xcom.mac.theme.gem". Also asks the user to to set the new app, theme, porter and original author name.
  7. Compile. Compiles XThemeBase.apk into the ported theme apk.
  8. Sign and zipalign. Signs and zipaligns the newly compiled apk ready for installation. The key used is market compatible generated by me.
  9. Return to main menu. Returns to the initial screen.

When porting a theme try to name it so it is easy to differentiate from the original.
Example.
Original package and app name:
  • com.mac.theme.gem
  • Gem Flat
Ported with png's only:
  • X.com.mac.theme.gem
  • X Gem Flat
Ported with xml's:
  • X.com.mac.theme.gem.inc
  • X Gem Flat inc



How to port the custom launcher icons?

To use the new custom icon porter option, you will find it under option 2 (Manual) and 9. Two pre-requisites must be met:
  1. You must have decompiled the apk in CMThemeIn prior to choosing this option.
  2. Set the AndroidManifest name or strings. If you have not, or closed the tool since porting the main theme, you can define them using option 2 (Manual) and 6.

If the theme you are porting doesnt support a certain density, you can use this jar tool to create them:
https://github.com/redwarp/9-Patch-Resizer/releases
ONLY CREATE DENSITIES LOWER THAN THE INPUT!.


Porting themes? Then read this:
Quote:

If you are going to port a theme and share it, you MUST obtain permission from it's creator/author.
Not only is this good community manners it is XDA forum rules.:highfive:

XDA Rules

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, you may then contact a Moderator and provide clear evidence that the work was created by you.

The Following 5 Users Say Thank You to dully79 For This Useful Post: [ View ] Gift dully79 Ad-Free
29th August 2014, 10:27 PM |#3  
dully79's Avatar
OP Senior Member
res/drawable
Thanks Meter: 3,415
 
Donate to Me
More
Sign Feature status and changelog
Feature status:

coming soon
  • Auto porting of xml's- xml's need the correct redirection prefix adding to the resource direction inside the file. This can be done manually if required (NOT RECOMMENDED). Complete.
  • Redirections for OEM ROM's e.g. TouchWiz, Semc etc. Complete.
  • Porting of app themed icons- This is something i will add in to port to a separate apk. Complete.

Maybe
  • Porting of boot animations, fonts, ringtones etc. Possibly to a flashable zip.

broken
  • styles.xml- Broken inside Xposed.



Changelog:

29/08/14
First beta release.

31/08/14 beta v1.1
  • Lots of code cleaning and bug fixes inc. message suppressing.
  • The script now searches for installed framework-res.apk, if none is found it will install the provided apk automatically.
  • If you input a CMTheme.apk that isnt a true CM11 Theme (doesn't use assets\overlays) you will receive a warning in the console and the decompiled folder will be removed.
  • "tools" folder contains:
    • framework-res.apk from CM11 for Mako.
    • aapt from android sdk build tools 4.4#
    • My updated version of the XTheme sample.apk A.K.A XThemeBase.apk

15/09/14 beta v3
  • Added xml porting support.
  • Updated XThemeBase.apk to include drawable and xml folder.
  • Lot's of code cleaning and bug fixes.
  • Removed opening of multiple windows. This results in a longer but cleaner process.
  • Added Jarsigner.exe to download.
  • Some other stuff.

23/09/14 beta v4
  • Removed jarsigner.
  • Removed framework-res.apk to reduce zip size (added to CMX folder in post #4 if required).
  • Added framework-res.apk redirections (4.2 Jelly Bean) for Sony and Samsung (thanks @pierx) devices.
  • Added the ability to port custom icons and wallpaper.If supported by the ported theme to a standalone Apex/Nova theme.apk. Manual option 9.
  • Fixed bug where invalid resource directories where created in XTheme.
  • Cleaned and re-wrote some code inc. an extra log for xml and png porting. This can be found in tools\ called assets.txt

24/09/14 beta v4.1
  • Added custom AndroidManifest and strings.xml to icon.apk porter. Uses values defined for main theme port. Can be redefined by selecting option 2 (Manual) and 6.
The Following 3 Users Say Thank You to dully79 For This Useful Post: [ View ] Gift dully79 Ad-Free
29th August 2014, 10:34 PM |#4  
dully79's Avatar
OP Senior Member
res/drawable
Thanks Meter: 3,415
 
Donate to Me
More
Lightbulb Ported CM11 Themes
The themes are split into 2 categories:
  1. Drawables port.
  2. Full port.
The reason for being split is because devices on older android versions (<4.3) might bootloop if using a fully ported 4.4 theme with a conflicting xml.
To cancel any bootloops you can disable Xposed via the flashable zip provided in rovo's Xposed thread, or by using adb shell delete in recovery. See faq above.

Layout:
[Supoorted densities] Name of theme- Created by author
Original thread- Link

Density key:
H=hdpi. X=xhdpi. XX=xxhdpi




Drawables only themes:
Full port themes:
PLEASE NOTE: These ports are intended as a preview to what the tool can do. I will not be maintaining them or fixing bugs.

Downloads:

Click the Icon or the link.


Everything CMX related inside.

http://tinyurl.com/lv7cpqx



If you want to post ported themes in this thread then feel free and i will link to your post from here.
Please obtain the authors permission to port and distribute.

Many thanks to the authors of the themes for allowing me to port them.
If you download their theme you should go to the link above and thank them.
The Following 9 Users Say Thank You to dully79 For This Useful Post: [ View ] Gift dully79 Ad-Free
29th August 2014, 11:21 PM |#5  
Senior Member
Thanks Meter: 207
 
More
First!!!!!!!.. Is it possible to make this an app for android? That would be great
30th August 2014, 10:23 AM |#6  
dully79's Avatar
OP Senior Member
res/drawable
Thanks Meter: 3,415
 
Donate to Me
More
Quote:
Originally Posted by Juansegovia20

First!!!!!!!.. Is it possible to make this an app for android? That would be great

You win a prize for premature jubilation.

It probably is possible. If the script was converted from batch to .sh to run on your device, you could package it into an apk... But I won't be doing it. Creating this took me long enough. Plus I don't have the skills.

Ideally there would be an update to X/HKTheme or a new module developed. In the mean time this is the next best option.
The Following User Says Thank You to dully79 For This Useful Post: [ View ] Gift dully79 Ad-Free
30th August 2014, 02:10 PM |#7  
Senior Member
Thanks Meter: 207
 
More
Quote:
Originally Posted by dully79

You win a prize for premature jubilation.

It probably is possible. If the script was converted from batch to .sh to run on your device, you could package it into an apk... But I won't be doing it. Creating this took me long enough. Plus I don't have the skills.

Ideally there would be an update to X/HKTheme or a new module developed. In the mean time this is the next best option.

I was just asking about the app because some of us don't have the knowledge do do all of this... but thanks, i hope someone here will accept requests to port the themes
30th August 2014, 02:15 PM |#8  
dully79's Avatar
OP Senior Member
res/drawable
Thanks Meter: 3,415
 
Donate to Me
More
Quote:
Originally Posted by Juansegovia20

I was just asking about the app because some of us don't have the knowledge do do all of this... but thanks, i hope sometime here will accept requests to port the themes

There is no knowledge required.
All you need is:
  • Java installed on your Windows system.
  • A CM11 theme of your choice placed in "CMThemeIn"
  • Run the script, select option 1 (Automatic) and follow the prompts (4 of).
  • Install the resulting signed file in "XThemeFinished".
It takes 2 minutes literally. Everything is automated to make it as noob friendly as possible.

If you have Windows give it a try and you'll be surprised how easy it is.
30th August 2014, 02:18 PM |#9  
Senior Member
Thanks Meter: 207
 
More
Quote:
Originally Posted by dully79

There is no knowledge required.
All you need is:

  • Java installed on your Windows system.
  • A CM11 theme of your choice placed in "CMThemeIn"
  • Run the script, select option 1 (Automatic) and follow the prompts (4 of).
  • Install the resulting signed file in "XThemeFinished".
It takes 2 minutes literally. Everything is automated to make it as noob friendly as possible.

If you have Windows give it a try and you'll be surprised how easy it is.

Awesome, thanks, i tried yesterday but i was confused, with this new instruction things look way easier,lol, I'll report back if i successfully managed to port a theme, thank you Sir!!
30th August 2014, 02:24 PM |#10  
eurochild's Avatar
Senior Member
Flag Athens
Thanks Meter: 965
 
Donate to Me
More
Quote:
Originally Posted by dully79

and follow the prompts (4 of)

can u please explain this ?

theme is loaded and recognized, then i select 1 for automatic, then ?
i cannot seem to get anything as a result in the XTheme folder
30th August 2014, 02:32 PM |#11  
dully79's Avatar
OP Senior Member
res/drawable
Thanks Meter: 3,415
 
Donate to Me
More
Quote:
Originally Posted by eurochild

can u please explain this ?

theme is loaded and recognized, then i select 1 for automatic, then ?
i cannot seem to get anything as a result in the XTheme folder

There are only 4 prompts contained in the automatic option
  1. Set AndroidManifest.xml "package name".
  2. Set strings.xml "app name".
  3. Set strings.xml "theme name".
  4. Set strings.xml "copyright name". This is the original author.

What does the log say?
Thread Closed Subscribe to Thread

Tags
hktheme, port cm11 themes, windows .bat, xtheme
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes