[One (M7) Themes and Apps] homeslice976:
So as you probably know by now, Android 4.4 came with a hidden feature in SystemUI to enable %battery within the battery icon when it's not charging. This can be accomplished by an app (credit to [MENTION=2100288]kroegerama[/MENTION]), an adb command, or a manual SystemUI smali edit (a quite easy one explained in this walkthrough). The problem is this text is the same color as the battery fill (white), making it useless until the battery is about 50% or less. I played around with the smali for a while and couldn't properly get the text to change colors (smali is certainly not my native tongue...), so I did it the old fashioned way. I changed it in source, built, and compared the results. With that, I'll show you how you can change the text color of the digits when %battery is enabled.

This tutorial will assume you have know how to use APKTool to decompile/recompile APKs while keeping their signatures in tact. There are walkthroughs that will show you how to accomplish this readily available. Method 1 will show you an easy way to change the color to black, and method 2 will show you how you can change things so you can set the text color to whatever you want, without having to figure out the java hex -> smali const equation (though if someone knows it I'm always loving to learn new things). This tutorial is for users on a DEODEXED ROM. If your ROM is odexed, it's probably easiest to deodex SystemUI, make the changes, then reodex ALWAYS HAVE A BACKUP READILY AVAILABLE IN CASE SOMETHING GOES WRONG!

Things you'll need:

APKTool

Notepad++

SystemUI.apk from your 4.4 ROM

Method 1 - an easy way to make the digits black.

1. Using APKTool, decompile SystemUI.apk

2. Open \smali\com\android\systemui\BatteryMeterView.smali in Notepad++

3. If you don't already have the white %battery enabled, enable it now. Find:

const-string v7, "status_bar_show_battery_percent"

const/4 v8, 0x0

and change 0x0 to 0x1

4. Now find:

iget-object v6, p0, Lcom/android/systemui/BatteryMeterView;->mTextPaint:Landroid/graphics/Paint;

const/4 v7, -0x1

and change "const/4 v7, -0x1" to "const/high16 v7, -0x100" (this is changing white (-0x1) to black (-0x100))

(Note: if you get an error regarding this line when recompiling, try "const/16 v7, -0x100" (without the "high". I know, where's the fun in that?))

4b. - Optional: If you'd like to change the font family, or make it bold, etc, you can do it here as well.

Search for:

const-string v6, "sans-serif-condensed"

const/4 v7, 0x0

"sans-serif-condensed" can be changed to "sans-serif" (or other families), and the result is slightly larger digits. The 0x0 is indicating it's normal style. Change this to 0x1 for Bold.

5. Save the changes and recompile the APK making sure to retain the original signature. Push back to /system/priv-app/ and set with RW/R/R permissions. Voila, now you have black text for your %battery

Method 2 - a few extra steps and a little more involved smali change, but will make it much easier to change the color to whatever you want once it's complete:

1. Using APKTool, decompile SystemUI.apk

2. Open \res\values\colors.xml

3. Under

<color name="batterymeter_bolt_color">#b2000000</color>

make a new line that reads

<color name="batterymeter_percent_color">#xxxxxxxx</color>

(where xxxxxxxx is an 8 digit hex color value - first 2 alpha, last 6 color):

4. Recompile the apk with the changes, preserving the signature

5. Decompile the new SystemUI that was just created

6. Open \res\values\public.xml and find:

<public type="color" name="batterymeter_percent_color" id="0x########" />

and write down/copy/take note of the 10 digit id number (0x########)

7. Open \smali\com\android\systemui\BatteryMeterView.smali in Notepad++

8. If you don't already have the white %battery enabled, enable it now. Find:

const-string v7, "status_bar_show_battery_percent"

const/4 v8, 0x0

and change 0x0 to 0x1

9. Now find:

iget-object v6, p0, Lcom/android/systemui/BatteryMeterView;->mTextPaint:Landroid/graphics/Paint;

const/4 v7, -0x1

invoke-virtual {v6, v7}, Landroid/graphics/Paint;->setColor(I)V

and replace it with the following, changing the id (0x########) with the one you previously made a note of:

iget-object v6, p0, Lcom/android/systemui/BatteryMeterView;->mTextPaint:Landroid/graphics/Paint;

const v7, 0x########

invoke-virtual {v5, v7}, Landroid/content/res/Resources;->getColor(I)I

move-result v7

invoke-virtual {v6, v7}, Landroid/graphics/Paint;->setColor(I)V

9b - Optional: If you'd like to change the font family, or make it bold, etc, you can do it here as well.

Directly under the code you just pasted, you'll see

const-string v6, "sans-serif-condensed"

const/4 v7, 0x0

"sans-serif-condensed" can be changed to "sans-serif" (or other families), and the result is slightly larger digits. The 0x0 is indicating it's normal style. Change this to 0x1 for Bold.

10. Save the changes and recompile the APK making sure to retain the original signature. Push back to /system/priv-app/ and set with RW/R/R permissions

Now if you want to change the color, just change the HEX value in \res\values\colors.xml and recompile :)

Building from source?

Method 1 when building from source:

-Open \frameworks\base\packages\SystemUI\src\com\android\systemui\BatteryMeterView.java.

-On line 191 you can turn the %battery on and off

-On line 208 you can set the %color.

Method 2 from source:

-Open \frameworks\base\packages\SystemUI\src\com\android\systemui\BatteryMeterView.java.

-On line 191 you can turn the %battery on and off, and on line 208 change (0xFF000000) to (res.getColor(R.color.batterymeter_percent_color)).

-Now open \frameworks\base\packages\SystemUI\res\values\colors.xml and add a line under "#B2000000" that reads "#XXXXXXXX" (where XXXXXXXX is your hex color value).

Happy Modding! :good: