You mainly see these kinds of things in AOSP ROMs, but I'll teach you guys how to add a "Tweaks" option to the Settings app. Some people know how to do this, others don't. In the spirit of making a better community, here's the how-to. I'll be using the MIUI batterybar by PvyParts as the example. So, to add the MIUI batterybar to Settings, follow the following steps:
Note: You must have already made your ROM compatible with the batterybar mod for it to work. This guide just teaches you how to add things to it. Also, this guide works only if you have a tweaks app such as the batterybar, quickpanel settings, etc so make sure you have those apps installed.
- Decompile SecSettings.apk (I use Apk Manager)
- Navigate to /res/xml/settings_headers.xml
Add
Code:<header android:title="@string/header_category_rom_mods" />
<header android:icon="@drawable/ic_settings_batterybar" android:id="@id/batterybar_settings" android:title="@string/batterybar_settings">
<intent android:targetPackage="com.pvy.battbar.settings" android:action="android.intent.action.MAIN" android:targetClass="com.pvy.battbar.settings.options" />
</header>
Code:<header android:icon="@drawable/ic_settings_more" android:id="@id/wireless_settings" android:title="@string/more_settings" android:fragment="com.android.settings.WirelessSettings" android:breadCrumbTitle="@string/wireless_networks_settings_title" />
Code:<header android:icon="@drawable/ic_settings_more" android:id="@id/wireless_settings" android:title="@string/more_settings" android:fragment="com.android.settings.WirelessSettings" android:breadCrumbTitle="@string/wireless_networks_settings_title" />
<header android:title="@string/header_category_rom_mods" />
<header android:icon="@drawable/ic_settings_batterybar" android:id="@id/batterybar_settings" android:title="@string/batterybar_settings">
<intent android:targetPackage="com.pvy.battbar.settings" android:action="android.intent.action.MAIN" android:targetClass="com.pvy.battbar.settings.options" />
</header>
- Navigate to /res/values/strings.xml
Scroll to the bottom of the file and add
Code:<string name="header_category_rom_mods">ROM Control</string>
<string name="batterybar_settings">Battery Bar</string>
Code:</resources>
Code:<string name="header_category_rom_mods">ROM Control</string>
<string name="batterybar_settings">Battery Bar</string>
</resources>
- Navigate to /res/values/public.xml
This is the tricky part. You will have to assign unique IDs to each mod. Additionally, you will need to assign a "drawable" type (for the picture) and a "string" type (for the name). This is what my code looks like (the red part is the unique ID (you can use mine as long as they don't conflict with any ID in your public.xml)):
At line 797:
Code:<public type="drawable" name="ic_settings_batterybar" id="0x7f0203e2" />
Code:<public type="string" name="batterybar_settings" id="0x7f090e3a" />" id="0x7f0203e2" />
Code:<public type="string" name="header_category_rom_mods" id="0x7f090e38" />
- Navigate to /res/values/ids.xml
Scroll to the bottom of the file and add:
Code:<item type="id" name="batterybar_settings">false</item>
Code:</resources>
- Recompile SecSettings.apk and push it to your phone.