[HOW TO] 100% battery mod with stock percentage battery text

_alex74_

Recognized Themer
Nov 11, 2012
1,316
3,006
0
FVG
For you today a detalied tutorial x adding stock battery percentage over the stock kitkat battery:



First, you have to know how to push files and decompile apk, or even create a flashable x it. Tutorial is for advanced users, developers and themers
This thread is not intended to provide zips, due to various roms around, so a wrong flashable will maybe lead to a fc or loosing some mods, or better if someone will do it, i will add it on first post (if comfirmed working).... credits given;)

let's start with it:

U need SystemUI.apk of course, decompile it.

1. go to \res\values\arrays.xml
<array name="batterymeter_color_values">
<item>#ffff3300</item>
<item>#ffffffff</item>
<item>#ffffffff</item>
</array>
<integer-array name="batterymeter_bolt_points">
<item>130</item>
<item>-146</item>
<item>392</item>
<item>-146</item>
<item>201</item>
<item>259</item>
<item>442</item>
<item>259</item>
<item>10</item>
<item>783</item>
<item>157</item>
<item>334</item>
<item>0</item>
<item>334</item>
</integer-array>
here you can set colors of battery for various levels, i leaved red when less then 5%, and white for others.
Battery meter bolt pints builds the thunder when charging, so i made it bigger, copy all like above

2. go then to \res\values\colors.xml
<color name="batterymeter_frame_color">#ff999999</color>
<color name="batterymeter_charge_color">#ffffffff</color>
<color name="batterymeter_bolt_color">#f21eff00</color>
change above values as your likings, frame color is the grayed frame of the battery i have setted solid light grey insted of a semi trasparent stock, charge color tells you enough, no explanation needed
Bolt color is thunder color when charging, i putted a 95% trasparent green(u can put whatever color you like)

3. now focus on \res\values\dimens.xml
<dimen name="status_bar_battery_text_size">11.0dip</dimen>
<dimen name="battery_icon_width">11.66dip</dimen>
<dimen name="battery_icon_height">17.33dip</dimen>
<dimen name="battery_icon_bottom_margin">0.33000004dip</dimen>
<dimen name="status_bar_battery_text_marginStart">0.0dip</dimen>
first value it is text dimension, ignore it as i mod it in last step
second and third value is for battery dimension, i make it bigger as x screen to fit my bigger signal icon, u can do as x your needings
ignore fourth value(just copy paste it)
set last value to 0.0 as above

4. now open \res\values\strings.xml and find the string
<string name="status_bar_settings_battery_meter_format">%d</string>
modify is as above as it will remove percentage from battery text

5. last point go to \res\layout\status_bar.xml
<LinearLayout android:gravity="center" android: orientation="horizontal" android:id="@id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="fill_parent" android: paddingStart="2.0dip">
<include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="3.0dip" layout="@layout/signal_cluster_view" />
<TextView android:textSize="@dimen/status_bar_battery_text_size" android:textColor="#ffffffff" android:layout_gravity="center" android:id="@id/battery_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/status_bar_network_name_separator" android:importantForAccessibility="no" android:fontFamily="sans-serif" android:layout_marginStart="@dimen/status_bar_battery_text_marginStart" />
<com.android.systemui.BatteryMeterView android:id="@id/battery" android:layout_width="@dimen/battery_icon_width" android:layout_height="@dimen/battery_icon_height" android:layout_marginBottom="@dimen/battery_icon_bottom_margin" android:layout_marginStart="3.0dip" />
</LinearLayout>
and paste this:
<LinearLayout android:gravity="center" android: orientation="horizontal" android:id="@id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="fill_parent" android: paddingStart="2.0dip">
<include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="3.0dip" layout="@layout/signal_cluster_view" />
<com.android.systemui.BatteryMeterView android:id="@id/battery" android:layout_width="@dimen/battery_icon_width" android:layout_height="@dimen/battery_icon_height" android:layout_marginBottom="@dimen/battery_icon_bottom_margin" android:layout_marginStart="3.0dip" />
<TextView android:textSize="10.33dip" android:textStyle="bold" android:textColor="#ff000000" android:layout_marginStart="-12.0dip" android: paddingTop="1.0dip" android:id="@id/battery_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/status_bar_network_name_separator" android:importantForAccessibility="no" android:fontFamily="sans-serif" />
</LinearLayout>
in the textview content u can modify regarding your needings, text size,color, font and format.


Be Aware, for emoji reasons(otherwise above u will see emoji instead of code) remove the space in pasted text from :
android: orientation
android: paddingStart
android: paddingTop

Recompile it and it is done :D:D:D:D:D:D:D:D:D:D:D:D:D

Mod will work even u have applied imaged battery mod, so you can just add your preferred image battery

hope you enjoy.
Feel free to use this tutorial, it will work on other devices too , just some position corrections needed.
I will just ask credits, thanks.
 
Last edited:

thereassaad

Recognized Contributor
Aug 22, 2013
7,621
9,714
263
Bierut
S5 Rom?

uploading x you few zips. send links via PM as up.

report here if works as i will add on thread then(If S5 rom will open thread there :D )
Bro N2 Custom Rom everything from S5 rom & okay send me pm & will report here & im wait

Sent from my SM-G900F using Tapatalk

---------- Post added at 01:40 PM ---------- Previous post was at 01:12 PM ----------

Bro its working VR but when I put my on charging I got thats like on


& thats working


Sent from my SM-G900F using Tapatalk

---------- Post added at 01:47 PM ---------- Previous post was at 01:40 PM ----------

& this u edit mine one but the number of percentage its very big & same issues when charging


Sent from my SM-G900F using Tapatalk
 

_alex74_

Recognized Themer
Nov 11, 2012
1,316
3,006
0
FVG
Bro its working VR but when I put my on charging I got thats like on
yep i know this, i will work on it trying to add animation when charging

this u edit mine one but the number of percentage its very big

yep i'm aware even of this, will solve it easily i think.

btw during all normal live(from 99 to 1 percent is working), so small issue under work:D
 
  • Like
Reactions: thereassaad

_alex74_

Recognized Themer
Nov 11, 2012
1,316
3,006
0
FVG
Updated post with charging fix.

about not centered 100 percent number in battery has to think about it, as it is dinamix text and layouted from right not from center.
So small bug as u will kepp 100% just for a while :D:D:D

will try to fix in these days;)
 

rush9935

Senior Member
Nov 30, 2013
415
63
0
Quebec
B&W KK444 theme !!

Updated post with charging fix.

about not centered 100 percent number in battery has to think about it, as it is dinamix text and layouted from right not from center.
So small bug as u will kepp 100% just for a while :D:D:D

will try to fix in these days;)
Look _alex74_ the picture of you new KK444 theme ..can you fix the problem ( pop-up display )...:confused: