Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

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

OP Erhany

2nd January 2014, 03:35 PM   |  #1  
Erhany's Avatar
OP Senior Member
Flag com/erhany
Thanks Meter: 986
 
443 posts
Join Date:Joined: Feb 2012
Donate to Me
More
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, 581 views)
Last edited by Erhany; 2nd January 2014 at 03:38 PM.
The Following 23 Users Say Thank You to Erhany For This Useful Post: [ View ]
3rd January 2014, 06:39 PM   |  #2  
rastigo's Avatar
Senior Member
Flag Pune
Thanks Meter: 1,134
 
883 posts
Join Date:Joined: Apr 2013
More
Quote:
Originally Posted by Erhany

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: [ View ]
11th January 2014, 04:10 AM   |  #3  
Senior Member
Thanks Meter: 25
 
190 posts
Join Date:Joined: 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:	851
Size:	151.2 KB
ID:	2507837  
12th January 2014, 12:25 AM   |  #4  
alextheboss96's Avatar
Senior Member
Flag Athens
Thanks Meter: 151
 
139 posts
Join Date:Joined: Oct 2012
Donate to Me
pal you made it!!!
you deserve a medal! seriously!
The Following User Says Thank You to alextheboss96 For This Useful Post: [ View ]
13th January 2014, 12:59 AM   |  #5  
Senior Member
Thanks Meter: 25
 
190 posts
Join Date:Joined: Jul 2012
Quote:
Originally Posted by alextheboss96

pal you made it!!!
you deserve a medal! seriously!

No bro, I am nothing. Erhany deserves a medal. Hehe. Thanks btw.
13th January 2014, 03:29 PM   |  #6  
shoeseat's Avatar
Senior Member
Thanks Meter: 57
 
321 posts
Join Date:Joined: 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).
21st January 2014, 03:25 AM   |  #7  
Aciong.Aksaya's Avatar
Senior Member
Flag Mandaluyong
Thanks Meter: 164
 
454 posts
Join Date:Joined: Aug 2012
More
@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.
4th February 2014, 11:45 AM   |  #8  
Senior Member
Flag athens
Thanks Meter: 17
 
197 posts
Join Date:Joined: May 2012
Quote:
Originally Posted by zgmfx20

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
5th February 2014, 04:03 AM   |  #9  
Senior Member
Thanks Meter: 25
 
190 posts
Join Date:Joined: Jul 2012
Quote:
Originally Posted by petros11

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, 152 views)
The Following 2 Users Say Thank You to zgmfx20 For This Useful Post: [ View ]
1st June 2014, 03:37 AM   |  #10  
Junior Member
Flag Rizal
Thanks Meter: 10
 
9 posts
Join Date:Joined: Apr 2014
More
Wink
thanks to this guide sir
Attached Thumbnails
Click image for larger version

Name:	hiwalay na cla.png
Views:	197
Size:	132.5 KB
ID:	2773901  
Last edited by dendenXD; 1st June 2014 at 03:50 AM.

The Following User Says Thank You to dendenXD For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Tags
2.3 (gingerbread), battery, battery 100%, percent, tutorial
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes