[HOW TO] 10% battery in themed framework apks


Last Updated:

  1. yawdapaah

    yawdapaah Well-Known Member This Topic's Starter

    Joined:
    Aug 20, 2009
    Messages:
    900
    Likes Received:
    288
    Why did I do this? Well, I wanted to use Fightspit's circular battery icons. The DX's icons only change every 20% which is kind of useless for the icon set I wanted.
    It's easy to swap out icons (via 7zip) but adding icons creates a lot of problems. This forced me to come up with a workaround. Here's the process in case anyone else has been trying to do this.

    ---------------

    What’s needed:
    ApkManager
    The themed framework-res.apk file
    • Extract framework-res.apk from any themed zip file
    • Or adb pull it from your THEMED phone’s system/framework directory

    Stock framework-res.apk file
    • Extract this from TBH’s deodexed 2.3.15 leak
    • Or adb pull from your STOCK phone

    Batter and charging icons
    • I use 0, 5, 10, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100 battery icons since the DX only reports battery readings in 10% increments.
    • I have 20 charging pngs. You can have more or less but you’ll have to modify some XMLs (see below) to get them to work.
    • You can use UOT Kitchen to generate battery icons. There are, also, other icons floating around on XDA. Just be careful to use HDPI compatible types.

    The attached decompiled XML files (these go in the DECOMPILED drawable-hdpi folder along with the batter icons). Edit these if you add or remove pngs.

    7zip or Winrar (I prefer the former for modding .apk files)

    Working knowledge of DOS (optional) or patience

    DIRECTIONS:
    Stock framework-res.apk prep
    • Extract ApkManager (you can put this anywhere. I have it on c:\ to make things easier in DOS)
    • Put your STOCK framework-res.apk in the place-apk-here-for-modding folder
    • Run the script and DECOMPILE (Option 9) the apk. The decompile folder will be in the projects folder.
    • Delete the STOCK framework-res.apk from the place-apk-here-for-modding folder
    • Move the DECOMPILED framework-res.apk folder from projects into the main ApkManager folder. This will be your repository of stock files that you will need later

    Themed framework-res.apk prep
    • At this point you should have NOTHING in your modding folder AND project folders
    • Put your THEMED framework-res.apk in the modding folder
    • From the ApkManager root folder, DELETE the log text file
    • Run the script and DECOMPILE (Option 9) the themed apk.
    • After the decompile is done, close the script and open up the newly created log.txt file
    • In the log you’ll see some .9.png errors in /res/drawable-hdpi folder. These are files that were not decompiled properly because some required information (9patch) was missing. Each of those 9.png files will be decompiled (wrongly) and then renamed to .png. Therefore for every SINGLE 9.png error file, there will be one USELESS .png file. NOTE: If you try to recompile with these broken 9patches, the resultant apk WILL cause you to bootloop.

    Let’s pause here for a bit:
    All the 9.png files listed in the error log, as stated before, are BROKEN. The decompile script aapt (apktool) ‘decompiles’ these broken 9.png files, makes a copy of said files, and renames the copies as *.png.
    So, there are, actually, two broken files (one 9.png and one .png) for every error in the log. You have to delete BOTH of these files and replace them with healthy files from the stock framework we decompiled earlier. If you skipped that, go back up and do it. The awesome thing is that there are hundreds of healthy 9.pngs and even more .png files in your THEMED framework decompiled folder. Locating each of this files (sometimes 30 x 2) is a pain. My workaround is to use good ol’ DOS. You don’t have to do the next few steps with DOS but you have to reach the same end.

    • Enter the dra… er decompiled framework-res folder in /projects.
    • Copy/mark the error 9.pngs into MS Word (or whatever you use). Keep Word and DOS open till were done with this part.
    • Using find and replace do the following:
    • Copy everything before the 9.png file and find/replace that with “del “.
    • Copy everything after .png and find/replace it with NOTHING (don’t type “nothing”)

    The outcome should be:
    del first_example.9.png
    del second_example.9.png
    and should contain all the broken .9.png files

    • In DOS, cd to decoded framework’s folder’s drawable-hdpi folder
    • Copy and paste the contents of the Word file into DOS to delete all the broken 9.png files.
    • Go back to MS Word and find/replace .9.png with .png

    The outcome should be:
    del first_example.png
    del second_example.png
    and should contain all the broken, renamed .png files.

    • If you didn’t close the DOS window, just copy and paste the modified contents of your Word folder into DOS to delete all the broken .png files. If you closed the DOS window, shame on you :p. You’ll have to open DOS again and navigate back to the decoded framework’s drawable-hdpi folder first.
    • You should have removed both the BROKEN .9.png and .png files from the decompiled framework’s drawable-hdpi folder
    • Head back to MS Word one last time and edit the files to look like this

    copy first_example.9.png c:\APKManager\projects\framework-res.apk\res\drawable-hdpi\
    copy second_example.9.png c:\APKManager\projects\framework-res.apk\res\drawable-hdpi\
    etc.
    The c:\... will vary depending on where you put your APKManager folder. If you put it somewhere else, copy the location from your address bar.

    • Head back to DOS and cd to your STOCK folder’s drawable-hdpi folder.
    • Copy the contents from MS Word into DOS and this will copy the healthy .9.png files to your THEMED decoded framework’s drawable-hdpi folder.
    • You can close MS Word and DOS at this point.
    • Replacing the battery icons and xml files.
    • Navigate to your THEMED decompiled framework’s drawable-hdpi folder.
    • Paste your new battery icons into this folder (overwriting all the existing ones). The files to look for are stat_sys_battery_X.png and stat_sys_battery_charge_animX.png
    • You should also replace ic_lock_idle_charging and ic_lock_idle_low_battery (I use the fully charged and the battery unknown pngs respectively)
    • Replace the xml files with your modified ones. The files to replace are stat_sys_battery.xml and stat_sys_battery_charge.xml.

    Rebuilding your framework-res.apk
    • At this point you should have your THEMED framework-res.apk in the modding folder and your THEMED, decompiled framework-res.apk folder in the project folder (with your new png and xml files.)
    • Go back to the APK Manager main folder and run the script.
    • Compile the apk (Option 11)
    • You will be asked if this is a system apk. Choose YES.
    • You will be asked if you want to copy all unmodified files from the oringal apk. You can choose NO.
    • Sign the APK (Option 12).
    • Go into the modding folder, you will find a signedframework-res.apk
    • Open (DON’T EXTRACT) signedframework-res.apk with 7zip or Winrar.
    • Open (again, DON’T EXTRACT) the themed framework-res.apk (also in the modding folder) with 7zip or Winrar
    • Delete, from within 7zip, the META-INF directory and AndroidManifest.xml file from signedframework-res.apk
    • Copy, inside 7zip, META-INF and AndroidManifest.xml from your original themed framework-res to signedframework-res.apk Don’t unzip anything.
    • Still in 7zip, navigate to /res/drawable-hdpi in both the original, themed framework-res.apk and signedframework-res.apk. Delete everything BUT the new (stat_sys_battery stat_sys_battery_charge) xmls and battery and charging .pngs from signedframework-res.apk. If you used my files, there will be only 40 items left.
    • Finally, copy (still in 7zip) everything BUT stat_sys_battery.xml, stat_sys_battery_charge.xml, and the battery and charging .pngs from the themed framework-res.apk’s drawable-hdpi folder to signedframework-res.apk’s drawable-hdpi folder.
    • Your modified framework-res.apk is ready to be pushed to your phone.

    Putting the files on your phone.
    • Either push signedframework-res.apk to your phone via adb or
    • Create an update.zip for use with clockwork recovery. You can also take the theme’s zip file and replace the framework-res.apk as well. (I like this). Or you can just make one if you like.
    • Reboot your phone if you used adb and welcome to 10% heaven.

    I’m hoping our themers will incorporate the 10% hack into their themes. For them it’s only a matter of replacing the (2) xml files before compiling the theme.

    I’ll try to answer any questions as best I can.
    Also, please donate to the DEVs (not me!) if you can. This little task took me almost a week (after work and no SSF4 for me :( ) to figure out. Imagine how much work is required to bring ApeX, RubiX, ZapX etc…

    Grab the Apex rEVO and NexTheme mods and files at:
    REVOlution theme with 10% Circle Battery MOD and NexTheme 10% Circle Battery Mod.

    Decompiled XML files

    Thanks to:
    Fabolous - for a great ROM and several great themes.
    aflat - partner in crime; helped me figure this stuff out.
    Fightspit - for the great icons
    Qliratu - for the online cooking tool. Use it to generate your battery pngs. UOT Kitchen
     

    Advertisement
    mxsjw likes this.
  2. yawdapaah

    yawdapaah Well-Known Member This Topic's Starter

    Joined:
    Aug 20, 2009
    Messages:
    900
    Likes Received:
    288
    I'm sorry for that wall of text lol.
     
  3. Airmaxx23

    Airmaxx23 Well-Known Member

    Joined:
    Jun 21, 2010
    Messages:
    3,142
    Likes Received:
    1,039
    Well, I gave this a try twice today and was not successful either time. I followed the directions to the "T" but I got stuck in a boot loop both times. The only thing I did differently was I did not use DOS to remove/replace the broken 9.png files, I just manually deleted them and put the new files in their place. I'm not sure what I did wrong. :(
     
  4. yawdapaah

    yawdapaah Well-Known Member This Topic's Starter

    Joined:
    Aug 20, 2009
    Messages:
    900
    Likes Received:
    288
    What were you trying to MOD? I'll follow the directions and see what the outcome is.
     
  5. Airmaxx23

    Airmaxx23 Well-Known Member

    Joined:
    Jun 21, 2010
    Messages:
    3,142
    Likes Received:
    1,039
    I'm trying to change the battery and charging icons in a different theme that only goes up in 20% increments so that it will go up exactly like your setup. Can the resulting framework-res.apk file be placed properly with Root Explorer?
     
  6. yawdapaah

    yawdapaah Well-Known Member This Topic's Starter

    Joined:
    Aug 20, 2009
    Messages:
    900
    Likes Received:
    288
    There shouldn't be a problem using Root Explorer. Did you get any errors in the recompile (not the en-GB warnings)?
     
  7. Airmaxx23

    Airmaxx23 Well-Known Member

    Joined:
    Jun 21, 2010
    Messages:
    3,142
    Likes Received:
    1,039
    None...
     
  8. yawdapaah

    yawdapaah Well-Known Member This Topic's Starter

    Joined:
    Aug 20, 2009
    Messages:
    900
    Likes Received:
    288
    Upload the theme and your icons then pm me the link. I'll try it when I get home.

    There may be an issue with APKManager's recompiling; I get an additional file with NexTheme :eek:
     
  9. SimsDelt

    SimsDelt Well-Known Member

    Joined:
    Aug 4, 2010
    Messages:
    1,067
    Likes Received:
    246
    Ok... this hurt my head... I wondered why I was not a themer/developer... the wall-o-text in the OP is exactly why... lol. Thanks for the tut though... awesome work.
     
  10. Airmaxx23

    Airmaxx23 Well-Known Member

    Joined:
    Jun 21, 2010
    Messages:
    3,142
    Likes Received:
    1,039
    I ended up going back to my rooted 2.2 (via SBF) and did a fresh install of Apex; Revolution; 10% battery and clock removal. I use Beautiful Smaller Home and I have it setup so that The Weather Channel app provides my temperature notification (more accurate in my area) but I did not like the blue temperature icons. I pulled the 121 temp icons from Beautiful Widgets (black icons) renamed them and used the APKManager to change them in the Weather Channel app. It worked like a charm.

    [​IMG]
     
  11. yawdapaah

    yawdapaah Well-Known Member This Topic's Starter

    Joined:
    Aug 20, 2009
    Messages:
    900
    Likes Received:
    288
    Glad it worked for you. Is there anything you'd like me to change in the writeup?
     
  12. Airmaxx23

    Airmaxx23 Well-Known Member

    Joined:
    Jun 21, 2010
    Messages:
    3,142
    Likes Received:
    1,039
    I basically used most of the write to change the icons in the weather channel.apk and it worked fine. I did not change the battery icons with it, I did a fresh install of Apex with Revolution and then used your 10% revolution mod. Thanks again.
     
  13. bouchigo

    bouchigo Well-Known Member

    Joined:
    Aug 10, 2010
    Messages:
    3,756
    Likes Received:
    1,026
    I don't see any .9.png errors in the log file after decompiling the themed framework-res.apk. All I see is this:

    java version "1.6.0_22"
    Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
    Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
    'adb' is not recognized as an internal or external command,
    operable program or batch file.
    Could Not Find C:\APKManager\place-apk-here-for-modding\../place-apk-here-for-modding/signedframework-res.apk
    Could Not Find C:\APKManager\place-apk-here-for-modding\../place-apk-here-for-modding/unsignedframework-res.apk
    I: Loading resource table...
    I: Decoding resources...
    S: Could not decode file, replacing by FALSE value: drawable/stat_sys_battery_charge.xml
    S: Could not decode file, replacing by FALSE value: drawable/stat_sys_battery.xml
    I: Copying assets and libs...


    Any ideas?
     
  14. yawdapaah

    yawdapaah Well-Known Member This Topic's Starter

    Joined:
    Aug 20, 2009
    Messages:
    900
    Likes Received:
    288
    Fix the 'adb' error first then post any other errors you get. You should add the SDK tools folder to your Windows environment. Right click My Computer >> Properties >> Advanced >> Look in system variables for "Path" and add your SDK's tool folder.

    Good Luck :D
     
    bouchigo likes this.
  15. bouchigo

    bouchigo Well-Known Member

    Joined:
    Aug 10, 2010
    Messages:
    3,756
    Likes Received:
    1,026
    I was using my computer at work, I knew I forgot something....thanks for the tip. This is my machine at home.

    I still get this though:

    --------------------------------------------------------------------------
    |Tue 11/02/2010 -- 17:17:32.74|
    --------------------------------------------------------------------------
    java version "1.6.0_21"
    Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
    Java HotSpot(TM) 64-Bit Server VM (build 17.0-b17, mixed mode)
    Could Not Find C:\APK Manager\place-apk-here-for-modding\../place-apk-here-for-modding/signedframework-res.apk
    Could Not Find C:\APK Manager\place-apk-here-for-modding\../place-apk-here-for-modding/unsignedframework-res.apk
    I: Loading resource table...
    I: Decoding resources...
    S: Could not decode file, replacing by FALSE value: drawable/stat_sys_battery.xml
    S: Could not decode file, replacing by FALSE value: drawable/stat_sys_battery_charge.xml
    I: Copying assets and libs...


    Do I need to have signedframework-res.apk and unsigned framework-res.apk in there too? If so, where to I get those .apk files from?
     
  16. bouchigo

    bouchigo Well-Known Member

    Joined:
    Aug 10, 2010
    Messages:
    3,756
    Likes Received:
    1,026
    This is what I get when I decompile the Apex Ver. 1.o framework-res.apk:

    --------------------------------------------------------------------------
    |Tue 11/02/2010 -- 17:47:43.57|
    --------------------------------------------------------------------------
    java version "1.6.0_21"
    Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
    Java HotSpot(TM) 64-Bit Server VM (build 17.0-b17, mixed mode)
    Could Not Find C:\APK Manager\place-apk-here-for-modding\../place-apk-here-for-modding/signedframework-res.apk
    Could Not Find C:\APK Manager\place-apk-here-for-modding\../place-apk-here-for-modding/unsignedframework-res.apk
    I: Loading resource table...
    I: Decoding resources...
    W: Cant find 9patch chunk in file: "drawable-hdpi/zz_moto_jog_tab_bar_up_end.9.png". Renaming it to *.png.
    W: Cant find 9patch chunk in file: "drawable-hdpi/zz_moto_jog_tab_bar_left_end.9.png". Renaming it to *.png.
    W: Cant find 9patch chunk in file: "drawable-hdpi/zz_moto_jog_tab_bar_down_end.9.png". Renaming it to *.png.
    W: Cant find 9patch chunk in file: "drawable-hdpi/zz_moto_jog_tab_bar_right_end.9.png". Renaming it to *.png.
    I: Copying assets and libs...

    It seems like it's the expected output.......why do I not get any .9.png errors on the framework-res.apk decompile posted in the previous post (Note, it's the framework-res.apk from the Kennedy X Rom in my previous post).
     
  17. Airmaxx23

    Airmaxx23 Well-Known Member

    Joined:
    Jun 21, 2010
    Messages:
    3,142
    Likes Received:
    1,039
    I ended up changing the temp icons again, the "button" look of the icons just didn't look right on the status bar so I pulled the temp icons from Weather Bug and placed them in The Weather Channel app. It takes longer to rename the 141 png files than it does to actually replace them.

    [​IMG]
     
  18. yawdapaah

    yawdapaah Well-Known Member This Topic's Starter

    Joined:
    Aug 20, 2009
    Messages:
    900
    Likes Received:
    288
    I'm going to try KennedyX and will let you know what happens.
     
  19. yawdapaah

    yawdapaah Well-Known Member This Topic's Starter

    Joined:
    Aug 20, 2009
    Messages:
    900
    Likes Received:
    288
    When I decompile KennedyX I get this:

    --------------------------------------------------------------------------
    |Thu 11/04/2010 -- 12:32:14.43|
    --------------------------------------------------------------------------
    java version "1.6.0_13"
    Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
    Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
    Could Not Find C:\apk_manager_4.9\place-apk-here-for-modding\../place-apk-here-for-modding/signedframework-res.apk
    Could Not Find C:\apk_manager_4.9\place-apk-here-for-modding\../place-apk-here-for-modding/unsignedframework-res.apk
    I: Loading resource table...
    I: Decoding resources...
    S: Could not decode file, replacing by FALSE value: drawable-hdpi/spinnerbox_arrow_single.9.png
    S: Could not decode file, replacing by FALSE value: drawable-hdpi/pickerbox_unselected.9.png
    W: Cant find 9patch chunk in file: "drawable-hdpi/zz_moto_jog_tab_bar_up_end.9.png". Renaming it to *.png.
    S: Could not decode file, replacing by FALSE value: drawable-hdpi/pickerbox_selected.9.png
    W: Cant find 9patch chunk in file: "drawable-hdpi/jog_tab_bar_right_end_confirm_yellow.9.png". Renaming it to *.png.
    W: Cant find 9patch chunk in file: "drawable-hdpi/jog_tab_bar_right_end_pressed.9.png". Renaming it to *.png.
    W: Cant find 9patch chunk in file: "drawable-hdpi/jog_tab_bar_left_end_confirm_green.9.png". Renaming it to *.png.
    S: Could not decode file, replacing by FALSE value: drawable-hdpi/pickerbox_background.png
    W: Cant find 9patch chunk in file: "drawable-hdpi/jog_tab_bar_left_end_confirm_gray.9.png". Renaming it to *.png.
    W: Cant find 9patch chunk in file: "drawable-hdpi/jog_tab_bar_left_end_pressed.9.png". Renaming it to *.png.
    W: Cant find 9patch chunk in file: "drawable-hdpi/jog_tab_bar_right_end_normal.9.png". Renaming it to *.png.
    S: Could not decode file, replacing by FALSE value: color/primary_text_light_disable_select.xml
    W: Cant find 9patch chunk in file: "drawable-hdpi/jog_tab_bar_left_end_confirm_yellow.9.png". Renaming it to *.png.
    W: Cant find 9patch chunk in file: "drawable-hdpi/jog_tab_bar_right_end_confirm_gray.9.png". Renaming it to *.png.
    W: Cant find 9patch chunk in file: "drawable-hdpi/jog_tab_bar_left_end_confirm_red.9.png". Renaming it to *.png.
    W: Cant find 9patch chunk in file: "drawable-hdpi/zz_moto_jog_tab_bar_down_end.9.png". Renaming it to *.png.
    S: Could not decode file, replacing by FALSE value: drawable-hdpi/spinnerbox_arrow_first.9.png
    W: Cant find 9patch chunk in file: "drawable-hdpi/zz_moto_jog_tab_bar_right_end.9.png". Renaming it to *.png.
    W: Cant find 9patch chunk in file: "drawable-hdpi/jog_tab_bar_right_end_confirm_green.9.png". Renaming it to *.png.
    S: Could not decode file, replacing by FALSE value: drawable-hdpi/spinnerbox_arrow_middle.9.png
    S: Could not decode file, replacing by FALSE value: drawable-hdpi/spinnerbox_arrow_last.9.png
    W: Cant find 9patch chunk in file: "drawable-hdpi/jog_tab_bar_right_end_confirm_red.9.png". Renaming it to *.png.
    W: Cant find 9patch chunk in file: "drawable-hdpi/zz_moto_jog_tab_bar_left_end.9.png". Renaming it to *.png.
    W: Cant find 9patch chunk in file: "drawable-hdpi/jog_tab_bar_left_end_normal.9.png". Renaming it to *.png.
    I: Copying assets and libs...
     
  20. bouchigo

    bouchigo Well-Known Member

    Joined:
    Aug 10, 2010
    Messages:
    3,756
    Likes Received:
    1,026
    Yeah I am getting that now.

    Before I was using the framework-res.apk from Kennedy X with the theme applied, extracted from my phone with root explorer. I tried the framework-res.apk (no theme) from the Kennedy X zip and now I get the results you are getting.

    Thanks
     
  21. yawdapaah

    yawdapaah Well-Known Member This Topic's Starter

    Joined:
    Aug 20, 2009
    Messages:
    900
    Likes Received:
    288
    No problems. If you have any other issues please ask cos others might run into the same problems.
     
    bouchigo likes this.
  22. bouchigo

    bouchigo Well-Known Member

    Joined:
    Aug 10, 2010
    Messages:
    3,756
    Likes Received:
    1,026
    @yawdapaah

    I tried modifying the blackbar mod by tom108 and applying it to Fission 2.1 Final using your guide, but I keep getting this error when I try to check my contacts or on certain apps:

    "The Process android.process.acore has stopped unexpectedly. Please try again."

    Any ideas?
     
  23. colchiro

    colchiro Well-Known Member

    Joined:
    Jun 4, 2010
    Messages:
    8,886
    Likes Received:
    1,784
  24. bouchigo

    bouchigo Well-Known Member

    Joined:
    Aug 10, 2010
    Messages:
    3,756
    Likes Received:
    1,026
  25. colchiro

    colchiro Well-Known Member

    Joined:
    Jun 4, 2010
    Messages:
    8,886
    Likes Received:
    1,784
    The multicolor battery theme here worked for me.

    O/W give me a day or two. I'm about to post a blue 10% battery theme.

    [​IMG]
     

Share This Page

Loading...