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:
save all .xml files.
stat_sys_battery_charge.xml and also if you have zzz_stat_sys_battery_1.xml with this code:
PHP:
<?xml version="1.0" encoding="utf-8"?>
<level-list
xmlns:android="http://schemas.android.com/apk/res/android">
</level-list>
STEP 2
Go to res/values/arrays.xml and find config_statusBarIcons string array.
Here is mine:
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.**
Here is mine:
Code:
<string-array name="config_statusBarIcons">
[B]<item>battery</item>[/B]
<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>
[B]<item>phone_evdo_signal</item>
<item>phone_signal</item>[/B]
</string-array>
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:
* 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.
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" />
[B]<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" />[/B]
<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" />
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.
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:
* 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.
PHP:
<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" />
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
so change them with your codes.
Example;
Do same for 16 lines and save.
**We're done. Compile SystemUI.apk**
I wrote lines to make it easier for you to edit. It starts with
Code:
.line 99
const v0, 0xstat_sys_battery_charge_anim100
Example;
Code:
.line 99
const v0, 0x7f020092
**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..
Attachments
Last edited: