[GUIDE][HOW] Easy Preference Control

Search This thread

bamzzz

Senior Member
Hi all.. i'm back again for share guide about add preference into stock Settings.apk
This guide is work for JB 4.1+

Feature:
PreferenceScreen
SeekBarPreference
ColorPickerPreference
MyListPreference
SwitchPreference
CheckBoxPreference
MyEditTextPreference
FilePreference
and many more..

Requirement:
- Understanding about APK compile/decompile
- APKTool
- Notepad++ (PC)

How:
1. Decompile Settings.apk
2. Copy smali and res folder from guide
3. Open AndroidManifest.xml
Find:
Code:
    <uses-permission android:name="android.permission.REBOOT"/>
Add below:
Code:
    <uses-permission android:name="android.permission.FORCE_STOP_PACKAGES" />
Scroll to end of line, add this above </application>
Code:
    <activity android:label="@string/zen_control_title" android:name="com.android.settings.bamzzz.ZenControl" />
4. Open res/xml/dashboard_categories.xml (Lollipop) or res/xml/settings_headers.xml (JB)
Add this below "<dashboard-category android:id="@id/system_section" ..." or what do you want
Lollipop:
Code:
        <dashboard-tile android:icon="@drawable/ic_settings_zencontrol" android:id="@id/zen_control" android:title="@string/zen_control_title" android:fragment="com.android.settings.bamzzz.ZenControl" />
JB:
Code:
        <header android:icon="@drawable/ic_settings_zencontrol" android:id="@id/zen_control" android:title="@string/zen_control_title" android:fragment="com.android.settings.bamzzz.ZenControl" />
5. Open res/values/attrs.xml and add this:
Code:
    <attr name="colorPrimary" format="color" />
    <attr name="colorPrimaryDark" format="color" />
    <attr name="colorAccent" format="color" />
	<declare-styleable name="ThumbnailListPreference">
        <attr name="drawableArray" format="reference" />
        <attr name="entryList" format="reference" />
        <attr name="entryValuesList" format="reference" />
        <attr name="entryDefault" format="string" />
    </declare-styleable>
6. Open res/values/colors.xml and add this:
Code:
    <color name="colorAccent">#ffff4081</color>
    <color name="colorPrimary">#ff3f51b5</color>
    <color name="colorPrimaryDark">#ff303f9f</color>
7. Open res/values/dimens.xml and add this:
Code:
    <dimen name="button_size">30.0dip</dimen>
8. Open res/values/ids.xml and add this:
Code:
    <item type="id" name="zen_control">false</item>
    <item type="id" name="appIcon">false</item>
    <item type="id" name="linearLayout">false</item>
    <item type="id" name="appName">false</item>
    <item type="id" name="appPackage">false</item>
    <item type="id" name="imageView">false</item>
    <item type="id" name="color_picker_view">false</item>
    <item type="id" name="text_hex_wrapper">false</item>
    <item type="id" name="hex_val">false</item>
    <item type="id" name="old_color_panel">false</item>
    <item type="id" name="new_color_panel">false</item>
    <item type="id" name="fileSwitch">false</item>
    <item type="id" name="searchApp">false</item>
    <item type="id" name="appsList">false</item>
    <item type="id" name="progressBar">false</item>
    <item type="id" name="iconForApp">false</item>
    <item type="id" name="seekBarPrefUnitsRight">false</item>
    <item type="id" name="seekBarPrefValue">false</item>
    <item type="id" name="seekBarPrefUnitsLeft">false</item>
    <item type="id" name="seekBarPrefBarContainer">false</item>
    <item type="id" name="seekBarPrefSeekBar">false</item>
    <item type="id" name="thumbnailRadioButton">false</item>
    <item type="id" name="thumbnailImage">false</item>
    <item type="id" name="thumbnailText">false</item>
    <item type="id" name="thumbnailListView">false</item>
    <item type="id" name="thumbnailIcon">false</item>
9. Open res/values/strings.xml and add this:
Code:
    <string name="zen_control_title">Zen Control™</string> <!-- Rename if do you want -->
    <string name="ok">OK</string>
    <string name="app_reboot_required_title">App Reboot Required</string>
    <string name="app_reboot_required_message">%1$s reboot is required for the changes to take effect.\n\nReboot now?</string>
    <string name="dialog_color_picker">Color Picker</string>
    <string name="press_color_to_apply">Press on Color to apply</string>
10. Open smali/com/android/settings/bamzzz/prefs/ColorPickerPreference.smali
Find "0x1020018" and replace with public id from framework-res type="id" name="widget_frame"
11. Open smali/com/android/settings/bamzzz/prefs/ColorPickerPreference.smali
Find "0x1020010" and replace with public id from framework-res type="id" name="summary"
12. Open res/xml/zen_prefs.xml, add/edit your preference here...
13. Done

Attention: Don't rename smali and/or folder structure without my permission..!!!

Keep oprek. Salam bootloop. :p

Thanks to:
wuby986@xda
daxgirl@xda

Guide by bamzzz@xda
fb.me/bamz4ever
 

Attachments

  • Screenshot_2016-02-19-07-00-05.png
    Screenshot_2016-02-19-07-00-05.png
    58.6 KB · Views: 3,085
  • Screenshot_2016-02-19-07-00-34.png
    Screenshot_2016-02-19-07-00-34.png
    66.9 KB · Views: 3,115
  • Screenshot_2016-02-19-07-00-13.png
    Screenshot_2016-02-19-07-00-13.png
    43.4 KB · Views: 3,010
  • Screenshot_2016-02-19-07-00-23.png
    Screenshot_2016-02-19-07-00-23.png
    58.4 KB · Views: 2,645
Last edited:

deddyassary

New member
Mar 5, 2016
4
0
Ask um,
java.lang.RuntimeException: Unable to resume activity {com.android.settings/com.android.settings.SubSettings}: java.lang.NullPointerException: Attempt to read from null array
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3019)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3050)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2425)
at android.app.ActivityThread.access$900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5294)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
 

moonryder

Senior Member
Apr 24, 2014
1,359
746
southern
@bamzzz @venkat kamesh
added missed
Code:
<public type="id" name="widget_frame" id="0x7f0f02e1" />
to public.xml
and missed
Code:
<item type="id" name="widget_frame">false</item>
to ids.xml
recompiled settings.apk to get public id´s
decompiled again and wanted to change id´s in smali.
But there is no value 0x1020010 in smali/com/android/settings/bamzzz/prefs/ColorPickerPreference.smali
 
Last edited:

venkat kamesh

Inactive Recognized Contributor
Jan 11, 2012
2,236
10,881
Tirupati
xdaforums.com
@bamzzz @venkat kamesh
added missed
Code:
<public type="id" name="widget_frame" id="0x7f0f02e1" />
to public.xml
and missed
Code:
<item type="id" name="widget_frame">false</item>
to ids.xml
recompiled settings.apk to get public id´s
decompiled again and wanted to change id´s in smali.
But there is no value 0x1020010 in smali/com/android/settings/bamzzz/prefs/ColorPickerPreference.smali
Bro adding id was not a matter

In layout xml or any xml. Where id is defined

Just change @iD to @+id this will add the required id to ids.xml also creates public id

Coming to 0x10xxxxx these public ids will be with framework-res.apk.

Good luck bro ;)
 

moonryder

Senior Member
Apr 24, 2014
1,359
746
southern
Bro adding id was not a matter

In layout xml or any xml. Where id is defined

Just change @iD to @+id this will add the required id to ids.xml also creates public id

Coming to 0x10xxxxx these public ids will be with framework-res.apk.

Good luck bro ;)
hi bro,

thx for the tipp with the +id ;)

I looked in the framework-res and saw that there has nothing to be changed in the smali cuz the id´s are the same.
But there is no value 0x1020010 in smali/com/android/settings/bamzzz/prefs/ColorPickerPreference.smali - so i can´t check/change the id!
And without that value this mod did not work! (also the one from @venkat kamesh) - pity
 
Last edited:

venkat kamesh

Inactive Recognized Contributor
Jan 11, 2012
2,236
10,881
Tirupati
xdaforums.com
hi bro,

thx for the tipp with the +id ;)

I looked in the framework-res and saw that there has nothing to be changed in the smali cuz the id´s are the same.
But there is no value 0x1020010 in smali/com/android/settings/bamzzz/prefs/ColorPickerPreference.smali - so i can´t check/change the id!
And without that value this mod did not work! (also the one from @venkat kamesh) - pity
Haha this guide was not from me
I haven't tested it either bro

See @Bloodlvst solved this
Hope he may help you bro
 

moonryder

Senior Member
Apr 24, 2014
1,359
746
southern
@moonryder - the ID shouldn't need changing. What's the error you get and what android version?
hi,
i will try to explain it the third time:
i followed the tut by bamzzz. All went fine until i wanted to change the values in "smali/com/android/settings/bamzzz/prefs/ColorPickerPreference.smali" (look at step 11 of bamzzz´s tutorial).
--> there is NO value 0x1020010 so i could not change it (public id)

so i tried it without step 11, followed the tut of venkat kamesh to hide battery in statusbar (tutorial from here).
Compiling and flashing went fine, but it didn´t work.
pushing the button, the battery icon won´t disapper.
So i think the issue must be in the smali mentioned above.

i am on LP 5.1.1
 
Last edited:

Bloodlvst

Senior Member
Apr 3, 2011
418
385
hi,
i will try to explain it the third time:
i followed the tut by bamzzz. All went fine until i wanted to change the values in "smali/com/android/settings/bamzzz/prefs/ColorPickerPreference.smali" (look at step 11 of bamzzz´s tutorial).
--> there is NO value 0x1020010 so i could not change it (public id)

so i tried it without step 11, followed the tut of venkat kamesh to hide battery in statusbar (tutorial from here).
Compiling and flashing went fine, but it didn´t work.
pushing the button, the battery icon won´t disapper.
So i think the issue must be in the smali mentioned above.

Step 11 just had a typo for the filename. If you look at the Guide.txt in the zip file, it will give you the right file name. But in either case those values wouldn't affect if the battery will hide or not
 
  • Like
Reactions: moonryder

venkat kamesh

Inactive Recognized Contributor
Jan 11, 2012
2,236
10,881
Tirupati
xdaforums.com
hi,
i will try to explain it the third time:
i followed the tut by bamzzz. All went fine until i wanted to change the values in "smali/com/android/settings/bamzzz/prefs/ColorPickerPreference.smali" (look at step 11 of bamzzz´s tutorial).
--> there is NO value 0x1020010 so i could not change it (public id)

so i tried it without step 11, followed the tut of venkat kamesh to hide battery in statusbar (tutorial from here).
Compiling and flashing went fine, but it didn´t work.
pushing the button, the battery icon won´t disapper.
So i think the issue must be in the smali mentioned above.

i am on LP 5.1.1
why not a logcat

that show the problem
get a logcat bro
 

Top Liked Posts

  • There are no posts matching your filters.
  • 7
    Hi all.. i'm back again for share guide about add preference into stock Settings.apk
    This guide is work for JB 4.1+

    Feature:
    PreferenceScreen
    SeekBarPreference
    ColorPickerPreference
    MyListPreference
    SwitchPreference
    CheckBoxPreference
    MyEditTextPreference
    FilePreference
    and many more..

    Requirement:
    - Understanding about APK compile/decompile
    - APKTool
    - Notepad++ (PC)

    How:
    1. Decompile Settings.apk
    2. Copy smali and res folder from guide
    3. Open AndroidManifest.xml
    Find:
    Code:
        <uses-permission android:name="android.permission.REBOOT"/>
    Add below:
    Code:
        <uses-permission android:name="android.permission.FORCE_STOP_PACKAGES" />
    Scroll to end of line, add this above </application>
    Code:
        <activity android:label="@string/zen_control_title" android:name="com.android.settings.bamzzz.ZenControl" />
    4. Open res/xml/dashboard_categories.xml (Lollipop) or res/xml/settings_headers.xml (JB)
    Add this below "<dashboard-category android:id="@id/system_section" ..." or what do you want
    Lollipop:
    Code:
            <dashboard-tile android:icon="@drawable/ic_settings_zencontrol" android:id="@id/zen_control" android:title="@string/zen_control_title" android:fragment="com.android.settings.bamzzz.ZenControl" />
    JB:
    Code:
            <header android:icon="@drawable/ic_settings_zencontrol" android:id="@id/zen_control" android:title="@string/zen_control_title" android:fragment="com.android.settings.bamzzz.ZenControl" />
    5. Open res/values/attrs.xml and add this:
    Code:
        <attr name="colorPrimary" format="color" />
        <attr name="colorPrimaryDark" format="color" />
        <attr name="colorAccent" format="color" />
    	<declare-styleable name="ThumbnailListPreference">
            <attr name="drawableArray" format="reference" />
            <attr name="entryList" format="reference" />
            <attr name="entryValuesList" format="reference" />
            <attr name="entryDefault" format="string" />
        </declare-styleable>
    6. Open res/values/colors.xml and add this:
    Code:
        <color name="colorAccent">#ffff4081</color>
        <color name="colorPrimary">#ff3f51b5</color>
        <color name="colorPrimaryDark">#ff303f9f</color>
    7. Open res/values/dimens.xml and add this:
    Code:
        <dimen name="button_size">30.0dip</dimen>
    8. Open res/values/ids.xml and add this:
    Code:
        <item type="id" name="zen_control">false</item>
        <item type="id" name="appIcon">false</item>
        <item type="id" name="linearLayout">false</item>
        <item type="id" name="appName">false</item>
        <item type="id" name="appPackage">false</item>
        <item type="id" name="imageView">false</item>
        <item type="id" name="color_picker_view">false</item>
        <item type="id" name="text_hex_wrapper">false</item>
        <item type="id" name="hex_val">false</item>
        <item type="id" name="old_color_panel">false</item>
        <item type="id" name="new_color_panel">false</item>
        <item type="id" name="fileSwitch">false</item>
        <item type="id" name="searchApp">false</item>
        <item type="id" name="appsList">false</item>
        <item type="id" name="progressBar">false</item>
        <item type="id" name="iconForApp">false</item>
        <item type="id" name="seekBarPrefUnitsRight">false</item>
        <item type="id" name="seekBarPrefValue">false</item>
        <item type="id" name="seekBarPrefUnitsLeft">false</item>
        <item type="id" name="seekBarPrefBarContainer">false</item>
        <item type="id" name="seekBarPrefSeekBar">false</item>
        <item type="id" name="thumbnailRadioButton">false</item>
        <item type="id" name="thumbnailImage">false</item>
        <item type="id" name="thumbnailText">false</item>
        <item type="id" name="thumbnailListView">false</item>
        <item type="id" name="thumbnailIcon">false</item>
    9. Open res/values/strings.xml and add this:
    Code:
        <string name="zen_control_title">Zen Control™</string> <!-- Rename if do you want -->
        <string name="ok">OK</string>
        <string name="app_reboot_required_title">App Reboot Required</string>
        <string name="app_reboot_required_message">%1$s reboot is required for the changes to take effect.\n\nReboot now?</string>
        <string name="dialog_color_picker">Color Picker</string>
        <string name="press_color_to_apply">Press on Color to apply</string>
    10. Open smali/com/android/settings/bamzzz/prefs/ColorPickerPreference.smali
    Find "0x1020018" and replace with public id from framework-res type="id" name="widget_frame"
    11. Open smali/com/android/settings/bamzzz/prefs/ColorPickerPreference.smali
    Find "0x1020010" and replace with public id from framework-res type="id" name="summary"
    12. Open res/xml/zen_prefs.xml, add/edit your preference here...
    13. Done

    Attention: Don't rename smali and/or folder structure without my permission..!!!

    Keep oprek. Salam bootloop. :p

    Thanks to:
    wuby986@xda
    daxgirl@xda

    Guide by bamzzz@xda
    fb.me/bamz4ever
    1
    hi,
    i will try to explain it the third time:
    i followed the tut by bamzzz. All went fine until i wanted to change the values in "smali/com/android/settings/bamzzz/prefs/ColorPickerPreference.smali" (look at step 11 of bamzzz´s tutorial).
    --> there is NO value 0x1020010 so i could not change it (public id)

    so i tried it without step 11, followed the tut of venkat kamesh to hide battery in statusbar (tutorial from here).
    Compiling and flashing went fine, but it didn´t work.
    pushing the button, the battery icon won´t disapper.
    So i think the issue must be in the smali mentioned above.

    Step 11 just had a typo for the filename. If you look at the Guide.txt in the zip file, it will give you the right file name. But in either case those values wouldn't affect if the battery will hide or not
    1
    i did it like you said

    seems the present tut not working on lp

    i will make one ;)