Any way to make battery icon image update every 10% rather than every 20%?

ChevyNo1

Premium Member
Premium Member
Developer
Joined
Dec 28, 2009
Messages
5,354
Reaction score
0
Ok -- just some ideas

I'm realizing that although I understand in general the concept of xml files, when it would come to creating an entry -- I'm really clueless. Wow a good tutorial would help (but how do I hate eclipse)!

Anyway just wondering what others have found along with questions:

Two xml files and one image directory jump out on review of the data:

/res/drawable/stat_sys_battery.xml:
<item android:drawable="@drawable/stat_sys_battery_0" android:maxLevel="4" />
<item android:drawable="@drawable/stat_sys_battery_10" android:maxLevel="14" />
<item android:drawable="@drawable/stat_sys_battery_20" android:maxLevel="29" />
<item android:drawable="@drawable/stat_sys_battery_40" android:maxLevel="49" />
<item android:drawable="@drawable/stat_sys_battery_60" android:maxLevel="69" />
<item android:drawable="@drawable/stat_sys_battery_80" android:maxLevel="89" />
<item android:drawable="@drawable/stat_sys_battery_100" android:maxLevel="100" />
/res/values/public.xml:
<public type="drawable" name="stat_sys_battery_0" id="0x01080293" />
<public type="drawable" name="stat_sys_battery_10" id="0x01080294" />
<public type="drawable" name="stat_sys_battery_100" id="0x01080295" />
<public type="drawable" name="stat_sys_battery_20" id="0x01080296" />
<public type="drawable" name="stat_sys_battery_40" id="0x01080297" />
<public type="drawable" name="stat_sys_battery_60" id="0x01080298" />
<public type="drawable" name="stat_sys_battery_80" id="0x01080299" />

And of course the /res/drawable-hdpi-v4 folder where the images are located.

Although /res/layout/battery_status.xml refers to the battery layout style I dont think this file is relevant although I don't quite fully understand this file unless its the text that is overlayed over the battery -- Not sure about this one.

Ok the big question -- when declaring new images -- am I ok with just arbitrarily picking IDs? A suggestion was to make them consecutive to the last drawable ID values, however if I look at the last 3 ID drawable values they seem not to be consecutive (these are found in res/values/public.xml):
<public type="drawable" name="usb_android_connected" id="0x01080358" />
<public type="drawable" name="bottombar_565" id="0x010800af" />
<public type="drawable" name="btn_lock_normal" id="0x010800fd" />

Thanks for any input!!!

@kevdog - sorry for the delay in getting back to you - it's been crazy since 4.7 came out!!

The only xml you need to change should be stat_sys_battery.xml; however ... the ID's that you are referencing (public.xml) are likely compile-time generated; I am truly not sure if you can do it this way or not ... I only get mine working because I compile from source and the id's are generated for me ...
 

kevdog

Member
Joined
Nov 14, 2009
Messages
721
Reaction score
0
Hmmm

I have a bad premonition, however I'm going to forge ahead anyway. Wish me luck. I have no idea how to compile from source (other than the kernel). Damn eclipse!!!
 

kevdog

Member
Joined
Nov 14, 2009
Messages
721
Reaction score
0
I need some icons --- The two posts that linked to icons in this thread -- either the images were bad or corrupted. Please send icons.

Update:
Got the modifications to actually compile -- Yea!! -- Now to see if they work on the phone device itself.
 
Last edited:

lrgraham14

New Member
Joined
Mar 6, 2010
Messages
5
Reaction score
0
I need some icons --- The two posts that linked to icons in this thread -- either the images were bad or corrupted. Please send icons.

Update:
Got the modifications to actually compile -- Yea!! -- Now to see if they work on the phone device itself.

Did you have any luck? I played with it the other day but had the same problems as others with the icons not displaying. This will be an awesome feature if someone can get it working!
 

kevdog

Member
Joined
Nov 14, 2009
Messages
721
Reaction score
0
Yes -- my end result was that after adding all the icons into the drawable-hdpi folder and adding the modified stat_sys_battery.xml file back into framework-res.apk, the battery icon did not display.

Chevy compiled his ROM from source so he did not run into this problem.

I originally made changes to the public.xml file within the decompiled framework, however when I recompiled -- this file or in fact the entire raw image folder was not visibile or was no longer present -- I'm not sure how the compilation process works, however is the data within the public.xml file somehow later morphed or added into other files?? I think this might be part of the problem.

I pulled the framework-res.apk that I modified, and attempted to decompile it. But here is some of the errors I was getting:
W: Could not decode attr value, using undecoded value instead: ns=android, name=d
rawable, value=0x0108035f

The hex value specifically being referenced is one that I added to public.xml:
<public type="drawable" name="stat_sys_battery_30" id="0x0108035f" />

Obviously something has been lost in translation.
 
Last edited:

kevdog

Member
Joined
Nov 14, 2009
Messages
721
Reaction score
0
Well I finally made this hack work!!! Needed to apply on top of stock theme or framework. I need to play around a bit more however consider this trick done. Because nobody supplied images, I just pulled the battery icons out of Chevy's ROM and used his. His are very generic, but at least they work for proof of concept.
 
OP
V
Joined
Nov 12, 2009
Messages
135
Reaction score
0
Well I finally made this hack work!!! Needed to apply on top of stock theme or framework. I need to play around a bit more however consider this trick done. Because nobody supplied images, I just pulled the battery icons out of Chevy's ROM and used his. His are very generic, but at least they work for proof of concept.

Nice! Great to hear that you've got this working. Great work! I look forward to a release when you've got it polished up.

And the battery icon being generic shouldn't be too big of an issue as it is pretty easily changed with metamorph.
 

kevdog

Member
Joined
Nov 14, 2009
Messages
721
Reaction score
0
I'm not sure if I'm going to make a release -- I could simply post a framework-res.apk file here that one could push using adb or root explorer, or convert this to an update.zip file that could be installed as well. Currently I have 10% intervals on the phone, I do possess 5% and 15% icons as well (as supplied by Chevy). The only problem with adding more and more percentage icons, is that if you want to theme over the stock icons, you will need to make more custom icon battery images. If you want me to use the 5 and 15% icons in addition to 0,10,20,30,40,50,60,70,80,90% (100% just has a full battery and no 100%), let me know and I can recompile the framework in a few minutes and then post the framework-res.apk. I've tested out at least the 10% step interval version on my phone today, and its running without a hitch.
 

lrgraham14

New Member
Joined
Mar 6, 2010
Messages
5
Reaction score
0
I'm not sure if I'm going to make a release -- I could simply post a framework-res.apk file here that one could push using adb or root explorer, or convert this to an update.zip file that could be installed as well. Currently I have 10% intervals on the phone, I do possess 5% and 15% icons as well (as supplied by Chevy). The only problem with adding more and more percentage icons, is that if you want to theme over the stock icons, you will need to make more custom icon battery images. If you want me to use the 5 and 15% icons in addition to 0,10,20,30,40,50,60,70,80,90% (100% just has a full battery and no 100%), let me know and I can recompile the framework in a few minutes and then post the framework-res.apk. I've tested out at least the 10% step interval version on my phone today, and its running without a hitch.

I would love to try out the framework you made! Heres some icons that I edited a while back, they are almost the same as chevys though... http://dl.dropbox.com/u/3325762/Battery_Icons10.zip
 

kevdog

Member
Joined
Nov 14, 2009
Messages
721
Reaction score
0
Just an update -- I'm having problems adding more additional icons to make a resultant framework file. No I haven't abandoned my efforts or just wanted to keep everyone hanging (although due to work I can't work on this everyday). I contacted the developer of APKManager since this is a problem with the build. For right now I'm going to try to hopefully find a hack around this problem.
 

medinauta

New Member
Joined
Dec 6, 2009
Messages
16
Reaction score
0
I got it... thanks to kalpik, the trick was to copy the META-INF folder and AndroidManifest.xml from the original framework-res.apk to the compiled one!, I got it in 10% increments!

1. Copy framework-res.apk
2. Decompile it with APK Manager 4.8
3. Paste the ... xml files in drawable and the png files in drawable-hdpi-v4.
4. Compile the apk
5. Copy META-INF folder and AndroidManifest.xml from the original APK to the modded one

APK Manager: Option 9 (decompile) and option 11 (compile).
7zip: To copy the original files to the modded one.
Then create an update.zip with the framework-res.apk in it and install with recovery.
 
Last edited:

kevdog

Member
Joined
Nov 14, 2009
Messages
721
Reaction score
0
That will definitely work --

Just an fyi -- you only need to compile the framework additionally for any xml changes. You don't need to do for simple png or image changes. And you don't necessarily need an update.zip. An alternative is to simply push with adb and then reboot.

Ive included a screencap -- (Man I need more battery quick!!)
 
Last edited:

microsnook

Active Member
Joined
Feb 8, 2010
Messages
1,291
Reaction score
0
That will definitely work --

Just an fyi -- you only need to compile the framework additionally for any xml changes. You don't need to do for simple png or image changes. And you don't necessarily need an update.zip. An alternative is to simply push with adb and then reboot.

Ive included a screencap -- (Man I need more battery quick!!)

kevdog, Im on CM and I used an edited xml file and added the pngs but they wouldnt display properly. Could you help me out with getting these 10% pngs?!
 

kevdog

Member
Joined
Nov 14, 2009
Messages
721
Reaction score
0
Send or post a non themed framework-res.apk and I'll fix it up for you.
 
Top