What does this MOD do?
-Allows you to add the battery bar to your ROM with out any Add-On APKs
This is for DEVs to use to bake into their ROMs, its not a flashable ZIP. If you want this MOD and do not know how to do the work, look up my Multi-Mod with Rom Control and flash it or wait until a DEV bakes this into your favorite ROM.
This MOD is based on Verizon VRBMB1 JB 4.1.2. Any other carrier or ROM and you will probably have to do some tweaking.
Please hit the thanks button and give credit if you plan to use this. A donation of $100 is not required but its greatly appreciated :)
Lets get on with the TUT!
Disclaimer*** Always perform a Nandroid before making changes to your phone.
Disclaimer #2**** I can not promise this TUT is dead on balls but I will do my best. If you notice something I forgot or something that doesn't look right, let me know, I am only human after all.
We will be working with two files:
SystemUI.apk
SecSettings.apk
I will assume you are using my ROM control. If not you will have to extrapolate my smali settings in Rom control to blend into the file of your choice. Sorry, but I built Rom Control to keep things easy on me.
We will begin with SecSettings.
Navigate to res/xml/rom_settings.xml (if you're not using RomControl navigate to the file of your choice)
Place the following code where you like
Navigate to res/values/arrays
Place the following code there:
Navigate to res/values/strings
Place the following code there:
Navigate to smali/com/android/settings/didact/RomSettings.smali
Add the following in RED:
in method .method public onCreate(Landroid/os/Bundle;)V, add the following in RED:
Same method, add the following in RED
In method .method public onPreferenceChange(Landroid/preference/Preference;Ljava/lang/Object;)Z, add the following in RED:
In method .method public onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z, add the following in RED:
That's it for SecSettings, recompile and check the new options and toggles are there. Then move on to part two for SystemUI.
Part II SystemUI.apk
Find the attached zip file and place all files in smali/com/android/systemui/statusbar/policy
Navigate to res/layout/tw_statusbar
Add the following code in RED:
Navigate to res/values/attrs
Add the following code there:
That's it, recompile and enjoy. Thanks button!
-Allows you to add the battery bar to your ROM with out any Add-On APKs
This is for DEVs to use to bake into their ROMs, its not a flashable ZIP. If you want this MOD and do not know how to do the work, look up my Multi-Mod with Rom Control and flash it or wait until a DEV bakes this into your favorite ROM.
This MOD is based on Verizon VRBMB1 JB 4.1.2. Any other carrier or ROM and you will probably have to do some tweaking.
Please hit the thanks button and give credit if you plan to use this. A donation of $100 is not required but its greatly appreciated :)
Lets get on with the TUT!
Disclaimer*** Always perform a Nandroid before making changes to your phone.
Disclaimer #2**** I can not promise this TUT is dead on balls but I will do my best. If you notice something I forgot or something that doesn't look right, let me know, I am only human after all.
We will be working with two files:
SystemUI.apk
SecSettings.apk
I will assume you are using my ROM control. If not you will have to extrapolate my smali settings in Rom control to blend into the file of your choice. Sorry, but I built Rom Control to keep things easy on me.
We will begin with SecSettings.
Navigate to res/xml/rom_settings.xml (if you're not using RomControl navigate to the file of your choice)
Place the following code where you like
Code:
<ListPreference android:entries="@array/battery_bar_entries" android:title="@string/battery_bar" android:key="battery_bar" android:entryValues="@array/battery_bar_values" />
<com.didact.colorpicker.ColorPickerPreference android:title="@string/battery_bar_color" android:key="battery_bar_color" android:defaultValue="@*android:color/holo_blue_light" alphaSlider="true" />
<ListPreference android:entries="@array/battery_bar_style_entries" android:title="@string/battery_bar_style_title" android:key="battery_bar_style" android:entryValues="@array/battery_bar_style_values" />
<ListPreference android:entries="@array/battery_bar_thickness_entries" android:title="@string/battery_bar_thickness_title" android:key="battery_bar_thickness" android:entryValues="@array/battery_bar_thickness_values" />
<CheckBoxPreference android:title="@string/battery_bar_animate_title" android:key="battery_bar_animate" android:summary="@string/battery_bar_animate_summary" />
Navigate to res/values/arrays
Place the following code there:
Code:
<string-array name="battery_bar_entries">
<item>Hide</item>
<item>Show</item>
</string-array>
<string-array name="battery_bar_values">
<item>0</item>
<item>1</item>
</string-array>
<string-array name="battery_bar_style_entries">
<item>Regular</item>
<item>Center-mirrored</item>
</string-array>
<string-array name="battery_bar_style_values">
<item>0</item>
<item>1</item>
</string-array>
<string-array name="battery_bar_thickness_entries">
<item>1 dp</item>
<item>2 dp</item>
<item>3 dp</item>
<item>4 dp</item>
</string-array>
<string-array name="battery_bar_thickness_values">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
</string-array>
Navigate to res/values/strings
Place the following code there:
Code:
<string name="battery_bar">Enable battery bar</string>
<string name="battery_bar_color">Choose battery bar color</string>
<string name="battery_bar_style_title">Battery bar style</string>
<string name="battery_bar_thickness_title">Battery Bar Thickness</string>
<string name="battery_bar_animate_title">Battery Bar Animation</string>
<string name="battery_bar_animate_summary">Animate bar when charging</string>
<string name="battery_bar_summary">%s</string>
<string name="battery_bar_color_summary">Bar color</string>
<string name="battery_bar_style_title_summary">%s</string>
<string name="battery_bar_thickness_title_summary">%s</string>
Navigate to smali/com/android/settings/didact/RomSettings.smali
Add the following in RED:
Code:
# instance fields
.field mAospLockVibration:Landroid/preference/CheckBoxPreference;
.field mBatteryBarAnimate:Landroid/preference/CheckBoxPreference;
.field mBatteryBarColor:Lcom/didact/colorpicker/ColorPickerPreference;
.field mBatteryBarList:Landroid/preference/ListPreference;
.field mBatteryBarStyle:Landroid/preference/ListPreference;
.field mBatteryBarThickness:Landroid/preference/ListPreference;
.field mBatteryIcon:Landroid/preference/ListPreference;
.field mBatteryStyle:Landroid/preference/ListPreference;
.field mBrightnessSliderPreference:Landroid/preference/CheckBoxPreference;
in method .method public onCreate(Landroid/os/Bundle;)V, add the following in RED:
Code:
const-string v5, "long_press_kill"
invoke-static {v4, v5, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v4
invoke-static {v4}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;
move-result-object v4
invoke-virtual {v1, v4}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V
const-string v1, "battery_bar_style"
invoke-virtual {p0, v1}, Lcom/android/settings/didact/RomSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v1
check-cast v1, Landroid/preference/ListPreference;
iput-object v1, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarStyle:Landroid/preference/ListPreference;
iget-object v1, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarStyle:Landroid/preference/ListPreference;
invoke-virtual {v1, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
iget-object v1, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarStyle:Landroid/preference/ListPreference;
invoke-virtual {p0}, Lcom/android/settings/didact/RomSettings;->getActivity()Landroid/app/Activity;
move-result-object v4
invoke-virtual {v4}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v4
const-string v5, "battery_bar_style"
invoke-static {v4, v5, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v4
invoke-static {v4}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;
move-result-object v4
invoke-virtual {v1, v4}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V
const-string v1, "battery_bar"
invoke-virtual {p0, v1}, Lcom/android/settings/didact/RomSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v1
check-cast v1, Landroid/preference/ListPreference;
iput-object v1, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarList:Landroid/preference/ListPreference;
iget-object v1, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarList:Landroid/preference/ListPreference;
invoke-virtual {v1, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
iget-object v1, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarList:Landroid/preference/ListPreference;
invoke-virtual {p0}, Lcom/android/settings/didact/RomSettings;->getActivity()Landroid/app/Activity;
move-result-object v4
invoke-virtual {v4}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v4
const-string v5, "battery_bar"
invoke-static {v4, v5, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v4
invoke-static {v4}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;
move-result-object v4
invoke-virtual {v1, v4}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V
const-string v1, "battery_bar_thickness"
invoke-virtual {p0, v1}, Lcom/android/settings/didact/RomSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v1
check-cast v1, Landroid/preference/ListPreference;
iput-object v1, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarThickness:Landroid/preference/ListPreference;
iget-object v1, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarThickness:Landroid/preference/ListPreference;
invoke-virtual {v1, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
iget-object v1, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarThickness:Landroid/preference/ListPreference;
invoke-virtual {p0}, Lcom/android/settings/didact/RomSettings;->getActivity()Landroid/app/Activity;
move-result-object v4
invoke-virtual {v4}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v4
const-string v5, "battery_bar_thickness"
invoke-static {v4, v5, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v4
invoke-static {v4}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;
move-result-object v4
invoke-virtual {v1, v4}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V
const-string v1, "battery_bar_color"
invoke-virtual {p0, v1}, Lcom/android/settings/didact/RomSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v1
check-cast v1, Lcom/didact/colorpicker/ColorPickerPreference;
iput-object v1, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarColor:Lcom/didact/colorpicker/ColorPickerPreference;
iget-object v1, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarColor:Lcom/didact/colorpicker/ColorPickerPreference;
invoke-virtual {v1, p0}, Lcom/didact/colorpicker/ColorPickerPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
const-string v1, "statusbar_color"
invoke-virtual {p0, v1}, Lcom/android/settings/didact/RomSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v1
check-cast v1, Lcom/didact/colorpicker/ColorPickerPreference;
iput-object v1, p0, Lcom/android/settings/didact/RomSettings;->mStatusbarColor:Lcom/didact/colorpicker/ColorPickerPreference;
iget-object v1, p0, Lcom/android/settings/didact/RomSettings;->mStatusbarColor:Lcom/didact/colorpicker/ColorPickerPreference;
invoke-virtual {v1, p0}, Lcom/didact/colorpicker/ColorPickerPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
Same method, add the following in RED
Code:
const-string v1, "display_brightness_slider"
invoke-virtual {p0, v1}, Lcom/android/settings/didact/RomSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v1
check-cast v1, Landroid/preference/CheckBoxPreference;
iput-object v1, p0, Lcom/android/settings/didact/RomSettings;->mBrightnessSliderPreference:Landroid/preference/CheckBoxPreference;
iget-object v4, p0, Lcom/android/settings/didact/RomSettings;->mBrightnessSliderPreference:Landroid/preference/CheckBoxPreference;
invoke-virtual {p0}, Lcom/android/settings/didact/RomSettings;->getActivity()Landroid/app/Activity;
move-result-object v1
invoke-virtual {v1}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v1
const-string v5, "display_brightness_slider"
invoke-static {v1, v5, v3}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v1
if-ne v1, v2, :cond_5
move v1, v2
:goto_5
invoke-virtual {v4, v1}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V
const-string v1, "battery_bar_animate"
invoke-virtual {p0, v1}, Lcom/android/settings/didact/RomSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v1
check-cast v1, Landroid/preference/CheckBoxPreference;
iput-object v1, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarAnimate:Landroid/preference/CheckBoxPreference;
iget-object v4, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarAnimate:Landroid/preference/CheckBoxPreference;
invoke-virtual {p0}, Lcom/android/settings/didact/RomSettings;->getActivity()Landroid/app/Activity;
move-result-object v1
invoke-virtual {v1}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v1
const-string v5, "battery_bar_animate"
invoke-static {v1, v5, v3}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v1
if-ne v1, v2, :cond_6
move v1, v2
:goto_6
invoke-virtual {v4, v1}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V
return-void
:cond_0
move v1, v3
goto/16 :goto_0
:cond_1
move v1, v3
goto/16 :goto_1
:cond_2
move v1, v3
goto/16 :goto_2
:cond_3
move v1, v3
goto :goto_3
:cond_4
move v1, v3
goto :goto_4
:cond_5
move v1, v3
goto :goto_5
:cond_6
move v1, v3
goto :goto_6
.end method
In method .method public onPreferenceChange(Landroid/preference/Preference;Ljava/lang/Object;)Z, add the following in RED:
Code:
const-string v6, "long_press_kill"
invoke-static {v5, v6, v4}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
move-result v2
goto/16 :goto_0
:cond_9
iget-object v5, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarColor:Lcom/didact/colorpicker/ColorPickerPreference;
if-ne p1, v5, :cond_a
invoke-static {p2}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;
move-result-object v5
invoke-static {v5}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;
move-result-object v5
invoke-virtual {v5}, Ljava/lang/Integer;->intValue()I
move-result v5
invoke-static {v5}, Lcom/didact/colorpicker/ColorPickerPreference;->convertToARGB(I)Ljava/lang/String;
move-result-object v0
invoke-virtual {p1, v0}, Landroid/preference/Preference;->setSummary(Ljava/lang/CharSequence;)V
invoke-static {v0}, Lcom/didact/colorpicker/ColorPickerPreference;->convertToColorInt(Ljava/lang/String;)I
move-result v1
invoke-virtual {p0}, Lcom/android/settings/didact/RomSettings;->getActivity()Landroid/app/Activity;
move-result-object v5
invoke-virtual {v5}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v5
const-string v6, "battery_bar_color"
invoke-static {v5, v6, v1}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
goto/16 :goto_0
:cond_a
iget-object v5, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarList:Landroid/preference/ListPreference;
if-ne p1, v5, :cond_b
check-cast p2, Ljava/lang/String;
invoke-static {p2}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I
move-result v4
invoke-virtual {p0}, Lcom/android/settings/didact/RomSettings;->getActivity()Landroid/app/Activity;
move-result-object v5
invoke-virtual {v5}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v5
const-string v6, "battery_bar"
invoke-static {v5, v6, v4}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
move-result v2
goto/16 :goto_0
:cond_b
iget-object v5, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarStyle:Landroid/preference/ListPreference;
if-ne p1, v5, :cond_c
check-cast p2, Ljava/lang/String;
invoke-static {p2}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I
move-result v4
invoke-virtual {p0}, Lcom/android/settings/didact/RomSettings;->getActivity()Landroid/app/Activity;
move-result-object v5
invoke-virtual {v5}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v5
const-string v6, "battery_bar_style"
invoke-static {v5, v6, v4}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
move-result v2
goto/16 :goto_0
:cond_c
iget-object v5, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarThickness:Landroid/preference/ListPreference;
if-ne p1, v5, :cond_0
check-cast p2, Ljava/lang/String;
invoke-static {p2}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I
move-result v4
invoke-virtual {p0}, Lcom/android/settings/didact/RomSettings;->getActivity()Landroid/app/Activity;
move-result-object v5
invoke-virtual {v5}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v5
const-string v6, "battery_bar_thickness"
invoke-static {v5, v6, v4}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
move-result v2
goto/16 :goto_0
.end method
In method .method public onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z, add the following in RED:
Code:
:cond_a
iget-object v2, p0, Lcom/android/settings/didact/RomSettings;->mBrightnessSliderPreference:Landroid/preference/CheckBoxPreference;
if-ne p2, v2, :cond_c
invoke-virtual {p0}, Lcom/android/settings/didact/RomSettings;->getActivity()Landroid/app/Activity;
move-result-object v2
invoke-virtual {v2}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v2
const-string v3, "display_brightness_slider"
check-cast p2, Landroid/preference/CheckBoxPreference;
invoke-virtual {p2}, Landroid/preference/CheckBoxPreference;->isChecked()Z
move-result v4
if-eqz v4, :cond_b
move v0, v1
:cond_b
invoke-static {v2, v3, v0}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
goto/16 :goto_0
:cond_c
iget-object v2, p0, Lcom/android/settings/didact/RomSettings;->mBatteryBarAnimate:Landroid/preference/CheckBoxPreference;
if-ne p2, v2, :cond_1
invoke-virtual {p0}, Lcom/android/settings/didact/RomSettings;->getActivity()Landroid/app/Activity;
move-result-object v2
invoke-virtual {v2}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v2
const-string v3, "battery_bar_animate"
check-cast p2, Landroid/preference/CheckBoxPreference;
invoke-virtual {p2}, Landroid/preference/CheckBoxPreference;->isChecked()Z
move-result v4
if-eqz v4, :cond_d
move v0, v1
:cond_d
invoke-static {v2, v3, v0}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
goto/16 :goto_0
.end method
That's it for SecSettings, recompile and check the new options and toggles are there. Then move on to part two for SystemUI.
Part II SystemUI.apk
Find the attached zip file and place all files in smali/com/android/systemui/statusbar/policy
Navigate to res/layout/tw_statusbar
Add the following code in RED:
Code:
<com.android.systemui.statusbar.phone.TickerView android:id="@id/tickerText" android:paddingTop="2.0dip" android:paddingRight="10.0dip" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:id="@id/ticker_text_view_old" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" />
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:id="@id/ticker_text_view_new" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" />
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
<com.android.systemui.statusbar.policy.BatteryBarController android:visibility="gone" android:layout_width="fill_parent" android:layout_height="1.0dip" android:layout_alignParentTop="true" systemui:viewLocation="1" />
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
Navigate to res/values/attrs
Add the following code there:
Code:
<attr name="viewLocation" format="integer" />
That's it, recompile and enjoy. Thanks button!