[Android General] Quinny899:
Welcome to this mini guide of how to add items and change the layout of the Settings.apk

Each part of this guide will be rated on how hard it is for the general person. (Out of 5 stars, 5 being hardest)

So, without further ado, here we go:

Stuff You'll Need for the guide

Apktool (And therefore Java too)

A suitable Text Editor for your OS. For Windows, Notepad++ is best, for Linux I recommend Geany In this guide I will be using Geany on Ubuntu

Zipsigner on your device (for ease of use)

adb

NOTE: If you are using Linux, run

everything

, including apktool and your text editor/file manager as ROOT/SUDO

Do this first: Decompiling Settings.apk

Difficulty: ★★☆☆☆

1.) Open a command window in a suitable location, where apktool.jar is also located

1.) Pull your apk from your device

adb pull /system/app/Settings.apk

2.) Pull and install the framework from your device to apktool

adb pull /system/framework/framework-res.apk

java -jar apktool.jar if framework-res.apk

3.) Decompile your Settings.apk

java -jar apktool.jar d -s Settings.apk

(No source is needed)

Editing the Strings of your Settings apk

Difficulty: ★★☆☆☆

1.) Open a file manager and go to where the Settings has decompiled to

2.) Locate and open res/xml/settings_headers.xml in your text editor

3.) Now you can find the header you wish to edit. In this one we will change "Developer settings" to "Noobs keep out"

We need to change the string referenced in this code:

<header android:icon= [MENTION=3944923]drawab[/MENTION]le/ic_settings_development" android:id="@id/development_settings" android:title="@string/development_settings_title" android:fragment="com.android.settings.DevelopmentSettings" />

The android:title reference is what we need to change, so open your Strings.xml, for your language (if it's not in there, open the default one)

Find (use Ctrl+F) the string that we earlier found, so I would search for "development_settings_title"

<string name="development_settings_title">Developer options</string>

Change the bit between the > and the < to what you want:

<string name="development_settings_title">Noobs keep out</string>

4.) Save and proceed to recompiling

Editing the Settings option's icon

Difficulty: ★★★☆☆

1.) Open a file manager and go to where the Settings has decompiled to

2.) Locate and open res/xml/settings_headers.xml in your text editor

3.) Locate the header you wish to change. In this one we will edit the "Development Settings" to have the "ic_settings_advanced" icon (included in CM based ROMs only)

4.) Find the header you want to edit, we want to edit this one:

<header android:icon= [MENTION=3944923]drawab[/MENTION]le/ic_settings_development" android:id="@id/development_settings" android:title="@string/development_settings_title" android:fragment="com.android.settings.DevelopmentSettings" />

5.) Edit the android:icon location to the icon you wish to have. The icons are in res/drawable-hdpi, mdpi, ldpi and xhdpi (depending on ROM)

We want to change it to ic_settings_advanced, so ours will look like:

<header android:icon= [MENTION=3944923]drawab[/MENTION]le/ic_settings_advanced" android:id="@id/development_settings" android:title="@string/development_settings_title" android:fragment="com.android.settings.DevelopmentSettings" />

6.) If you don't want to add icons, proceed to recompiling

7.) Adding icons:

To get icons that fit, see this zip from Google: Download

i) Find the icon you wish to add, make sure it fits your screen's icon resolution (can be found with the dimension of current ic_settings icons in the apk)

ii) Copy it to the correct folder (hdpi, mdpi, xhdpi, ldpi)

iii) Name it something similar (ic_settings_<name>)

iv) Refer to it in the xml, using [MENTION=3944923]drawab[/MENTION]le/ic_settings_<name>

8.) Proceed to recompiling

Adding options to the settings headers

Difficulty: ★★★★☆

Note: In adding settings you can open things such as GooManager for updates quickly and easily from the menu with "About phone" and "Developer settings" in it

1.) Open your decompiled settings_headers.xml

2.) Locate where you want to add an option, and add a new line:

Add this code:

<header android:icon= [MENTION=3944923]drawab[/MENTION]le/ic_settings_name" android:id="@id/id" android:title="@string/title">
<intent android:targetPackage="pkgName" android:action="android.intent.action.MAIN" android:targetClass="pkgName.Activity" />
</header>

3.) What to change:

Change android:icon to the icon you want (for more info see "adding/changing icons")

Add a title to values/strings.xml and reference it in android:title

Change the android:targetPackage to the package name of the app you want to open. This can be found in the AndroidManifest of that particular app

Change the android:targetClass to the package name, followed by the activity you want to open, again found in that particular app's AndroidManifest

Change the android:id to an id that you can add in values/ids.xml (or delete it if you want)

4.) Proceed to recompiling

Adding dividers to settings

Difficulty: ★★★☆☆

Adding to the main settings screen:

1.) Open your settings_headers.xml

2.) Locate where you want to add a divider

3.) Add the following code:

<header android:id="@id/id" android:title="@string/title" />

Stuff to change:

Change the android:id to one that you added in values/ids.xml (or delete it if you want)

Change the android:title to your title in strings.xml

4.) If that's all you want, proceed to recompiling

Adding to the submenus:

1.) Open the submenu that you want to edit's xml (they're quite obvious of which one is which)

2.) Locate where you want to add a divider

3.) Add the following code:

At the start of where you want to have the divider

<PreferenceScreen android:title="@string/title" android:key="key">

Just before the next divider:

</PreferenceScreen>

Stuff to change:

Change the android:title to your title in strings.xml

Change the key to whatever you want

4.) Proceed to recompiling

Reordering Settings

Difficulty: ★★☆☆☆

1.) Open either the settings_headers.xml or a submenu, the process is the same

2.) Cut and paste the different options to your desired order

3.) That's all, proceed to recompiling

Adding items to submenus

Want to add a "Credits" option to your "About device" menu? This is what you need

Difficulty: ★★★☆☆

1.) Open your submenu xml you want (device_info_settings.xml is the about device submenu)

2.) Find your desired location of your new option and make a new line

3.) Paste the following code:

<Preference android:title="@string/title" android:key="key" android:summary="@string/summary" style="?android:preferenceInformationStyle" />

Stuff to change:

Change android:title to the title you added in values/strings.xml

Change android:key to whatever you want

Change android:summary to the longer text that you want that you added to values/strings.xml

4.) Proceed to recompiling

Bonus: Forcing "Developer settings" to be available by default on 4.2

Difficulty: ★★☆☆☆

1.) Open the settings_headers.xml

2.) Locate the following code:

<header android:icon= [MENTION=3944923]drawab[/MENTION]le/ic_settings_development" android:id="@id/development_settings" android:title="@string/development_settings_title" android:fragment="com.android.settings.DevelopmentSettings" />

3.) Change the id from development_settings to development_settings_force

<header android:icon= [MENTION=3944923]drawab[/MENTION]le/ic_settings_development" android:id="@id/development_settings_force" android:title="@string/development_settings_title" android:fragment="com.android.settings.DevelopmentSettings" />

4.) Open values/ids.xml

5.) Add the following line:

<item type="id" name="development_settings_force">false</item>

6.) Proceed to recompiling

Do this last: Recompiling

Difficulty: ★★☆☆☆

1.) Re-open the command window that you used to decompile, in the same location

2.) Run the following code:

java -jar apktool.jar b Settings

3.) Push the new, unsigned apk to your device:

adb push Settings/dist/Settings.apk /sdcard/

4.) On the device, open Zipsigner and select the Settings.apk using the in/out button

5.) On the dropdown, select "platform"

6.) Press sign

7.) When it's done, run the following codes in the command window on the PC:

(Note: Some people might need to run 'adb root' first)

adb remount

adb shell cp /system/app/Settings.apk /system/app/Settings.bak

adb shell cp /sdcard/Settings-signed.apk /system/app/Settings.apk

8.) Reboot your device, you are done

Troubleshooting:

My apk doesn't recomplile!

Look in the command window, it should tell you where the error is, and try to fix it. If you can't, post the error log here and I/someone else will try to help

My new settings doesn't appear!

Did you sign it properly? Try that again. Else, you're out of luck

Something else is wrong!!!!1111

Leave a reply and wait, don't spam, and someone (if not me) will try to help

Screenshots for inspiration:

What I did:

Added an option to update, opens GooManager, using ic_action_mark from the zip from Google

Added an option that opens SuperSU, icon from the newer Settings.apk in ParanoidAndroid

Changed the title and icon of Developer Settings, as well as forcing it to always be there

Reordered the developer settings, and added different dividers