[Sony Cross-Device General] Ticklefish:
(***NOW UPDATED WITH CHARGING ICONS!!****)​

** THIS GUIDE IS FOR STOCK XPERIA KITKAT ROMS

ONLY

. IF YOU'RE ON A KK ROM THAT ISN'T MADE BY SONY, LOOK AT MY FRIEND [MENTION=4485836]Erhany[/MENTION]'S GUIDE HERE: http://xdaforums.com/showpost.php?p=56300485&postcount=1 **

Changing the battery icon on a stock KitKat rom isn't easy. Google have changed how the icon is created and it's no longer possible to just change some icons and a few xml files.

Or is it?

Sony have put their own spin on KitKat and, if you've got an official stock Xperia 4.4 rom, you can still change the icon very easily. You just have to do something a little different to before..

How To Do It

So this is what the stock icon looks like:

It's okay..but we wouldn't be here if we weren't the sort who liked to change things.

First, you'll need to decompile your SystemUI.apk.

I'm not going to tell you how to do that, there's lots of guides already on xda. Although I do recommend taking a look at Tickle My Android (tinyurl.com/ticklemyandroid). It's made by a very good friend of mine.. :D

You're also going to need four types of tiles:

a lot of files called 'stat_sys_battery_100.png', 'stat_sys_battery_99.png', 'stat_sys_battery_98.png', etc

a lot of files called 'stat_sys_battery_charge_anim100.png', 'stat_sys_battery_charge_anim99.png, 'stat_sys_battery_charge_anim98.png, etc

a file called 'stat_sys_battery.xml'

and a file called 'stat_sys_battery_charge.xml'

You'll find those all over xda as well. I've attached the ones I've used in this post, just so you can try them out.

Adding The Images

You'll need to copy those image files into your 'drawable-?dpi' folder. This will vary according to your device, on my XZ it's 'drawable-xxhdpi'.

This will give Android images to use as your battery icon.

Then comes the fun part.

Editing The XML

Normally, you'll copy 'stat_sys_battery.xml' and 'stat_sys_battery_charge.xml' into your drawable folder, overwriting the files that are already there.

There is no 'stat_sys_battery.xml' or 'stat_sys_battery_charge.xml' in KitKat.

Instead, rename 'stat_sys_battery.xml' to 'somc_sys_battery.xml'. And rename 'stat_sys_battery_charge.xml to 'somc_sys_charging.xml'. Then copy them into your drawable folder.

This will tell Android which images to use for each amount of charge in the battery.

Now edit status_bar.xml and change this piece of code:

<LinearLayout android:id="@id/battery" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginStart="4.0dip">
<ImageView android:layout_gravity="center_vertical" android:id="@id/status" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<LinearLayout android:id="@id/battery_meter" android:layout_width="wrap_content" android:layout_height="fill_parent">
<ImageView android:layout_gravity="center_vertical" android:id="@id/battery_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageView android:layout_gravity="center_vertical" android:id="@id/stamina_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/somc_sys_powersaver" />
</LinearLayout>
<FrameLayout android:id="@id/battery_percent" android:layout_width="wrap_content" android:layout_height="fill_parent">
<com.sonymobile.systemui.statusbar.BatteryImage android:layout_gravity="start|center" android:id="@id/battery_percent_bg" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</FrameLayout>
</LinearLayout>

to:

<LinearLayout android:id="@id/battery" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginStart="4.0dip">
<LinearLayout android:id="@id/battery_meter" android:layout_width="wrap_content" android:layout_height="fill_parent">
<ImageView android:layout_gravity="center_vertical" android:id="@id/status" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageView android:layout_gravity="center_vertical" android:id="@id/battery_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageView android:layout_gravity="center_vertical" android:id="@id/stamina_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/somc_sys_powersaver" />
</LinearLayout>
<FrameLayout android:id="@id/battery_percent" android:layout_width="wrap_content" android:layout_height="fill_parent">
<com.sonymobile.systemui.statusbar.BatteryImage android:layout_gravity="start|center" android:id="@id/battery_percent_bg" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</FrameLayout>
</LinearLayout>

This will place the charging icon next to the battery icon, inside the @id/battery_meter Layout. This will cause the charging icon to vanish if you turn on the percentage option in the Settings app.

We're nearly there..

Editing The Smali

Now comes the really fun part. It's time to edit some smali!

For this part, we need to do some detective work. Open your 'res/values/public.xml' and find these two lines:

They might be next to each other...or they might not.

The parts in red are the hex references that we're going to need to look for in our smali. It's likely the references will be different in your rom to mine.

Edit 'com\android\systemui\statusbar\policy\BatteryController.smali' and look for your 'somc_sys_charging' reference. The code you'll find should look like this:

You'll want to change this so it looks like this:

Make sure you change the code in red to your own reference!

This will make Android change the charging icon when the battery level changes.

Then look for your 'somc_sys_battery' reference. The code you'll find should look like this:

Change it to:

Again, make sure you change the code in red to your own reference!

This will make the battery icon vanish when your phone's charging.

Now just save, recompile and push to your device as normal. Wait a while for it to reboot and...

[YOUTUBE]40JHdeoWROE[/YOUTUBE] [YOUTUBE]xZJEyo_BkAk[/YOUTUBE]

(You'll also need to disable the battery percentage in the Settings app, if you haven't already.)

Of course, these aren't perhaps the best icons I could have chosen for these screenshots. I didn't have much time for this post, I just picked some at random and it looks a little lost. But that's the fun of battery icons..there are so many to choose from! :cool:

**HUGE Thanks Go To The Master, [MENTION=3989065]serajr[/MENTION], For The Smali Help!**

**Thanks also go to [mention=4561595]krzycho96[/mention] for their YouTube video**​