Quantcast
Channel: xda-developers - Verizon Galaxy S III Android Development
Viewing all articles
Browse latest Browse all 352

[MOD][HOW-TO] Add an item to Settings

$
0
0
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.
  1. Decompile SecSettings.apk (I use Apk Manager)

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

    below
    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" />
    It'll look like this when finished:
    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>

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

    right above
    Code:

    </resources>
    It'll look like this when finished (You can name "ROM Control" and "Battery Bar" to whatever you want):
    Code:

    <string name="header_category_rom_mods">ROM Control</string>
    <string name="batterybar_settings">Battery Bar</string>

    </resources>

  4. 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" />
    At line 4871:
    Code:

    <public type="string" name="batterybar_settings" id="0x7f090e3a" />" id="0x7f0203e2" />
    At line 4869:
    Code:

    <public type="string" name="header_category_rom_mods" id="0x7f090e38" />
  5. Navigate to /res/values/ids.xml

    Scroll to the bottom of the file and add:
    Code:

    <item type="id" name="batterybar_settings">false</item>
    right above
    Code:

    </resources>
  6. Recompile SecSettings.apk and push it to your phone.

Viewing all articles
Browse latest Browse all 352

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>