Post Reply

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

10th February 2013, 12:02 AM   |  #1  
Didact74's Avatar
OP Recognized Developer / Recognized Contributor
Flag Lake Shore, MD
Thanks Meter: 1,851
 
609 posts
Join Date:Joined: Sep 2010
Donate to Me
More
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" />
    <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>
</PreferenceScreen>


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

.field private mBatteryStyle:Landroid/preference/ListPreference;

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


Find ".method public onCreate(Landroid/os/BundleV 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

    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

    .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/ObjectZ" 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

    if-eqz v0, :cond_10

    .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

    :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
.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
    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

    .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
    iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;

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

    invoke-virtual {v9, v10}, Lcom/android/systemui/statusbar/policy/BatteryController;->addLabelView(Landroid/widget/TextView;)V

    .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_poli cy
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!
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2013-02-09-15-23-07[1].jpg
Views:	5894
Size:	27.2 KB
ID:	1716557   Click image for larger version

Name:	Screenshot_2013-02-09-15-23-02[1].jpg
Views:	4230
Size:	27.1 KB
ID:	1716558  
Attached Files
File Type: zip Battery_Mod.zip - [Click for QR Code] (6.26 MB, 1415 views)
Last edited by Didact74; 12th February 2013 at 04:07 AM.
The Following 77 Users Say Thank You to Didact74 For This Useful Post: [ View ]
10th February 2013, 12:05 AM   |  #2  
rompnit's Avatar
Recognized Contributor / Themer
Flag Granger, IN
Thanks Meter: 17,026
 
2,810 posts
Join Date:Joined: Aug 2008
Donate to Me
More
First! Another awesome mod!! Thanks!
10th February 2013, 12:05 AM   |  #3  
sbreen94's Avatar
Recognized Contributor / Recognized Developer
Thanks Meter: 18,131
 
4,489 posts
Join Date:Joined: Apr 2012
Donate to Me
More
Holy ballz you are an absolute machine!!!!! thanks again didact
10th February 2013, 12:06 AM   |  #4  
SoCalSpecialist's Avatar
Senior Member
Flag San Diego
Thanks Meter: 532
 
2,875 posts
Join Date:Joined: Jan 2009
More
ur mods make my nipples hard every time!

gratzi!
The Following User Says Thank You to SoCalSpecialist For This Useful Post: [ View ]
10th February 2013, 12:18 AM   |  #5  
Didact74's Avatar
OP Recognized Developer / Recognized Contributor
Flag Lake Shore, MD
Thanks Meter: 1,851
 
609 posts
Join Date:Joined: Sep 2010
Donate to Me
More
Quote:
Originally Posted by SoCalSpecialist

ur mods make my nipples hard every time!

gratzi!

Please be a woman....
The Following 3 Users Say Thank You to Didact74 For This Useful Post: [ View ]
10th February 2013, 12:32 AM   |  #6  
SoCalSpecialist's Avatar
Senior Member
Flag San Diego
Thanks Meter: 532
 
2,875 posts
Join Date:Joined: Jan 2009
More
Quote:
Originally Posted by Didact74

Please be a woman....

hahahaha...

thats a negative ghost rider
10th February 2013, 05:58 AM   |  #7  
Droid2drummer's Avatar
Senior Member
Thanks Meter: 168
 
573 posts
Join Date:Joined: Nov 2012
Re: [MOD][GUIDE] Status Bar "on the fly" Battery MOD
Quote:
Originally Posted by Didact74

Please be a woman....

Lmmfao

Sent from my SCH-I535 using xda premium
10th February 2013, 09:23 AM   |  #8  
jonathanphx1's Avatar
Senior Member
Thanks Meter: 971
 
1,210 posts
Join Date:Joined: Apr 2010
Donate to Me
More
fIXED
Last edited by jonathanphx1; 10th February 2013 at 02:08 PM.
11th February 2013, 09:56 PM   |  #9  
Kryten2k35's Avatar
Recognized Contributor
Flag Bradford
Thanks Meter: 11,160
 
7,377 posts
Join Date:Joined: Jan 2011
Donate to Me
More
Can you expand this to that it affects the VideoPlayer too?
12th February 2013, 12:30 AM   |  #10  
Didact74's Avatar
OP Recognized Developer / Recognized Contributor
Flag Lake Shore, MD
Thanks Meter: 1,851
 
609 posts
Join Date:Joined: Sep 2010
Donate to Me
More
Quote:
Originally Posted by Kryten2k35

Can you expand this to that it affects the VideoPlayer too?

LOL...baby steps.....

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Verizon Galaxy S III Android Development by ThreadRank