In this guide , I will tell "How to add Battery Bar" option in Settings. :)
Tested this option on Android 4.2 and 4.4
Tested this option on Android 4.2 and 4.4
REQUIREMENTS :
1. Brain
2. Apktool
3. Notepad ++
4. Knowledge on How to Decompile/Recompile the apk
Lets start ,
NOTE : Those are not having the "colorpicker" folder in Settings/smali/net/margaritov/preference and having any other colorpicker in different location then open the "battery_bar_prefs" and edit this line by changing the path of colorpicker in this line.
PHP Code:
<net.margaritov.preference.colorpicker.ColorPickerPreference android:title="@string/battery_bar_color" android:key="battery_bar_color" android:defaultValue="\#ffffff" alphaSlider="true" />
Settings.apk Modding
1. First Decompile your Settings.apk and merge the files (given below).
2. Now add this line in display_settings.xml or any other xml present in Settings.apk/res/xml.
PHP Code:
<PreferenceScreen android:title="@string/battery_bar_title" android:key="battery_bar" android:summary="@string/battery_bar_summary" android:fragment="com.android.settings.gurpreet.batterybar.BatteryBarStyle" />
PHP Code:
<string name="battery_bar_title">Battery Bar</string>
<string name="battery_bar_summary">Enable the battery bar option in statusbar</string>
<string name="battery_bar">Battery bar location</string>
<string name="battery_bar_color">Battery bar color</string>
<string name="battery_bar_cat">Battery bar style</string>
<string name="battery_bar_style_title">Battery bar alignment</string>
<string name="battery_bar_thickness_title">Battery bar thickness</string>
<string name="battery_bar_animate_title">Charging animation</string>
<string name="battery_bar_animate_summary">The charging animation may result in a poor user experience. Enable at your own discretion.</string>
PHP Code:
<string-array name="battery_bar_entries">
<item>Hide</item>
<item>Statusbar</item>
<item>Top of navbar</item>
<item>Bottom of navbar</item>
</string-array>
<string-array name="battery_bar_values">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</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>
6. Now open BatteryBarStyle.smali and replace the ids with the ids present in public.xml of your Settings.apk
0x7f06005e
PHP Code:
<public type="xml" name="battery_bar_prefs"
PHP Code:
<public type="drawable" name="ic_settings_batterybar"
SystemUI.apk Modding
1. First Decompile your SystemUI.apk and merge the files inside it (given below).
2. Now go to SystemUI.apk\res\layout\gemini_status_bar.xml and open it. Now Find these lines ,
PHP Code:
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
PHP Code:
<com.android.systemui.statusbar.policy.BatteryBarController android:layout_width="fill_parent" android:layout_height="1.0dip" systemui:viewLocation="1" />
PHP Code:
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
<com.android.systemui.statusbar.policy.BatteryBarController android:layout_width="fill_parent" android:layout_height="1.0dip" systemui:viewLocation="1" />
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
PHP Code:
<FrameLayout android:id="@id/rot0" android:layout_width="fill_parent" android:layout_height="fill_parent">
PHP Code:
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent">
<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="2" />
<com.android.systemui.statusbar.policy.BatteryBarController android:visibility="gone" android:layout_width="fill_parent" android:layout_height="1.0dip" android:layout_alignParentBottom="true" systemui:viewLocation="3" />
</RelativeLayout>
PHP Code:
<FrameLayout android:id="@id/rot0" android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent">
<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="2" />
<com.android.systemui.statusbar.policy.BatteryBarController android:visibility="gone" android:layout_width="fill_parent" android:layout_height="1.0dip" android:layout_alignParentBottom="true" systemui:viewLocation="3" />
</RelativeLayout>
PHP Code:
<FrameLayout android:id="@id/rot90" android:paddingTop="0.0dip" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent">
PHP Code:
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.android.systemui.statusbar.policy.BatteryBarController android:orientation="vertical" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentLeft="true" android:rotation="180.0" systemui:viewLocation="2" />
<com.android.systemui.statusbar.policy.BatteryBarController android:orientation="vertical" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentRight="true" android:rotation="180.0" systemui:viewLocation="3" />
</RelativeLayout>
PHP Code:
<FrameLayout android:id="@id/rot90" android:paddingTop="0.0dip" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.android.systemui.statusbar.policy.BatteryBarController android:orientation="vertical" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentLeft="true" android:rotation="180.0" systemui:viewLocation="2" />
<com.android.systemui.statusbar.policy.BatteryBarController android:orientation="vertical" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentRight="true" android:rotation="180.0" systemui:viewLocation="3" />
</RelativeLayout>
4. Now go to SystemUI.apk\res\values\attrs.xml and open it. Now add this above </resources>.
PHP Code:
<attr name="viewLocation" format="integer" />
HTML Code:
.method public static edit(Landroid/content/Context;)Landroid/content/SharedPreferences$Editor;
HTML Code:
.method public static getLastBatteryLevel(Landroid/content/Context;)I
.locals 3
.param p0, "context" # Landroid/content/Context;
.prologue
.line 48
invoke-static {p0}, Lcom/android/systemui/statusbar/policy/Prefs;->read(Landroid/content/Context;)Landroid/content/SharedPreferences;
move-result-object v0
const-string v1, "last_battery_level"
const/16 v2, 0x32
invoke-interface {v0, v1, v2}, Landroid/content/SharedPreferences;->getInt(Ljava/lang/String;I)I
move-result v0
return v0
.end method
HTML Code:
.method public static read(Landroid/content/Context;)Landroid/content/SharedPreferences;
HTML Code:
.method public static setLastBatteryLevel(Landroid/content/Context;I)V
.locals 2
.param p0, "context" # Landroid/content/Context;
.param p1, "level" # I
.prologue
.line 44
invoke-static {p0}, Lcom/android/systemui/statusbar/policy/Prefs;->edit(Landroid/content/Context;)Landroid/content/SharedPreferences$Editor;
move-result-object v0
const-string v1, "last_battery_level"
invoke-interface {v0, v1, p1}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor;
move-result-object v0
invoke-interface {v0}, Landroid/content/SharedPreferences$Editor;->commit()Z
.line 45
return-void
.end method
HTML Code:
# static fields
HTML Code:
.field public static final BatteryBarController:[I
HTML Code:
.method static constructor <clinit>()V
.locals 4
.prologue
const/4 v3, 0x1
const/4 v2, 0x0
HTML Code:
new-array v0, v3, [I
const v1, 0x7f01000c
aput v1, v0, v2
sput-object v0, Lcom/android/systemui/R$styleable;->BatteryBarController:[I
HTML Code:
.method static constructor <clinit>()V
.locals 4
.prologue
const/4 v3, 0x1
const/4 v2, 0x0
new-array v0, v3, [I
const v1, 0x7f01000c
aput v1, v0, v2
sput-object v0, Lcom/android/systemui/R$styleable;->BatteryBarController:[I
8. Now open R$styleable.smali and replace the id with the id present in public.xml of your SystemUI.apk
0x7f01000c
PHP Code:
<public type="attr" name="viewLocation"
Special Thanks To :
1. DU_Flo ROM (Extracted from this ROM)
2. MAAaD
3. XDA