[mod] Battery icon with percent

Chris3D

Well-known member
Sep 21, 2010
646
179
0
Visit site
Hi guys, so the stock battery icon was annoying the hell out of me with how it wouldn't show an actual number, and it only displayed in 10% increments. I know there are utilities that'll put an icon with numerical display on the notification bar, but I hate having to have TWO battery icons just to get what should be shown in the stock one.

So, after much trial and error, I figured out how to modify the framework-res.apk to not only add in icons with a number on top, but to add in 1% increments. It seems to be working perfectly on my phone, and if any daring souls want to give it a try, here it is.

But first, a few caveats...

If you're using a modded theme, you don't want this. All the mods to themes are done in the framework-res.apk file, and aside from the battery icon changes, this one it completely stock, so it would revert your theme back to stock. But chances are if you're using a theme, it already has new battery icons so you wouldn't want this anyway.

This *seems* to be working, and I don't *think* it could make your phone explode, but there's no guarantees. In getting this to work, I had many failed attempts that caused the phone to get stuck on boot, but all that needed to be done was reboot into Clockwork recovery and adb push the original back. Phone booted up perfectly afterward each and every time, so on the odd chance it doesn't work, reverting back to the original doesn't appear to leave any lasting effects.

So, here 'ya go:

Step 1 - Download my modded framework-res.apk:
For DI01
For DJ05 (remove "DJ05_" from the file name before continuing)​

Step 2 - Reboot your phone into Clockwork recovery and connect it to your computer.

Step 3 - Place the framework-res.apk into whatever directory contains your adb files, start a dos prompt and navigate there.

Step 4 - Type "adb pull system/framework/framework-res.apk orig_framework-res.apk" This pulls the original off your phone and saves it locally should you want to restore it.

Step 5 - Type "adb push framework-res.apk system/framework/framework-res.apk" This copies the new apk onto your phone.

Step 6 - Reboot.

If something goes wrong - your phone doesn't boot or boots but other issues pop up, just reboot into recovery and type "adb push orig_framework-res.apk system/framework/framework-res.apk" and it'll copy the original file back.

Here's a screenshot of the new icon. Charging icons haven't changed, I just want to make sure this is working before I delve into it any further.

batt.jpg
 
Last edited:

Chris3D

Well-known member
Sep 21, 2010
646
179
0
Visit site
that looks pretty cool, and I think I prefer this to the circle with the percentage in the middle of it.

That's exactly why I did this - I didn't like the circle one either, I like the normal battery icon and just wanted a number on top and to have it show in 1% increments.

Down to 30 percent, the battery fill is blue, 30 to 15 it's orange, 10 below it's red and 4 to 0 it's just a red outline that (should) blink on and off (should is in parentheses because I'm still waiting for my battery to get down there to verify)
 

Plinkie

Member
Oct 25, 2010
13
1
0
Visit site
Thank you for this.. this is exactly want I've been wanting.
I just wanted a battery icon with percent. nothing too fancy.

Seems to be working fine.
Installed on Super Clean with Stupid Fast Kernal..
 

Chris3D

Well-known member
Sep 21, 2010
646
179
0
Visit site
Thank you for this.. this is exactly want I've been wanting.
I just wanted a battery icon with percent. nothing too fancy.

Seems to be working fine.
Installed on Super Clean with Stupid Fast Kernal..

Cool, glad to hear it works for you.

I'm trying to put together another which shows a plug icon when charging with ascending numbers, but for some reason I can't explain, it always shows 20%... no matter what level the battery really is. When I figure it out, I'll post.

Oh, and there's a tiny error in my framework file... it counts down 8, 7, 6, 5, 0, 3, 2, 1... 4 is missing! I can upload a fixed one if you want, but I should be able to figure out the charging one soon anyway.
 

Fappy Jones

Well-known member
Oct 12, 2010
205
10
0
Visit site
I just got this battery % meter with the dark gloss rom.

6199475a-6c61-a092.jpg


I like it and the dark notification bar.

Sent from my JT Super Clean Fascinate
 

Adiliyo

Well-known member
Oct 17, 2009
2,412
49
0
Visit site
they're all the same idea once you replace the xml in framework. then the icon you want is a matter of replacing png's, so if you want something specific, you can make one, or there is a thread on xda with a bunch of them.

:)
 

AmanteNJ

Well-known member
Oct 3, 2010
125
2
0
Visit site
I installed this through root explorer, after saving it to my sd card i made a copy of the original framework saved it somewhere in the sd card and replaced with this one, reboot. looks good thanks, the wall paper got reset tho and got a FC of yahoo mail but everything else is fine
 

Chris3D

Well-known member
Sep 21, 2010
646
179
0
Visit site
or there is a thread on xda with a bunch of them.

If we're thinking of the same thread, they were all for Froyo... we're a bit behind the curve ;) And all the ones I saw for the Fascinate were part of a broader themed framework. I just wanted the stock battery on the stock theme, with the addition of the number ontop.

I installed this through root explorer, after saving it to my sd card i made a copy of the original framework saved it somewhere in the sd card and replaced with this one, reboot. looks good thanks, the wall paper got reset tho and got a FC of yahoo mail but everything else is fine

Do you always have FC's in Yahoo mail, or was it just once? If it was just once, it probably had to do with replacing the framework while it was still "live". Pushing it to the phone in recovery avoids any problems like that.

So anyway, I think I've discovered the problem with displaying the charging icon - it seems to be a bug in how the battery status is reported to/by the OS. I don't know if that happens in the kernel or the system, but all the modded frameworks I tried are stuck on or around the 20% mark while charging. And when I study even the stock charge icon animation, it too is stuck at the 20% mark - it plays the little animation, but it's the animation for 20% and never plays any of the others. So, my XML is fine, it's just always being told that the battery is ~20% when charging.

In other words, I've given up getting an accurate charging icon working. But I updated my framework (linked in the OP) to fix the missing 4% icon, so if anyone's interested, they can update theirs, but the previous one shouldn't cause any issues whatsoever beside not showing 4%.
 

Adiliyo

Well-known member
Oct 17, 2009
2,412
49
0
Visit site
If we're thinking of the same thread, they were all for Froyo... we're a bit behind the curve ;) And all the ones I saw for the Fascinate were part of a broader themed framework. I just wanted the stock battery on the stock theme, with the addition of the number ontop.



Do you always have FC's in Yahoo mail, or was it just once? If it was just once, it probably had to do with replacing the framework while it was still "live". Pushing it to the phone in recovery avoids any problems like that.

So anyway, I think I've discovered the problem with displaying the charging icon - it seems to be a bug in how the battery status is reported to/by the OS. I don't know if that happens in the kernel or the system, but all the modded frameworks I tried are stuck on or around the 20% mark while charging. And when I study even the stock charge icon animation, it too is stuck at the 20% mark - it plays the little animation, but it's the animation for 20% and never plays any of the others. So, my XML is fine, it's just always being told that the battery is ~20% when charging.

In other words, I've given up getting an accurate charging icon working. But I updated my framework (linked in the OP) to fix the missing 4% icon, so if anyone's interested, they can update theirs, but the previous one shouldn't cause any issues whatsoever beside not showing 4%.

i don't remember which version it was for, but the png's are the same name wise, so as long as the xml files are edited, you can pick and choose whatever style of accurate battery you want :)
 

Chris3D

Well-known member
Sep 21, 2010
646
179
0
Visit site
i don't remember which version it was for, but the png's are the same name wise, so as long as the xml files are edited, you can pick and choose whatever style of accurate battery you want :)

But the modified framework files were for Froyo... are you saying they'll work on 2.1? If not, they don't do us any good, which is why I went through the trouble of modifying a 2.1 framework file...
 

Adiliyo

Well-known member
Oct 17, 2009
2,412
49
0
Visit site
you're right, the framework edits won't work, but if people want to try the other images for the battery, they can use those combined with your framework :)
 

Chris3D

Well-known member
Sep 21, 2010
646
179
0
Visit site
Yea, if anyone's interested, I can put together a quick .bat file that'll do all the work of replacing the images. I should have probably automated the process for myself considering how many times I've done it now.

I wonder if it's possible to replace the directory inside the apk that contains all the images with a sim link to a directorl elsewhere - so the images could be replaced on the fly without having to constantly mess with the apk. Probably not, but it'd be slick if it could.
 

Sta11i0n

Well-known member
Oct 22, 2010
958
151
0
Visit site
I too received a force close after the first time I just copied the file over with Root Explorer (for TW) but that was just whenever I reset the phone. This also happened to be when I was playing around with a few different ROMs and Kernels so I think that might have been related. I've since gone back to a prior Clockwork backup which was with the stock ROM/Kernel/Launcher and haven't had any problems since. I don't use Yahoo mail so I can't rule either way on that one.
 

Chris3D

Well-known member
Sep 21, 2010
646
179
0
Visit site
i deleted the original file using root explorer and now im stuck on the samsung screen. any idea how to recover?

If you boot into recovery, you can use adb push to copy the new file... Just follow my instructions in the first post.

It's never safe to delete major system files while the OS is running... which is why I said to do it in Clockwork.
 

Members online

Trending Posts

Forum statistics

Threads
943,653
Messages
6,919,467
Members
3,159,138
Latest member
Mickmac