[MOD] Battery Bar for All ROMs - Updated 31/3/12

Search This thread

pvyParts

Inactive Recognized Developer
Oct 11, 2010
1,858
2,341
35
Anyone run into and/or know how to fix the 1% battery notification when the battery level is less than 15%? Pvy said (in a PM) that it had something to do with the way I was hiding the stock battery icon, but I've never successfully figured this out. Issue is indeed resolved by unhiding the icon. :confused:

This has been a minor, but long-standing bug in my ROM. :(

Sorry dude I completely forgot. Can you send me the smali file that has the hide code in it and ill compare it to my fix to see if it can work too.

Pvy

Sent from my TEAM Powered Arc S
 
  • Like
Reactions: grayn0de

hlxanthus

Senior Member
Jun 10, 2011
1,523
1,177
This works for the LG Optimus S, thought you might like to know. I would like to include this mod within a future release of my rom (currently release, just looking for more goodies for it LOL), but is there a way to modify to be active by default so on the user end it doesnt have to be activated to work? I must say, I am impressed with this, works flawlessly. A nice addition to the settings apk would be to have the option for a centered battery bar, and maybe move to the bottom of the status bar. Just a thought.

Edit: saw these features had been mentioned already, so no biggie
 
Last edited:

hlxanthus

Senior Member
Jun 10, 2011
1,523
1,177
Well, I have released this in my rom. I rethemed my framework-res.apk from the standard uot theme I had to change the battery to show just the numerical percentage. Everyone, feel free to make use of the images from the apk if you want, though I doubt the apk itself would work for you. Thanks pvy !! If you are interested in checking out my rom just follow the link for the apk and go back to the first page!

http://forums.androidcentral.com/showthread.php?p=1795413 - themed framework-res.apk
 
Last edited:

Ticklefish

Recognized Themer
Oct 27, 2011
6,773
8,627
Hampshire, UK
Well, I have released this in my rom. I rethemed my framework-res.apk from the standard uot theme I had to change the battery to show just the numerical percentage. Everyone, feel free to make use of the images from the apk if you want, though I doubt the apk itself would work for you. Thanks pvy !! If you are interested in checking out my rom just follow the link for the apk and go back to the first page!

http://forums.androidcentral.com/showthread.php?p=1795413 - themed framework-res.apk

Very nice! Is it possible I could use those in a command-line tool I'm working on? Fully credited, of course.
I tried to do something similar but my artistic skills are...not so good! :)

Sent from my U20i, SK17i, GT-P1010 or something else entirely.
 

MatZ69

Senior Member
Jan 25, 2011
640
911
Odivelas/Lisbon
Hey, i do like the tutorial said, with the 5v files and V5.apk and the carge animation simple doesnt work...
The bar only increases with the charging level but not animated...
Can someone help me?

Thanks
 

Arbybear

Senior Member
Oct 2, 2011
104
4
Hey, I found a bug on my Droid x2 cm7. Sometimes, when the battery bar is at its normal color, it switches to the charging color.
 

Metallan

Senior Member
Sep 3, 2010
50
4
Alajuela
ok, so I checked a few pages at the beginning and the end and didn't see anyone else reporting this, but the "hide while in fullscreen" option isn't working for me on ICS. Neither on my SGS2 nor my Note.

Could this be something related to Touchwiz UI or ICS? It worked just fine when I had both devices with GB, but it stopped working after updating to ICS:

EDIT: I'm using the market version. The app link brought me here, but if there's another place I should be reporting this, please let me know.
 
Last edited:

pvyParts

Inactive Recognized Developer
Oct 11, 2010
1,858
2,341
35
ok, so I checked a few pages at the beginning and the end and didn't see anyone else reporting this, but the "hide while in fullscreen" option isn't working for me on ICS. Neither on my SGS2 nor my Note.

Could this be something related to Touchwiz UI or ICS? It worked just fine when I had both devices with GB, but it stopped working after updating to ICS:

EDIT: I'm using the market version. The app link brought me here, but if there's another place I should be reporting this, please let me know.

Here is great i am offshore with work will fix it when i get home. prob 4 or 5 days...

Pvy.

Sent from my Transformer TF101 using XDA Premium HD app
 

motcher41

Senior Member
Jul 29, 2011
3,666
1,337
Perham, Minnesota
Pvy, I was using the battery bar on my nexus somehow I managed to delete the app and now market says my nexus isn't compatible. Can o get a free version apk to download?
Sent from my Galaxy Nexus using Tapatalk 2
 
  • Like
Reactions: pvyParts

pvyParts

Inactive Recognized Developer
Oct 11, 2010
1,858
2,341
35
  • Like
Reactions: Vinzgore

Top Liked Posts

  • There are no posts matching your filters.
  • 117

    MOD Version

    App Version Here - http://xdaforums.com/showthread.php?t=1568318

    Howdy All,

    Few people have been asking me how i got the Miui Battery Bar into my ROM on the x10! short answer is i didn't i wrote my own battery bar! and here is how you can use it!

    Features
    Hide / Show
    Selectable Colors
    Static Color
    Auto-Magicaly Color (Low Med Reg Charge)
    Auto Detection of screen Width ( Bar works in Portrait and Landscape Mode )
    Selectable Height
    Charge Animation options.

    Screen Shots
    device-2011-12-01-213858.png


    Change Log
    Code:
    [B]Options App[/B]
    v2.0
    added height options.
    
    v3.0
    added new color dialogs.
    
    v4.0
    fixed default color of med level to be non-transparent.
    Code:
    [B]Battery Bar[/B]
    v2
    added height options and fixed default colors.


    How To!

    Ok so there are 2 files attached

    First is a Zip with the files needed to add to the SystemUI.apk (THIS IS NOT FLASHABLE)

    Second is an the Settings app for the Battery Bar.

    Step 1
    decompile your SystemUI.apk

    i use Apk Manager

    Step 2
    Navigate to smali\com\android\systemui\statusbar\ Folder
    Place the 3 Smali Files from the zip here
    BatteryBar.smali
    BatteryBar$1.smali
    BatteryBar$SettingsObserver.smali

    Step 3
    You need to Navigate to the res\layouts\ Folder
    open your statusbar.xml

    Step 4
    Underneath the line with

    Code:
    com.android.systemui.statusbar.DateView

    add this
    *** CHANGED ON v3 ***
    Code:
    <com.android.systemui.statusbar.BatteryBar android:textAppearance="@android:style/TextAppearance.StatusBar.Icon" android:gravity="center_vertical" android:orientation="horizontal" android:layout_width="wrap_content" [B][COLOR="Red"]android:layout_height="wrap_content"[/COLOR][/B] />


    it should be right at the bottom above the

    Code:

    i have added my statusbar.xml for reference if yours is in a different order no big deal just put it last and above this line
    Code:
    </com.android.systemui.statusbar.StatusBarView>


    Step 5
    Recompile the apk however you normaly would (there are so many ways i wont cover this here)
    then push it to your phone and reboot.

    If you don't know how or are having issues this is how I do it!

    Notes:
    a. i have a file on my desctop that i edit this is a copy of the file pulled from my phone.

    Steps:
    1. after all mods are done open up apk manager
    2. type 22 hit enter and pick the file you were editing ( SystemUI.apk )
    3. type 11 hit enter and the app will recompile.
    - 4. Open a copy of the SystemUI.apk ( see note a ) in winnra or 7zip ect put that window on one side of your screen ( windows 7 snap too (windows key + -> or <- ) is awesome for this )
    5. Navigate to the projects folder of APK Manager and then navigate to the app you edited (SystemUI.apk)
    6. Navigate to the /build/apk folder ( snap this to the other side of your screen ) ( Note that the build/apk folder has the same structure as the apk file open in winnra / 7zip )
    7. for THIS MOD only! you will need these files simply drag the 2 files listed below into the same folder location in the open apk in winnra / 7zip
    - /res/layouts/status_bar.xml
    - /classes.dex

    8. Push the apk that you draged the files into to your phone with adb like this

    adb push [where ever your apk is]/SystemUI.apk system/app/SystemUI.apk
    adb shell chmod 0644 system/app/SystemUI.apk

    9. whilst you have adb up reboot :)
    adb reboot
    + 4. Open a copy of the SystemUI.apk ( see note a ) in winnra or 7zip ect put that window on one side of your screen ( windows 7 snap too (windows key + -> or

    - 10. Proceed to next step
    -
    Step 6
    Once your status bar is back and running (you will have no battery bar yet)
    Simply install "BatteryBarSettings.apk" then open the app and pick your settings!

    Thats it ( I think )!

    all i ask is you don't modify the about section of the app if you choose to use it! and give credits where credits due. feel free to change my dodgy icon and if anyone has a better one ;) i will also put the sources for the settings app up on my git when i get git back up ( and when i tidy up and add comments ) and running in the next few days so that those of you running on source versions can cook it in from scratch. ( i don't think i need to explain how to do that if you are compiling sources i think you'll know what to do )
    Vissit My Git to have a Look


    with some help i can probably port this to older android versions (<2.3) as needed but i dont have access to a rom to test it on currently. so if you can help me there let me know :D

    Hope you found this helpfull! Let me know if this is not clear enough!

    Q&A
    Q: I am getting a FC on this or that, can you help me!
    A: NO. We can't help you. Because what you just said means nothing to us.
    We want to help you SO much, but in order to do that you need to report the bug properly.
    We took care of that too, see here:
    http://xdaforums.com/showthread.php?t=1292625

    Q:OMG YOU STOLE MY WORK! YOU A!@#$!% etc etc etc
    A: I kindly ask you that if you have an issue with anything above to PM me so i can sort it out politely. There is no need to flame in the thread.

    Pvy


    Credits
    Color Picker
    http://xdaforums.com/showthread.php?p=10739805#post10739805
    Thanks to Devmil

    19
    [APP] or [MOD] Battery Bar for All ROMs - Updated 16/1/12

    Hiding the battery Icons on your beloved ROM's
    tested on 2.3.* ROMS (Stock ROMS, AOSP, CM, MIUI) may sork on others aswell but 2.2 and below have a different process.

    for anyone who understands this stuff a bit this code here is what i edited for our TEAM ROM. this is hiding with an option from an app that sets a "global" setting.
    look in the statusbarpolicy.smali
    i commented the part with "hide battery icon";


    For everyone else what you will need to do is,

    1. Decompile your SystemUI.apk
    2. Open /smali/com/android/systemui/statusbar/StatusBarPolicy.smali
    3. Find the UpdateBattery function.
    this can be a long way down.
    just do a search for "battery" and you will find it eventually.

    Option A - Lock out the battery icon forever!

    basicaly to perma hide the icon add this to the start of the update battery function after the bit that looks like this.

    Code:
    Code:
    .locals 12
    .parameter "intent"
    
    .prologue

    add this!

    Code:
    Code:
    iget-object v1, p0, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->mService:Landroid/app/StatusBarManager;
    
    const-string v2, "battery"
    
    const v0, 0x0
    
    invoke-virtual {v1, v2, v0}, Landroid/app/StatusBarManager;->setIconVisibility(Ljava/lang/String;Z)V
    return-void

    then recompile and push back to phone.

    If you don't know how or are having issues this is how I do it!

    Notes:
    a. i have a file on my desctop that i edit this is a copy of the file pulled from my phone.

    Steps:
    1. after all mods are done open up apk manager
    2. type 22 hit enter and pick the file you were editing ( SystemUI.apk )
    3. type 11 hit enter and the app will recompile.
    4. Open a copy of the SystemUI.apk ( see note a ) in winnra or 7zip ect put that window on one side of your screen ( windows 7 snap too (windows key + -> or <- ) is awesome for this )
    5. Navigate to the projects folder of APK Manager and then navigate to the app you edited (SystemUI.apk)
    6. Navigate to the /build/apk folder ( snap this to the other side of your screen ) ( Note that the build/apk folder has the same structure as the apk file open in winnra / 7zip )
    7. for THIS MOD only! you will need these files simply drag the 2 files listed below into the same folder location in the open apk in winnra / 7zip
    - /classes.dex

    8. Push the apk that you draged the files into to your phone with adb like this

    adb push [where ever your apk is]/SystemUI.apk system/app/SystemUI.apk
    adb shell chmod 0644 system/app/SystemUI.apk

    9. whilst you have adb up reboot
    adb reboot
    that will perma hide the battery icon

    Option B - Make it optional! ( my preferred way of doing things )

    basically the same process but with different code and an app to set the settings.
    i will add this soon and i will put the option to toggle into the BatteryBar settings app.

    Aaron.
    5
    Howdy Guys

    I built My Battery Bar into an app.

    grab it on the market. has all the same features without the need to mod it into system. am going to update the OP now :D

    https://market.android.com/details?id=com.pvy.batterybar

    Pvy.
    4
    Updated to V1.4

    Howdy All!

    Updated the "App Version" today with these changes!

    V1.4
    1. Fixed the height issues
    2. You can now set what ever height you like
    3. Fixed the issue with the bar not moving when the alignment is set
    4. removed the notification sound
    5. small code rewrite in the service

    Grab it in the OP or on the market :D

    Pvy.
    3
    I used & followed this tuto : http://youtu.be/YgWd0jsDtH0

    if I used the plain SystemUI from APKTool\SystemUI\dist , I get neverending FC. upon reboot, the status bar is simply gone and even the launcher's "Notifications" soft menu option doesn't make it appear. gotta reflash the ROM to set things straight & get the statusbar back.

    if I copy/paste "resources.arsc" from APKTool\SystemUI\build\apk into the fresh SystemUI I obtain in APKTool\SystemUI\dist, there are no FC and the status bar shows, but your top bar mod isn't present, not even when repeatedly checking/unchecking/rechecking "show battery bar" in your app.

    it doesn't take a rocket scientist to understand & follow your tutorial, so I believe that my problem comes from somewhere in the recompiling process...
    at work now, whenever I have 10min, I'll upload my systemUI apks

    OK my gimme 5 i'll edit the op with my full decompile/compile process

    EDIT*** all done. hope it is enough... i really had to think on how to word it all LOL!

    also the file in apktool/[apk name]/dist
    has no signatures and will not run (from memory)

    Pvy.