[MOD][GUIDE] Status Bar "on the fly" Battery MOD

Search This thread

Didact74

Senior Member
Sep 2, 2010
609
1,877
Lake Shore, MD
Time for another MOD :)

This guide is meant for DEVs who want to incorporate this MOD into their ROM. I will post up a flashable zip later but just know it will only be for Stock Deodexed Roms. Most people are running custom ROMs now so flashing this over one of them will break themes and things.

Always Nandroid before making or attempting to MOD your phone

What will this MOD do?
-This MOD will allow you to select up to 20 different icons to use for your battery.

So what, I can do this now with any one of my battery flashable zips, why do I need this?
-Because this MOD will let you make these changes immediately, on the fly, and with no flashing or rebooting needed. :)

This is a pretty involved MOD with lot of changes and file additions. I will do my best to remember everything but I make no promises. If you catch something I missed or are having issues with something just post it up in this thread and I will try to help you.

Big Thanks to DSA for letting me look through some of his stuff for implementation.!

With that said, lets begin........


First thing to mention is there is an attached zip file to this thread. In this ZIP you will find the files needed to get this MOD going. The files you need are located in folders within the zip. Each folder name describes where those files should be placed. If you encounter a message that says the file you are adding already exists, write over it with the new file. This includes new icons as well.

We will be working with two system files:
SystemUI.apk
SecSettings.apk

We will begin with SecSettings.apk

Once you have decompiled SecSettings, navigate to res/values/arrays

Add the following lines of code
Code:
<string-array name="battery_icon_entries">
        <item>Stock icon only</item>
        <item>Text only</item>
        <item>Icon with text</item>
        <item>Icon with centered text</item>
        <item>C Style</item>
        <item>Android</item>
        <item>Blueglass</item>
        <item>Castaway</item>
        <item>Chrysis</item>
        <item>Dark Blue HC</item>
        <item>Dark Blue Stock</item>
        <item>Green Glass</item>
        <item>Green HC</item>
        <item>Green Stock</item>
        <item>ICS Blue HC</item>
        <item>ICS Blue Stock</item>
        <item>Little Android</item>
        <item>Naddict</item>
        <item>Sense</item>
        <item>Hide</item>
    </string-array>
    <string-array name="battery_icon_values">
        <item>0</item>
        <item>1</item>
        <item>2</item>
        <item>3</item>
        <item>4</item>
        <item>11</item>
        <item>6</item>
        <item>7</item>
        <item>8</item>
        <item>9</item>
        <item>10</item>
        <item>-1</item>
        <item>-2</item>
        <item>-3</item>
        <item>-4</item>
        <item>-5</item>
        <item>-6</item>
        <item>-7</item>
        <item>-8</item>
        <item>-9</item>
    </string-array>

Navigate to res/values/strings and add the following lines of code
Code:
<string name="battery_icon_category">Battery icon options</string>
    <string name="battery_icon">Battery icon style</string>

Navigate to res/xml/display_settings.xml and add the following in RED. You will write over some code doing this.
Code:
<CheckBoxPreference android:title="@string/sub_lcd_auto_lock" android:key="sub_lcd_auto_lock" android:summary="@string/sub_lcd_auto_lock_summary" />
    <CheckBoxPreference android:title="@string/key_night_mode" android:key="key_night_mode" />
    <ListPreference android:persistent="false" android:entries="@array/key_backlight_entries" android:title="@string/key_backlight" android:key="key_backlight" android:widgetLayout="@layout/round_more_icon" android:entryValues="@array/key_backlight_values" />
    [COLOR="red"]<ListPreference android:persistent="false" android:entries="@array/touch_key_light_entries" android:title="@string/touch_key_light" android:key="touch_key_light" android:summary="@string/touch_key_light_summary" android:widgetLayout="@layout/round_more_icon" android:entryValues="@array/touch_key_light_values" />
	<CheckBoxPreference android:persistent="false" android:title="@string/display_saving" android:key="power_saving_mode" android:summary="@string/display_saving_mode_summary" />
    <CheckBoxPreference android:persistent="false" android:title="@string/notification_pulse_title" android:key="notification_pulse" />
    <PreferenceCategory android:title="@string/battery_icon_category" android:key="battery_icon_category">
        <ListPreference android:entries="@array/battery_icon_entries" android:title="@string/battery_icon" android:key="battery_icon_list" android:entryValues="@array/battery_icon_values" />
		<CheckBoxPreference android:persistent="false" android:title="@string/display_battery_percentage" android:key="display_battery_level" android:summary="@string/display_battery_percentage_summary" />
    </PreferenceCategory>
[/COLOR]</PreferenceScreen>

Navigate to smali/com/android/settings/DisplaySettings.smali and add the following lines in RED
Code:
.field private mAutoLockmode:Landroid/preference/CheckBoxPreference;

[COLOR="red"].field private mBatteryStyle:Landroid/preference/ListPreference;[/COLOR]

.field private mBrightness:Lcom/android/settings/BrightnessPreference;

Find ".method public onCreate(Landroid/os/Bundle;)V and add the following lines in RED
Code:
const-string v11, "font_size"

    invoke-virtual {p0, v11}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v11

    check-cast v11, Landroid/preference/ListPreference;

    iput-object v11, p0, Lcom/android/settings/DisplaySettings;->mFontSizePref:Landroid/preference/ListPreference;

    .line 394
    iget-object v11, p0, Lcom/android/settings/DisplaySettings;->mFontSizePref:Landroid/preference/ListPreference;

    invoke-virtual {v11, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V

    [COLOR="red"]const-string v11, "battery_icon_list"

    invoke-virtual {p0, v11}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v11

    check-cast v11, Landroid/preference/ListPreference;

    iput-object v11, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;

    const-string v11, "battery_icon_list"

    const/4 v12, 0x0

    invoke-static {v8, v11, v12}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v11

    iget-object v12, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;

    invoke-static {v11}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v11

    invoke-virtual {v12, v11}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V

    iget-object v12, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;

    invoke-virtual {v12, p0}, Landroid/preference/SwitchPreferenceScreen;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
[/COLOR]
    .line 396
    const-string v11, "display_battery_level"

    invoke-virtual {p0, v11}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v11

    check-cast v11, Landroid/preference/CheckBoxPreference;

    iput-object v11, p0, Lcom/android/settings/DisplaySettings;->mDisplayBatteryLevel:Landroid/preference/CheckBoxPreference;

    .line 398
    invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getActivity()Landroid/app/Activity;

Find ".method public onPreferenceChange(Landroid/preference/Preference;Ljava/lang/Object;)Z" and add the following lines in RED
Code:
const-string v2, "contextualpage_settings"

    invoke-virtual {v2, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

  [COLOR="red"]  if-eqz v0, :cond_10
[/COLOR]
    .line 1014
    check-cast p2, Ljava/lang/Boolean;

    invoke-virtual {p2}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v0

    if-eqz v0, :cond_c

Code:
const-string v1, "DisplaySettings"

    const-string v3, "CONTEXTUALPAGE_SWITCH_CHANGED changed = false"

    invoke-static {v1, v3}, Landroid/util/Log;->secD(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_7

    :cond_f
    move-wide v0, v4

    goto/16 :goto_3

    [COLOR="red"]:cond_10
    iget-object v1, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;

    if-ne p1, v1, :cond_1

    check-cast p2, Ljava/lang/String;

    invoke-static {p2}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/Integer;->intValue()I

    move-result v0

    invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    const-string v2, "battery_icon_list"

    invoke-static {v1, v2, v0}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

    goto/16 :goto_4
[/COLOR].end method

Thats it for SecSettings, recompile and push to /system/app. Make sure everything boots and you see your new selections in SystemSettings->display->Battery Icon selection. It will not be functional yet, but you should see it there.


SYSTEMUI.apk

Decompile SystemUI.apk and add all the new files if have not already done so.

Now recompile SystemUI.apk, delete the old SystemUI folder and decompile again creating a new SystemUI folder.

We do this step so the system can take all the new files we just added and generate new IDs for them. If you get errors compiling its probably because you forgot to add a file or a line of code......or i missed a step in this tutorial :). To verify tht the new IDs are there, simply navigate to res/values/public and search for one of the new files we just added like "stat_sys_battery_castaway". If you find it, you are good to proceed.

Navigate to res/values/ids and add the following files
Code:
<item type="id" name="battery_combo">false</item>
    <item type="id" name="battery_text_center">false</item>
    <item type="id" name="battery_text_only">false</item>
    <item type="id" name="battery_text_only_low">false</item>
    <item type="id" name="battery_text_only_plugged">false</item>
    <item type="id" name="battery_cluster">false</item>
    <item type="id" name="battery_notification">false</item>

Navigate to res/values/strings and add the following
Code:
<string name="battery_test">99</string>

Navigate to res/values/styles and add the following
Code:
</style>
    <style name="Battery_Offset">
        <item name="android:textSize">11.0dip</item>
        <item name="android:textStyle">bold</item>
        <item name="android:layout_gravity">bottom|left|center</item>
        <item name="android:paddingBottom">1.0dip</item>
        <item name="android:layout_marginRight">4.0dip</item>
        <item name="android:shadowColor">#ff000000</item>
        <item name="android:shadowDx">0.0</item>
        <item name="android:shadowDy">0.0</item>
        <item name="android:shadowRadius">2.5</item>
    </style>
    <style name="Battery_Center">
        <item name="android:textSize">9.0dip</item>
        <item name="android:textStyle">bold</item>
        <item name="android:layout_gravity">center</item>
        <item name="android:layout_marginRight">0.0dip</item>
        <item name="android:shadowColor">#ff000000</item>
        <item name="android:shadowDx">0.0</item>
        <item name="android:shadowDy">0.0</item>
        <item name="android:shadowRadius">2.5</item>
    </style>
    <style name="TextAppearance.StatusBar.BatteryTextOnly" parent="@*android:style/TextAppearance.StatusBar.Icon">
        <item name="android:textSize">16.0dip</item>
        <item name="android:textStyle">normal</item>
        <item name="android:textColor">@*android:color/holo_blue_light</item>
    </style>
    <style name="TextAppearance.StatusBar.BatteryTextOnly_Plugged" parent="@*android:style/TextAppearance.StatusBar.Icon">
        <item name="android:textSize">16.0dip</item>
        <item name="android:textStyle">normal</item>
        <item name="android:textColor">@*android:color/holo_green_light</item>
    </style>
    <style name="TextAppearance.StatusBar.BatteryTextOnly_Low" parent="@*android:style/TextAppearance.StatusBar.Icon">
        <item name="android:textSize">16.0dip</item>
        <item name="android:textStyle">normal</item>
        <item name="android:textColor">@*android:color/holo_red_light</item>
    </style>

Navigate to smali/com/android/systemui/statusbar/phone/PhoneStatusBar.smali

Find "method protected makeStatusBarView()Lcom/android/systemui/statusbar/phone/PhoneStatusBar;" and REMOVE the lines in RED
Code:
new-instance v9, Lcom/android/systemui/statusbar/policy/LocationController;

    iget-object v10, p0, Lcom/android/systemui/SystemUI;->mContext:Landroid/content/Context;

    invoke-direct {v9, v10}, Lcom/android/systemui/statusbar/policy/LocationController;-><init>(Landroid/content/Context;)V

    iput-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mLocationController:Lcom/android/systemui/statusbar/policy/LocationController;

    .line 756
    [COLOR="Red"]new-instance v9, Lcom/android/systemui/statusbar/policy/BatteryController;

    iget-object v10, p0, Lcom/android/systemui/SystemUI;->mContext:Landroid/content/Context;

    invoke-direct {v9, v10}, Lcom/android/systemui/statusbar/policy/BatteryController;-><init>(Landroid/content/Context;)V

    iput-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;

    .line 757
    iget-object v10, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;

    iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarView:Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;

    const v11, 0x7f0d003c

    invoke-virtual {v9, v11}, Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;->findViewById(I)Landroid/view/View;

    move-result-object v9

    check-cast v9, Landroid/widget/ImageView;

    invoke-virtual {v10, v9}, Lcom/android/systemui/statusbar/policy/BatteryController;->addIconView(Landroid/widget/ImageView;)V
[/COLOR]
    .line 760
    sget-boolean v9, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->useTouchWizGUI:Z

    if-eqz v9, :cond_5

    .line 761
    iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarView:Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;

    const v10, 0x7f0d00af

    invoke-virtual {v9, v10}, Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;->findViewById(I)Landroid/view/View;

    move-result-object v9

    check-cast v9, Landroid/widget/TextView;

    iput-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText:Landroid/widget/TextView;

    .line 762
   [COLOR="red"] iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
[/COLOR]
    iget-object v10, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText:Landroid/widget/TextView;

  [COLOR="red"]  invoke-virtual {v9, v10}, Lcom/android/systemui/statusbar/policy/BatteryController;->addLabelView(Landroid/widget/TextView;)V
[/COLOR]
    .line 764
    iget-object v9, p0, Lcom/android/systemui/SystemUI;->mContext:Landroid/content/Context;

    invoke-virtual {v9}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v9

    const-string v10, "display_battery_percentage"

    invoke-static {v10}, Landroid/provider/Settings$System;->getUriFor(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v10

    const/4 v11, 0x0

Now for the really fun part :) Take a look at the six files in the zip in the folder named SystemUI_smali_com_android_systemui_statusbar_policy
There are two files in this folder we will concentrate on
-BatteryController.smali
-BatteryControllerNotification.smali


Here is what we are going to do. We need to go through both files and find all the System ID's. These can be identified by looking for the
Code:
0x7fxxxxx

We need to find all these IDs and verify or change them to the correct IDs found in your res/values/public. Why? Because you just added over 3000 new files to your SystemUI.apk and there is no telling exactly what IDs were assigned to them without verifying it first. If you used the IDs in my files and one was different, the MOD would fail.

So here is how to do this. First you will notice I have done half the legwork for you by naming what each ID is in my files. So when you are searching for IDs you will see somethin like this
Code:
const v8, 0x7f0a001c    #status_bar_settings_battery_meter_format

The "0x7f0a001c" is the ID and the "#status_bar_settings_battery_meter_format"is the name associated with the ID.

What you will do is open one of the two files at a time as well as open your public.xml file so you have both files available in your editor. Find each ID, copy the description beside it (without the hashtag) and search for this description in your public.xml file. Verify the ID is the same and if its not change it to the correct one. You have to do this for all IDs in both of those files. Take your time and go slow, if you miss one or copy one wrong the MOD will fail.


Thats it! You can recompile files and push to /system/app. enjoy the MOD!!


Please dont forget to buy me a coke or hit the thanks button!

Keep an eye out for more MODs soon!
 

Attachments

  • Battery_Mod.zip
    6.3 MB · Views: 1,881
Last edited:

sbreen94

Inactive Recognized Developer / Contributor
Apr 18, 2012
5,292
22,656
Holy ballz you are an absolute machine!!!!! thanks again didact
 

gruesomewolf

Senior Member
Jan 30, 2011
4,428
8,515
Mocksville, NC
This is awesome.....only thing I can see is the lines I had to delete in smali were located in "PhoneStatusBar" not PhoneStatusBarView". Other then that this is a great tut. :victory:
 

tu3218

Senior Member
Apr 14, 2009
3,413
368
awesome mod man!! incredible. Can't wait to see this implemented into some roms around here.
 

upndwn4par

Inactive Recognized Developer
Jan 22, 2012
3,640
10,375
New Jersey
Thanks again!

Is your goal to be in the credits of every single SGS3 ROM thread?

Because you're getting pretty close.

P.S. Love the sig!
 

Didact74

Senior Member
Sep 2, 2010
609
1,877
Lake Shore, MD
This is awesome.....only thing I can see is the lines I had to delete in smali were located in "PhoneStatusBar" not PhoneStatusBarView". Other then that this is a great tut. :victory:

You are correct sir. I will fix that now.

awesome mod man!! incredible. Can't wait to see this implemented into some roms around here.

Free to the masses!

Thanks again!

Is your goal to be in the credits of every single SGS3 ROM thread?

Because you're getting pretty close.

P.S. Love the sig!

LOL....not my goal but I love that everyone enjoys the MODs.
 
  • Like
Reactions: rompnit

kdizzleh85

Senior Member
Jun 25, 2012
1,298
686
Seattle
The s3 is hands down the best phone and has an awesome array of top notch developers. Thanks for all the hard work man. Lots of great stuff. This will be awesome.
 

Naddict

Senior Member
Nov 23, 2011
8,510
13,862
28.2S, 92.1W
Naddict Battery? :confused::silly::victory:


Must be an awesome mod to include such an awesome battery... ;)

cute-dog-performing-salsa-dance_zps14d84925.gif
 
  • Like
Reactions: rompnit

Top Liked Posts

  • There are no posts matching your filters.
  • 77
    Time for another MOD :)

    This guide is meant for DEVs who want to incorporate this MOD into their ROM. I will post up a flashable zip later but just know it will only be for Stock Deodexed Roms. Most people are running custom ROMs now so flashing this over one of them will break themes and things.

    Always Nandroid before making or attempting to MOD your phone

    What will this MOD do?
    -This MOD will allow you to select up to 20 different icons to use for your battery.

    So what, I can do this now with any one of my battery flashable zips, why do I need this?
    -Because this MOD will let you make these changes immediately, on the fly, and with no flashing or rebooting needed. :)

    This is a pretty involved MOD with lot of changes and file additions. I will do my best to remember everything but I make no promises. If you catch something I missed or are having issues with something just post it up in this thread and I will try to help you.

    Big Thanks to DSA for letting me look through some of his stuff for implementation.!

    With that said, lets begin........


    First thing to mention is there is an attached zip file to this thread. In this ZIP you will find the files needed to get this MOD going. The files you need are located in folders within the zip. Each folder name describes where those files should be placed. If you encounter a message that says the file you are adding already exists, write over it with the new file. This includes new icons as well.

    We will be working with two system files:
    SystemUI.apk
    SecSettings.apk

    We will begin with SecSettings.apk

    Once you have decompiled SecSettings, navigate to res/values/arrays

    Add the following lines of code
    Code:
    <string-array name="battery_icon_entries">
            <item>Stock icon only</item>
            <item>Text only</item>
            <item>Icon with text</item>
            <item>Icon with centered text</item>
            <item>C Style</item>
            <item>Android</item>
            <item>Blueglass</item>
            <item>Castaway</item>
            <item>Chrysis</item>
            <item>Dark Blue HC</item>
            <item>Dark Blue Stock</item>
            <item>Green Glass</item>
            <item>Green HC</item>
            <item>Green Stock</item>
            <item>ICS Blue HC</item>
            <item>ICS Blue Stock</item>
            <item>Little Android</item>
            <item>Naddict</item>
            <item>Sense</item>
            <item>Hide</item>
        </string-array>
        <string-array name="battery_icon_values">
            <item>0</item>
            <item>1</item>
            <item>2</item>
            <item>3</item>
            <item>4</item>
            <item>11</item>
            <item>6</item>
            <item>7</item>
            <item>8</item>
            <item>9</item>
            <item>10</item>
            <item>-1</item>
            <item>-2</item>
            <item>-3</item>
            <item>-4</item>
            <item>-5</item>
            <item>-6</item>
            <item>-7</item>
            <item>-8</item>
            <item>-9</item>
        </string-array>

    Navigate to res/values/strings and add the following lines of code
    Code:
    <string name="battery_icon_category">Battery icon options</string>
        <string name="battery_icon">Battery icon style</string>

    Navigate to res/xml/display_settings.xml and add the following in RED. You will write over some code doing this.
    Code:
    <CheckBoxPreference android:title="@string/sub_lcd_auto_lock" android:key="sub_lcd_auto_lock" android:summary="@string/sub_lcd_auto_lock_summary" />
        <CheckBoxPreference android:title="@string/key_night_mode" android:key="key_night_mode" />
        <ListPreference android:persistent="false" android:entries="@array/key_backlight_entries" android:title="@string/key_backlight" android:key="key_backlight" android:widgetLayout="@layout/round_more_icon" android:entryValues="@array/key_backlight_values" />
        [COLOR="red"]<ListPreference android:persistent="false" android:entries="@array/touch_key_light_entries" android:title="@string/touch_key_light" android:key="touch_key_light" android:summary="@string/touch_key_light_summary" android:widgetLayout="@layout/round_more_icon" android:entryValues="@array/touch_key_light_values" />
    	<CheckBoxPreference android:persistent="false" android:title="@string/display_saving" android:key="power_saving_mode" android:summary="@string/display_saving_mode_summary" />
        <CheckBoxPreference android:persistent="false" android:title="@string/notification_pulse_title" android:key="notification_pulse" />
        <PreferenceCategory android:title="@string/battery_icon_category" android:key="battery_icon_category">
            <ListPreference android:entries="@array/battery_icon_entries" android:title="@string/battery_icon" android:key="battery_icon_list" android:entryValues="@array/battery_icon_values" />
    		<CheckBoxPreference android:persistent="false" android:title="@string/display_battery_percentage" android:key="display_battery_level" android:summary="@string/display_battery_percentage_summary" />
        </PreferenceCategory>
    [/COLOR]</PreferenceScreen>

    Navigate to smali/com/android/settings/DisplaySettings.smali and add the following lines in RED
    Code:
    .field private mAutoLockmode:Landroid/preference/CheckBoxPreference;
    
    [COLOR="red"].field private mBatteryStyle:Landroid/preference/ListPreference;[/COLOR]
    
    .field private mBrightness:Lcom/android/settings/BrightnessPreference;

    Find ".method public onCreate(Landroid/os/Bundle;)V and add the following lines in RED
    Code:
    const-string v11, "font_size"
    
        invoke-virtual {p0, v11}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
    
        move-result-object v11
    
        check-cast v11, Landroid/preference/ListPreference;
    
        iput-object v11, p0, Lcom/android/settings/DisplaySettings;->mFontSizePref:Landroid/preference/ListPreference;
    
        .line 394
        iget-object v11, p0, Lcom/android/settings/DisplaySettings;->mFontSizePref:Landroid/preference/ListPreference;
    
        invoke-virtual {v11, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
    
        [COLOR="red"]const-string v11, "battery_icon_list"
    
        invoke-virtual {p0, v11}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
    
        move-result-object v11
    
        check-cast v11, Landroid/preference/ListPreference;
    
        iput-object v11, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;
    
        const-string v11, "battery_icon_list"
    
        const/4 v12, 0x0
    
        invoke-static {v8, v11, v12}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
    
        move-result v11
    
        iget-object v12, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;
    
        invoke-static {v11}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;
    
        move-result-object v11
    
        invoke-virtual {v12, v11}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V
    
        iget-object v12, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;
    
        invoke-virtual {v12, p0}, Landroid/preference/SwitchPreferenceScreen;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
    [/COLOR]
        .line 396
        const-string v11, "display_battery_level"
    
        invoke-virtual {p0, v11}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
    
        move-result-object v11
    
        check-cast v11, Landroid/preference/CheckBoxPreference;
    
        iput-object v11, p0, Lcom/android/settings/DisplaySettings;->mDisplayBatteryLevel:Landroid/preference/CheckBoxPreference;
    
        .line 398
        invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getActivity()Landroid/app/Activity;

    Find ".method public onPreferenceChange(Landroid/preference/Preference;Ljava/lang/Object;)Z" and add the following lines in RED
    Code:
    const-string v2, "contextualpage_settings"
    
        invoke-virtual {v2, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
    
        move-result v0
    
      [COLOR="red"]  if-eqz v0, :cond_10
    [/COLOR]
        .line 1014
        check-cast p2, Ljava/lang/Boolean;
    
        invoke-virtual {p2}, Ljava/lang/Boolean;->booleanValue()Z
    
        move-result v0
    
        if-eqz v0, :cond_c

    Code:
    const-string v1, "DisplaySettings"
    
        const-string v3, "CONTEXTUALPAGE_SWITCH_CHANGED changed = false"
    
        invoke-static {v1, v3}, Landroid/util/Log;->secD(Ljava/lang/String;Ljava/lang/String;)I
    
        goto :goto_7
    
        :cond_f
        move-wide v0, v4
    
        goto/16 :goto_3
    
        [COLOR="red"]:cond_10
        iget-object v1, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;
    
        if-ne p1, v1, :cond_1
    
        check-cast p2, Ljava/lang/String;
    
        invoke-static {p2}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;
    
        move-result-object v1
    
        invoke-virtual {v1}, Ljava/lang/Integer;->intValue()I
    
        move-result v0
    
        invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getContentResolver()Landroid/content/ContentResolver;
    
        move-result-object v1
    
        const-string v2, "battery_icon_list"
    
        invoke-static {v1, v2, v0}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
    
        goto/16 :goto_4
    [/COLOR].end method

    Thats it for SecSettings, recompile and push to /system/app. Make sure everything boots and you see your new selections in SystemSettings->display->Battery Icon selection. It will not be functional yet, but you should see it there.


    SYSTEMUI.apk

    Decompile SystemUI.apk and add all the new files if have not already done so.

    Now recompile SystemUI.apk, delete the old SystemUI folder and decompile again creating a new SystemUI folder.

    We do this step so the system can take all the new files we just added and generate new IDs for them. If you get errors compiling its probably because you forgot to add a file or a line of code......or i missed a step in this tutorial :). To verify tht the new IDs are there, simply navigate to res/values/public and search for one of the new files we just added like "stat_sys_battery_castaway". If you find it, you are good to proceed.

    Navigate to res/values/ids and add the following files
    Code:
    <item type="id" name="battery_combo">false</item>
        <item type="id" name="battery_text_center">false</item>
        <item type="id" name="battery_text_only">false</item>
        <item type="id" name="battery_text_only_low">false</item>
        <item type="id" name="battery_text_only_plugged">false</item>
        <item type="id" name="battery_cluster">false</item>
        <item type="id" name="battery_notification">false</item>

    Navigate to res/values/strings and add the following
    Code:
    <string name="battery_test">99</string>

    Navigate to res/values/styles and add the following
    Code:
    </style>
        <style name="Battery_Offset">
            <item name="android:textSize">11.0dip</item>
            <item name="android:textStyle">bold</item>
            <item name="android:layout_gravity">bottom|left|center</item>
            <item name="android:paddingBottom">1.0dip</item>
            <item name="android:layout_marginRight">4.0dip</item>
            <item name="android:shadowColor">#ff000000</item>
            <item name="android:shadowDx">0.0</item>
            <item name="android:shadowDy">0.0</item>
            <item name="android:shadowRadius">2.5</item>
        </style>
        <style name="Battery_Center">
            <item name="android:textSize">9.0dip</item>
            <item name="android:textStyle">bold</item>
            <item name="android:layout_gravity">center</item>
            <item name="android:layout_marginRight">0.0dip</item>
            <item name="android:shadowColor">#ff000000</item>
            <item name="android:shadowDx">0.0</item>
            <item name="android:shadowDy">0.0</item>
            <item name="android:shadowRadius">2.5</item>
        </style>
        <style name="TextAppearance.StatusBar.BatteryTextOnly" parent="@*android:style/TextAppearance.StatusBar.Icon">
            <item name="android:textSize">16.0dip</item>
            <item name="android:textStyle">normal</item>
            <item name="android:textColor">@*android:color/holo_blue_light</item>
        </style>
        <style name="TextAppearance.StatusBar.BatteryTextOnly_Plugged" parent="@*android:style/TextAppearance.StatusBar.Icon">
            <item name="android:textSize">16.0dip</item>
            <item name="android:textStyle">normal</item>
            <item name="android:textColor">@*android:color/holo_green_light</item>
        </style>
        <style name="TextAppearance.StatusBar.BatteryTextOnly_Low" parent="@*android:style/TextAppearance.StatusBar.Icon">
            <item name="android:textSize">16.0dip</item>
            <item name="android:textStyle">normal</item>
            <item name="android:textColor">@*android:color/holo_red_light</item>
        </style>

    Navigate to smali/com/android/systemui/statusbar/phone/PhoneStatusBar.smali

    Find "method protected makeStatusBarView()Lcom/android/systemui/statusbar/phone/PhoneStatusBar;" and REMOVE the lines in RED
    Code:
    new-instance v9, Lcom/android/systemui/statusbar/policy/LocationController;
    
        iget-object v10, p0, Lcom/android/systemui/SystemUI;->mContext:Landroid/content/Context;
    
        invoke-direct {v9, v10}, Lcom/android/systemui/statusbar/policy/LocationController;-><init>(Landroid/content/Context;)V
    
        iput-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mLocationController:Lcom/android/systemui/statusbar/policy/LocationController;
    
        .line 756
        [COLOR="Red"]new-instance v9, Lcom/android/systemui/statusbar/policy/BatteryController;
    
        iget-object v10, p0, Lcom/android/systemui/SystemUI;->mContext:Landroid/content/Context;
    
        invoke-direct {v9, v10}, Lcom/android/systemui/statusbar/policy/BatteryController;-><init>(Landroid/content/Context;)V
    
        iput-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
    
        .line 757
        iget-object v10, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
    
        iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarView:Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;
    
        const v11, 0x7f0d003c
    
        invoke-virtual {v9, v11}, Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;->findViewById(I)Landroid/view/View;
    
        move-result-object v9
    
        check-cast v9, Landroid/widget/ImageView;
    
        invoke-virtual {v10, v9}, Lcom/android/systemui/statusbar/policy/BatteryController;->addIconView(Landroid/widget/ImageView;)V
    [/COLOR]
        .line 760
        sget-boolean v9, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->useTouchWizGUI:Z
    
        if-eqz v9, :cond_5
    
        .line 761
        iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarView:Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;
    
        const v10, 0x7f0d00af
    
        invoke-virtual {v9, v10}, Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;->findViewById(I)Landroid/view/View;
    
        move-result-object v9
    
        check-cast v9, Landroid/widget/TextView;
    
        iput-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText:Landroid/widget/TextView;
    
        .line 762
       [COLOR="red"] iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
    [/COLOR]
        iget-object v10, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText:Landroid/widget/TextView;
    
      [COLOR="red"]  invoke-virtual {v9, v10}, Lcom/android/systemui/statusbar/policy/BatteryController;->addLabelView(Landroid/widget/TextView;)V
    [/COLOR]
        .line 764
        iget-object v9, p0, Lcom/android/systemui/SystemUI;->mContext:Landroid/content/Context;
    
        invoke-virtual {v9}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;
    
        move-result-object v9
    
        const-string v10, "display_battery_percentage"
    
        invoke-static {v10}, Landroid/provider/Settings$System;->getUriFor(Ljava/lang/String;)Landroid/net/Uri;
    
        move-result-object v10
    
        const/4 v11, 0x0

    Now for the really fun part :) Take a look at the six files in the zip in the folder named SystemUI_smali_com_android_systemui_statusbar_policy
    There are two files in this folder we will concentrate on
    -BatteryController.smali
    -BatteryControllerNotification.smali


    Here is what we are going to do. We need to go through both files and find all the System ID's. These can be identified by looking for the
    Code:
    0x7fxxxxx

    We need to find all these IDs and verify or change them to the correct IDs found in your res/values/public. Why? Because you just added over 3000 new files to your SystemUI.apk and there is no telling exactly what IDs were assigned to them without verifying it first. If you used the IDs in my files and one was different, the MOD would fail.

    So here is how to do this. First you will notice I have done half the legwork for you by naming what each ID is in my files. So when you are searching for IDs you will see somethin like this
    Code:
    const v8, 0x7f0a001c    #status_bar_settings_battery_meter_format

    The "0x7f0a001c" is the ID and the "#status_bar_settings_battery_meter_format"is the name associated with the ID.

    What you will do is open one of the two files at a time as well as open your public.xml file so you have both files available in your editor. Find each ID, copy the description beside it (without the hashtag) and search for this description in your public.xml file. Verify the ID is the same and if its not change it to the correct one. You have to do this for all IDs in both of those files. Take your time and go slow, if you miss one or copy one wrong the MOD will fail.


    Thats it! You can recompile files and push to /system/app. enjoy the MOD!!


    Please dont forget to buy me a coke or hit the thanks button!

    Keep an eye out for more MODs soon!
    6
    I have a question for the last part where im looking for ".method public onPreferenceChange(Landroid/preference/Preference;Ljava/lang/ObjectZ"

    It's supposed to look like this
    invoke-virtual {v2, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_10 (This is the one supposed to change

    .line 1014
    check-cast p2, Ljava/lang/Boolean;

    invoke-virtual {p2}, Ljava/lang/Boolean;->booleanValue()Z

    But mine looks like this

    invoke-virtual {v2, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_8

    move-object v0, p2

    .line 981
    check-cast v0, Ljava/lang/String;

    Do i just make the change or will it be incorrect because of the line before and after are different.

    So for the "if-eqz v0, :cond_10" code, you need to use whatever :cond your new Battery code is located. If your last condition in the method is 7, then use 8. If its 9, then use 10. Also, it looks like your method is not using "p" registers which is why your moving the contents of p2 into v0 in this line " move-object v0, p2". So make sure anytime you see a "p" register being referenced directly, you will need to move the contents to v0 first. So if my code reads

    invoke-virtual {p2}, Ljava/lang/Boolean;->booleanValue()Z

    you would replace that with this

    move-object v0, p2
    invoke-virtual {v0}, Ljava/lang/Boolean;->booleanValue()Z
    4
    ur mods make my nipples hard every time!

    gratzi!

    Please be a woman....
    4
    Just for anyone doing this MOD. Attached below is a collection of the Icon's I used as well as a new set of xml's. The new charge.xml's are fancy with the icon's flipping back and forth from the % icon to the charge Icon. The digital icon's have a scrolling charge animation that are really cool. I renamed everything so you can just replace them with how this mod is implemented.

    Few other changes I made. to the style.xml

    <style name="Battery_Offset">
    <item name="android:textSize">15.0dip</item> <------ this size increase also looks nice
    <item name="android:textStyle">bold</item>
    <item name="android:layout_gravity">bottom|left|center</item>
    <item name="android:paddingTop">1.0dip</item> <---- changing this to top padding IMO makes it look better especially with the text size increase
    <item name="android:layout_marginRight">4.0dip</item>
    <item name="android:shadowColor">#ff000000</item>
    <item name="android:textColor">#ffffffff</item> <----- adding this allows you to control the color of the text, mine was always gray. even after changing the value in the tw_status_bar layout
    <item name="android:shadowDx">0.0</item>
    <item name="android:shadowDy">0.0</item>
    <item name="android:shadowRadius">3</item>
    </style>
    <style name="Battery_Center">
    <item name="android:textSize">11.0dip</item>
    <item name="android:textStyle">bold</item>
    <item name="android:layout_gravity">center</item>
    <item name="android:paddingTop">1.0dip</item>
    <item name="android:layout_marginRight">0.0dip</item>
    <item name="android:shadowColor">#ff000000</item>
    <item name="android:textColor">#ffffffff</item>
    <item name="android:shadowDx">0.0</item>
    <item name="android:shadowDy">0.0</item>
    <item name="android:shadowRadius">3</item>

    Thanks again to Didact74, this is yet again another great mod. Happy modding
    4
    I get a failed when flashing/ installing this... (Recovery TWRP)

    Sorry man, I have not posted up a flashable yet. The zip attached are files needed to manually code the MOD. I will try to get a flashable up soon.