5,599,033 Members 31,590 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
pvyParts
Old
(Last edited by pvyParts; 12th July 2012 at 12:50 AM.)
#1  
pvyParts's Avatar
Recognized Developer - OP
Thanks Meter 2278
Posts: 1,792
Join Date: Oct 2010
Default [MOD] Battery Bar for All ROMs - Updated 31/3/12


MOD Version

App Version Here - http://forum.xda-developers.com/show....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


Change Log
Code:
Options App
v2.0
added height options.

v3.0
added new color dialogs.

v4.0
fixed default color of med level to be non-transparent.
Code:
Battery Bar
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.

Quote:
Step 1
decompile your SystemUI.apk

i use Apk Manager
Quote:
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
Quote:
Step 3
You need to Navigate to the res\layouts\ Folder
open your statusbar.xml
Quote:
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" android:layout_height="wrap_content" />

it should be right at the bottom above the

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>

Quote:
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
-
Quote:
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

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

Q&A
Quote:
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://forum.xda-developers.com/show....php?t=1292625
Quote:
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://forum.xda-developers.com/show...5#post10739805
Thanks to Devmil

The Following 111 Users Say Thank You to pvyParts For This Useful Post: [ Click to Expand ]
 
pvyParts
Old
(Last edited by pvyParts; 12th April 2012 at 02:12 AM.)
#2  
pvyParts's Avatar
Recognized Developer - OP
Thanks Meter 2278
Posts: 1,792
Join Date: Oct 2010
Lightbulb [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.

Quote:
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.
The Following 16 Users Say Thank You to pvyParts For This Useful Post: [ Click to Expand ]
 
Mjergen
Old
#3  
Mjergen's Avatar
Junior Member
Thanks Meter 2
Posts: 12
Join Date: Nov 2010
hi there ; tried it on a SGS2 with the latest CM nightly and then with CheckROM 3.1.1 -- didn't work. no serious hang nor crash, just...nothing happens (I've done the decompiling and recompiling with APKTool)
The Following 2 Users Say Thank You to Mjergen For This Useful Post: [ Click to Expand ]
 
Scratch0805
Old
#4  
Scratch0805's Avatar
Senior Member
Thanks Meter 1193
Posts: 2,046
Join Date: Jun 2011
Location: Sheffield
Worked perfect, Thanks.

Sent from my HTC Wildfire using xda premium

My Devices
Samsung Galaxy S2
Asus Nexus 7
Samsung Galaxy Tab 7
Samsung Galaxy Note N7000
2 x Samsung Galaxy Ace 5380i's
HTC Wildfire

mycolourscreen

My Dropbox
 
pvyParts
Old
#5  
pvyParts's Avatar
Recognized Developer - OP
Thanks Meter 2278
Posts: 1,792
Join Date: Oct 2010
Quote:
Originally Posted by Mjergen View Post
hi there ; tried it on a SGS2 with the latest CM nightly and then with CheckROM 3.1.1 -- didn't work. no serious hang nor crash, just...nothing happens (I've done the decompiling and recompiling with APKTool)
It has to be enabled from the app. Did you turn it on?

Pvy

Sent from my TEAM powered x10
The Following User Says Thank You to pvyParts For This Useful Post: [ Click to Expand ]
 
Mjergen
Old
#6  
Mjergen's Avatar
Junior Member
Thanks Meter 2
Posts: 12
Join Date: Nov 2010
Quote:
Originally Posted by pvyParts View Post
It has to be enabled from the app. Did you turn it on?
sure, I installed the app and when first running the app, the "activate" box was already ticked. un-ticking and ticking it again did not help either :-l
 
pvyParts
Old
(Last edited by pvyParts; 1st December 2011 at 11:13 PM.) Reason: typos
#7  
pvyParts's Avatar
Recognized Developer - OP
Thanks Meter 2278
Posts: 1,792
Join Date: Oct 2010
Quote:
Originally Posted by Mjergen View Post
sure, I installed the app and when first running the app, the "activate" box was already ticked. un-ticking and ticking it again did not help either :-l
Doesn't cm have it'd own bar? could be fighting.

Any chance of sending me your systemui and maybe grabbing some logs at boot and when you change the settings.

Pvy

Sent from my TEAM powered x10
The Following User Says Thank You to pvyParts For This Useful Post: [ Click to Expand ]
 
Mjergen
Old
(Last edited by Mjergen; 2nd December 2011 at 06:36 AM.)
#8  
Mjergen's Avatar
Junior Member
Thanks Meter 2
Posts: 12
Join Date: Nov 2010
Quote:
Originally Posted by pvyParts View Post
Doesn't cm have it'd own bar? could be fighting.
well I thought it had it, hence me flashing it, but apparently not. either that or it's really really ... really well hidden. neither the latest SGS2 nightly (116), nor the stable rls (7.1) seem to have the top bar. i flashed the stable CM 7.1 yesterday evening and didn't apply your mod to the stable version just yet. gonna try that today and keep you posted (i'm in Czech, GMT+1, if you're australian, we might have quite the time difference here ).
what I'll do is i'll send you the unaltered systemui from the stable CM7.1 AND the same systemui with your mod, if that's okay with you ?
what is your method of choice for decompiling and recompiling, btw ?

Quote:
Originally Posted by pvyParts View Post
Any chance of sending me your systemui and maybe grabbing some logs at boot and when you change the settings.
sure thing, i'll do as I said hereabove. also, which logs, pre- or post-mod ?
 
Ditamae
Old
#9  
Ditamae's Avatar
Senior Member
Thanks Meter 173
Posts: 821
Join Date: Oct 2010
Location: Portland
Hey there. First, thank you so much for this.

I apologize for the noob question, but I've never decompiled an apk before, but I'm eager to learn.

I used apkTool to unpack SystemUI.apk, and then added the files per your instructions, and then repacked. I then pushed SystemUI.apk to /system/app and rebooted. Upon reboot the status bar didn't work at all. When I looked at the apk itself it says "Parse error: There is a problem parsing the package."

I'm assuming I've not recompiled properly. I've attached the apkTool version I used. Perhaps I've some made obvious error? Any help you could provide would be much appreciated! I'll try again and see what happens in the meantime.
Attached Files
File Type: zip apkTools.zip - [Click for QR Code] (5.28 MB, 207 views)

Samsung Galaxy SIII (SGH-T999) in titanium gray | Slim Bean v4.2.2 | TWRP Recovery Touch v2.6.0.0 themed with Halo by thecoby
with Apex by dennisxl | Ember theme by Sonny Sekhon

HTC Vision | Andromadus Mimicry v1.5.0 with V6 Supercharger | 4EXT Recovery Touch v1.0.0.5 custom themed
radio_26.13.04.19 with matching rils | eng hboot_0.84.2000
 
pvyParts
Old
#10  
pvyParts's Avatar
Recognized Developer - OP
Thanks Meter 2278
Posts: 1,792
Join Date: Oct 2010
Quote:
Originally Posted by Mjergen View Post
well I thought it had it, hence me flashing it, but apparently not. either that or it's really really ... really well hidden. neither the latest SGS2 nightly (116), nor the stable rls (7.1) seem to have the top bar. i flashed the stable CM 7.1 yesterday evening and didn't apply your mod to the stable version just yet. gonna try that today and keep you posted (i'm in Czech, GMT+1, if you're australian, we might have quite the time difference here ).
what I'll do is i'll send you the unaltered systemui from the stable CM7.1 AND the same systemui with your mod, if that's okay with you ?
what is your method of choice for decompiling and recompiling, btw ?



sure thing, i'll do as I said hereabove. also, which logs, pre- or post-mod ?
Quote:
Originally Posted by Ditamae View Post
Hey there. First, thank you so much for this.

I apologize for the noob question, but I've never decompiled an apk before, but I'm eager to learn.

I used apkTool to unpack SystemUI.apk, and then added the files per your instructions, and then repacked. I then pushed SystemUI.apk to /system/app and rebooted. Upon reboot the status bar didn't work at all. When I looked at the apk itself it says "Parse error: There is a problem parsing the package."

I'm assuming I've not recompiled properly. I've attached the apkTool version I used. Perhaps I've some made obvious error? Any help you could provide would be much appreciated! I'll try again and see what happens in the meantime.
I use APK Manager v5

then drag/ drop updated files into the apks. to replace the old ones.

i cant find a decent guide atm but i know there is one.

Pvy

The Following User Says Thank You to pvyParts For This Useful Post: [ Click to Expand ]
Tags
awesome, bar, battery, miui, pvyparts
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes