Sunday 31 July 2016

[Guide][tut] [LP/MM/+] Create settings preferences and subsettings



Hello guys

i just want to share a very small tut
the basic part .... this should help most of new guys

The topic is about settings preferences

look at this pic



first i will explain in easy words

1. Decompile your deodexed sstock settings.apk
2. Download this Attachment 3829096 and merge to your settings

This zip contain preference smali and preference xml

Compile and Decompile

so you will get pubilc id and replace with yours in krypton.smali


Code:


0x7f060072 = <public type="xml" name="krypton_settings" id="0x7f060072" />

If you need in Dashboard list Follow point 3

3. Now Open res/xml/dashboard_categories.xml

in that add this line (as you like to be )
as i need it in category of personal as in pic

after this line

Code:


    <dashboard-category android:id="@id/system_section" android:title="@string/header_category_system">

i just added this line

Code:


        <dashboard-tile android:id="@+id/system_section" android:title="Krypton Settings" android:fragment="com.android.settings.rz.krypton" />

where ever you add the line it should be before this line

Code:


    </dashboard-category>

If you need in Some subsettings like adding in display settings. follow point 4

4. For Example If you want the kryton settings inside a display settings

then open res/xml/display_settings.xml

Before

Code:


</PreferenceScreen>

Add this line

Code:


    <PreferenceScreen android:title="Krypton Settings" android:key="krypton" android:fragment="com.android.settings.rz.krypton" />

5. so If you want to add logo to your preferences just add this


Code:


android:icon="@drawable/ic_settings_kamesh"

and then add a 72x72 img to drawables with the name ic_settings_kamesh.png ( as you defined )

so code look like

If Dashboard

Code:


<dashboard-tile android:icon="@drawable/ic_settings_kamesh" android:id="@+id/system_section" android:title="@string/RockZ1k_settings" android:fragment="com.android.settings.rz.krypton"/>

If Subsettings

Code:


    <PreferenceScreen android:icon="@drawable/ic_settings_kamesh" android:title="Krypton Settings" android:fragment="com.android.settings.rz.krypton" />

6. when we do here adding these lines we define Fragment path ( call smali at where we define the xml path to execute )

Code:


android:fragment="com.android.settings.rz.krypton"

com.android.settings.rz.krypton = smali/com/android/settings/rz/krypton.smali

If you are Done with this
You are almost ready to create your own preference layouts in sub settings or on Dashboard

you can change the PATH / NAME ( but also need to change in smali ) use notepad++

What we can do with the Preference layouts ?
was Explained in next post


I am not a tutor
i just try to explain in simple that everyone can understand














Attached Files






File Type: zip Settings.zip -
[Click for QR Code]
(2.0 KB)







No comments:

Post a Comment