Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,777,785 Members 46,763 Now Online
XDA Developers Android and Mobile Development Forum

[GB SPECIAL][GUIDE][2.Jan.14] Add BatteryText% to Left of Battery.JB levels! Final.

Tip us?
 
Erhany
Old
(Last edited by Erhany; 2nd January 2014 at 02:38 PM.)
#1  
Erhany's Avatar
Senior Member - OP
Thanks Meter 949
Posts: 429
Join Date: Feb 2012
Location: com/erhany

 
DONATE TO ME
Arrow [GB SPECIAL][GUIDE][2.Jan.14] Add BatteryText% to Left of Battery.JB levels! Final.

Signal Icon - BatteryText% - Battery Icon

Hello guys. Welcome to my another topic about battery percentage. I had a lot of PM for putting it to left of battery icon like ICS, JB bla bla.. So here is the final. An alternative way. Special for Gingerbread.

TUTORIAL

->>framework-res.apk<<-

STEP 1
 
Decompile framework-res.apk >> Go to res/drawable folder and edit stat_sys_battery.xml
stat_sys_battery_charge.xml and also if you have zzz_stat_sys_battery_1.xml with this code:

PHP Code:
<?xml version="1.0" encoding="utf-8"?>
<level-list
  xmlns:android="http://schemas.android.com/apk/res/android">
</level-list>
save all .xml files.

STEP 2
 
Go to res/values/arrays.xml and find config_statusBarIcons string array.
Here is mine:
Code:
<string-array name="config_statusBarIcons">
        <item>battery</item>
	<item>alarm_clock</item>
        <item>secure</item>
        <item>clock</item>
	<item>ime</item>
        <item>sync_failing</item>
        <item>sync_active</item>
        <item>gps</item>
        <item>bluetooth</item>
        <item>nfc</item>
        <item>tty</item>
        <item>hac</item>
        <item>speakerphone</item>
        <item>mute</item>
        <item>volume</item>
        <item>wifi</item>
        <item>cdma_eri</item>
        <item>data_connection</item>
        <item>phone_evdo_signal</item>
        <item>phone_signal</item>
        </string-array>
LOGIC: In here we try to put percentage to right of signal icon and we make invisible stock battery icon.
So normally battery, alarm bla bla items were after phone_signal and I moved them to first.
Basicly move to top what you have after phone_signal and put battery item to top.
And then save.

**We're done with framework-res.apk so compile apk.**

->>SystemUI.apk<<-

STEP 3
 
Decompile SystemUI.apk >> go to res/layout/status_bar.xml and add <com.erhany.BatteryLine.. after @id/statusIcons.
It will look like that:
Code:
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/statusIcons" android:paddingRight="6.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentRight="true" />
        <com.erhany.BatteryLine android:textSize="14.0sp" android:gravity="left|center" android:paddingRight="6.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" android:drawablePadding="4.0dip" android:layout_marginLeft="-4.0dip" />
        <com.android.systemui.statusbar.Clock android:textAppearance="@*android:style/TextAppearance.StatusBar.Icon" 
android:textColor="#ffffffff" android:gravity="left|center" android:paddingRight="6.0dip"
android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" />
* This textSize and layout_margin is tested on HDPI device. You may need to change dips after modding done if you have a MDPI device.

STEP 4
 
Download attachment. You will have 16 .png icons and 2 .smali files.Here is patience step.
C[opy smali files into smali/com/erhany folder. ( First, create erhany folder inside com/ )
Copy icons into drawable-hdpi folder.

*MDPI users need to copy into drawable-mdpi folder but you must find mdpi icons first. It may look bigger if you use hdpi icons. Not tested on mdpi.

STEP 5 - The patience!
 
Go to res/values/public.xml and add these lines:
PHP Code:
<public type="drawable" name="stat_sys_battery_0" id="0x7f020083" />
    <public 
type="drawable" name="stat_sys_battery_15" id="0x7f020084" />
    <public 
type="drawable" name="stat_sys_battery_28" id="0x7f020085" />
    <public 
type="drawable" name="stat_sys_battery_43" id="0x7f020086" />
    <public 
type="drawable" name="stat_sys_battery_57" id="0x7f020087" />
    <public 
type="drawable" name="stat_sys_battery_71" id="0x7f020088" />
    <public 
type="drawable" name="stat_sys_battery_85" id="0x7f020089" />
    <public 
type="drawable" name="stat_sys_battery_100" id="0x7f02008a" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim0" id="0x7f02008b" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim15" id="0x7f02008c" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim28" id="0x7f02008d" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim43" id="0x7f02008e" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim57" id="0x7f02008f" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim71" id="0x7f020090" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim85" id="0x7f020091" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim100" id="0x7f020092" /> 
* Don't use my id codes. Find last drawable code and change manually all. (1-9 .. a-f..)
My last drawable was id="0x7f020082" so continued ..83,..84,..85.. Change and save it.

STEP 6
 
Go to com/erhany/BatteryLine.smali and open it,
I wrote lines to make it easier for you to edit. It starts with
Code:
.line 99
    const v0, 0xstat_sys_battery_charge_anim100
so change them with your codes.
Example;
Code:
.line 99
const v0, 0x7f020092
Do same for 16 lines and save.

**We're done. Compile SystemUI.apk**

* apks are ready to push to system. Enjoy your new look!
------------------------------------------

>>> Answers to some questions <<<
- Why don't we use stock battery icons?
- Stock SystemUI uses id/statusIcons, I checked statusbarPolicy.java for icons, so we can use any drawable between signal and battery icon but can not put battery% there.

-Why 16 .png icons?
- JB 4.3 uses these icons for level-list. I did same levels & drawables like original. Here is code from original:
Code:
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:maxLevel="4" android:drawable="@drawable/stat_sys_battery_0" />
    <item android:maxLevel="15" android:drawable="@drawable/stat_sys_battery_15" />
    <item android:maxLevel="35" android:drawable="@drawable/stat_sys_battery_28" />
    <item android:maxLevel="49" android:drawable="@drawable/stat_sys_battery_43" />
    <item android:maxLevel="60" android:drawable="@drawable/stat_sys_battery_57" />
    <item android:maxLevel="75" android:drawable="@drawable/stat_sys_battery_71" />
    <item android:maxLevel="90" android:drawable="@drawable/stat_sys_battery_85" />
    <item android:maxLevel="100" android:drawable="@drawable/stat_sys_battery_100" />
</level-list>
-Text turned "red" from "white". Why?
- I changed textColor if level < 15 from white to red. Just a colored mod :)

-Used "hdpi" icons. Only for HDPI?
- No!. I have a hdpi device. For other resolutions put drawables into your related folders and test it. You know pixels are different on hdpi/mdpi etc. so statusbar fits it otomatically.

For other questions just reply to topic.
If you like my work, please hit thanx and donate me!
Happy moddings..
Attached Files
File Type: zip Erhany-BatteryLine.zip - [Click for QR Code] (18.4 KB, 450 views)
Liked or Helped ?, please HIT 'Thanks' Button !

GB SPECIAL! BatteryText% with JB Battery!! signal-%-battery!



Current Device : Xperia arc (LT15i) Current Rom: Stock .587 (ICS)

The Following 21 Users Say Thank You to Erhany For This Useful Post: [ Click to Expand ]
 
rastigo
Old
#2  
rastigo's Avatar
Senior Member
Thanks Meter 577
Posts: 774
Join Date: Apr 2013
Location: Pune
Quote:
Originally Posted by Erhany View Post
Signal Icon - BatteryText% - Battery Icon

Hello guys. Welcome to my another topic about battery percentage. I had a lot of PM for putting it to left of battery icon like ICS, JB bla bla.. So here is the final. An alternative way. Special for Gingerbread.

TUTORIAL

->>framework-res.apk<<-

STEP 1
 
Decompile framework-res.apk >> Go to res/drawable folder and edit stat_sys_battery.xml
stat_sys_battery_charge.xml and also if you have zzz_stat_sys_battery_1.xml with this code:

PHP Code:
<?xml version="1.0" encoding="utf-8"?>
<level-list
  xmlns:android="http://schemas.android.com/apk/res/android">
</level-list>
save all .xml files.

STEP 2
 
Go to res/values/arrays.xml and find config_statusBarIcons string array.
Here is mine:
Code:
<string-array name="config_statusBarIcons">
        <item>battery</item>
	<item>alarm_clock</item>
        <item>secure</item>
        <item>clock</item>
	<item>ime</item>
        <item>sync_failing</item>
        <item>sync_active</item>
        <item>gps</item>
        <item>bluetooth</item>
        <item>nfc</item>
        <item>tty</item>
        <item>hac</item>
        <item>speakerphone</item>
        <item>mute</item>
        <item>volume</item>
        <item>wifi</item>
        <item>cdma_eri</item>
        <item>data_connection</item>
        <item>phone_evdo_signal</item>
        <item>phone_signal</item>
        </string-array>
LOGIC: In here we try to put percentage to right of signal icon and we make invisible stock battery icon.
So normally battery, alarm bla bla items were after phone_signal and I moved them to first.
Basicly move to top what you have after phone_signal and put battery item to top.
And then save.

**We're done with framework-res.apk so compile apk.**

->>SystemUI.apk<<-

STEP 3
 
Decompile SystemUI.apk >> go to res/layout/status_bar.xml and add <com.erhany.BatteryLine.. after @id/statusIcons.
It will look like that:
Code:
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/statusIcons" android:paddingRight="6.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentRight="true" />
        <com.erhany.BatteryLine android:textSize="14.0sp" android:gravity="left|center" android:paddingRight="6.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" android:drawablePadding="4.0dip" android:layout_marginLeft="-4.0dip" />
        <com.android.systemui.statusbar.Clock android:textAppearance="@*android:style/TextAppearance.StatusBar.Icon" 
android:textColor="#ffffffff" android:gravity="left|center" android:paddingRight="6.0dip"
android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" />
* This textSize and layout_margin is tested on HDPI device. You may need to change dips after modding done if you have a MDPI device.

STEP 4
 
Download attachment. You will have 16 .png icons and 2 .smali files.Here is patience step.
C[opy smali files into smali/com/erhany folder. ( First, create erhany folder inside com/ )
Copy icons into drawable-hdpi folder.

*MDPI users need to copy into drawable-mdpi folder but you must find mdpi icons first. It may look bigger if you use hdpi icons. Not tested on mdpi.

STEP 5 - The patience!
 
Go to res/values/public.xml and add these lines:
PHP Code:
<public type="drawable" name="stat_sys_battery_0" id="0x7f020083" />
    <public 
type="drawable" name="stat_sys_battery_15" id="0x7f020084" />
    <public 
type="drawable" name="stat_sys_battery_28" id="0x7f020085" />
    <public 
type="drawable" name="stat_sys_battery_43" id="0x7f020086" />
    <public 
type="drawable" name="stat_sys_battery_57" id="0x7f020087" />
    <public 
type="drawable" name="stat_sys_battery_71" id="0x7f020088" />
    <public 
type="drawable" name="stat_sys_battery_85" id="0x7f020089" />
    <public 
type="drawable" name="stat_sys_battery_100" id="0x7f02008a" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim0" id="0x7f02008b" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim15" id="0x7f02008c" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim28" id="0x7f02008d" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim43" id="0x7f02008e" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim57" id="0x7f02008f" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim71" id="0x7f020090" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim85" id="0x7f020091" />
    <public 
type="drawable" name="stat_sys_battery_charge_anim100" id="0x7f020092" /> 
* Don't use my id codes. Find last drawable code and change manually all. (1-9 .. a-f..)
My last drawable was id="0x7f020082" so continued ..83,..84,..85.. Change and save it.

STEP 6
 
Go to com/erhany/BatteryLine.smali and open it,
I wrote lines to make it easier for you to edit. It starts with
Code:
.line 99
    const v0, 0xstat_sys_battery_charge_anim100
so change them with your codes.
Example;
Code:
.line 99
const v0, 0x7f020092
Do same for 16 lines and save.

**We're done. Compile SystemUI.apk**

* apks are ready to push to system. Enjoy your new look!
------------------------------------------

>>> Answers to some questions <<<
- Why don't we use stock battery icons?
- Stock SystemUI uses id/statusIcons, I checked statusbarPolicy.java for icons, so we can use any drawable between signal and battery icon but can not put battery% there.

-Why 16 .png icons?
- JB 4.3 uses these icons for level-list. I did same levels & drawables like original. Here is code from original:
Code:
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:maxLevel="4" android:drawable="@drawable/stat_sys_battery_0" />
    <item android:maxLevel="15" android:drawable="@drawable/stat_sys_battery_15" />
    <item android:maxLevel="35" android:drawable="@drawable/stat_sys_battery_28" />
    <item android:maxLevel="49" android:drawable="@drawable/stat_sys_battery_43" />
    <item android:maxLevel="60" android:drawable="@drawable/stat_sys_battery_57" />
    <item android:maxLevel="75" android:drawable="@drawable/stat_sys_battery_71" />
    <item android:maxLevel="90" android:drawable="@drawable/stat_sys_battery_85" />
    <item android:maxLevel="100" android:drawable="@drawable/stat_sys_battery_100" />
</level-list>
-Text turned "red" from "white". Why?
- I changed textColor if level < 15 from white to red. Just a colored mod

-Used "hdpi" icons. Only for HDPI?
- No!. I have a hdpi device. For other resolutions put drawables into your related folders and test it. You know pixels are different on hdpi/mdpi etc. so statusbar fits it otomatically.

For other questions just reply to topic.
If you like my work, please hit thanx and donate me!
Happy moddings..
i am getting bootloops after incoprating you your mod. something missed out Erhany...If you have a working systemui.apk pl upload...Thanks ...great work
The Following 2 Users Say Thank You to rastigo For This Useful Post: [ Click to Expand ]
 
zgmfx20
Old
#3  
Senior Member
Thanks Meter 25
Posts: 189
Join Date: Jul 2012
nice! I followed your tutorials but got no error. 2 mods in one. lol.
Thank you so d*mn much Erhany!

(credits also to Krisdee for the framework-res from NXT_r1)
Attached Thumbnails
Click image for larger version

Name:	screenshot_2014-01-11_1058.png
Views:	710
Size:	151.2 KB
ID:	2507837  
http://i.imgur.com/xtWNL.png
 
alextheboss96
Old
#4  
alextheboss96's Avatar
Senior Member
Thanks Meter 151
Posts: 139
Join Date: Oct 2012
Location: Athens
pal you made it!!!
you deserve a medal! seriously!
Device: Xperia Neo V
Rom: BRABUS NXT for NeoV
Kernel: Night-Elf Exp 10.1 lite

DONATE ANYTHING YOU AFFORD
I'M ONLY 17!

MY WORKS

The Following User Says Thank You to alextheboss96 For This Useful Post: [ Click to Expand ]
 
zgmfx20
Old
#5  
Senior Member
Thanks Meter 25
Posts: 189
Join Date: Jul 2012
Quote:
Originally Posted by alextheboss96 View Post
pal you made it!!!
you deserve a medal! seriously!
No bro, I am nothing. Erhany deserves a medal. Hehe. Thanks btw.
http://i.imgur.com/xtWNL.png
 
shoeseat
Old
#6  
shoeseat's Avatar
Senior Member
Thanks Meter 57
Posts: 321
Join Date: Jul 2012
While compiling systemUI i get this error.What am i missing?

I: Building resources...
D:\Android\apktool-install-windows-r05-ibot\SystemUI\res\values\public.xml:293:
error: Public resource drawable/stat_sys_battery_0 has conflicting type codes fo
r its public identifiers (0x2 vs 0xc).
D:\Android\apktool-install-windows-r05-ibot\SystemUI\res\values\public.xml:294:
error: Public resource drawable/stat_sys_battery_15 has conflicting type codes f
or its public identifiers (0x2 vs 0xc).
 
Aciong.Aksaya
Old
#7  
Aciong.Aksaya's Avatar
Senior Member
Thanks Meter 161
Posts: 449
Join Date: Aug 2012
Location: Mandaluyong
@Erhany you did a great job.

Just a question how will I reduce the font size of the battery percentage? Maybe about 50% smaller than on your screenshot.

If you think my post was helpful, please click the thanks button
 
petros11
Old
#8  
Senior Member
Thanks Meter 16
Posts: 193
Join Date: May 2012
Location: athens
Quote:
Originally Posted by zgmfx20 View Post
nice! I followed your tutorials but got no error. 2 mods in one. lol.
Thank you so d*mn much Erhany!

(credits also to Krisdee for the framework-res from NXT_r1)
Can you give me this system ui with a flashable zip?

Sent from my Xperia Arc S using xda app-developers app
 
zgmfx20
Old
#9  
Senior Member
Thanks Meter 25
Posts: 189
Join Date: Jul 2012
Quote:
Originally Posted by petros11 View Post
Can you give me this system ui with a flashable zip?

Sent from my Xperia Arc S using xda app-developers app
you also need framework-res in tandem to make it work. This will overwrite your framework-res. Here
Attached Files
File Type: zip Erhany Z1 battery.zip - [Click for QR Code] (4.82 MB, 120 views)
http://i.imgur.com/xtWNL.png
The Following 2 Users Say Thank You to zgmfx20 For This Useful Post: [ Click to Expand ]
 
dendenXD
Old
(Last edited by dendenXD; 1st June 2014 at 02:50 AM.)
#10  
Junior Member
Thanks Meter 4
Posts: 5
Join Date: Apr 2014
Location: Rizal
thanks to this guide sir
Attached Thumbnails
Click image for larger version

Name:	hiwalay na cla.png
Views:	143
Size:	132.5 KB
ID:	2773901  

The Following User Says Thank You to dendenXD For This Useful Post: [ Click to Expand ]
Tags
2.3 (gingerbread), battery, battery 100%, percent, tutorial
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes