[MOD][How to] Use layout file on SecSettings

92 posts
Thanks Meter: 84
By gerryS2, Member on 24th January 2014, 05:59 PM
Post Reply Subscribe to Thread Email Thread
In this guide I will explain how to use layout file, for insert a text guide or image in SecSettings like the image in attachment
The limitation of this mod are that you can insert one text or image with one layout file like this:
1 text(TextView)=1 layout file
2 text(TextView)=2 layout file
1 image(ImageView)=1 layout file
2 image(ImageView)=2 layout file
1 text and 1 image=1 layout for text and 1 layout for image.
In this guide I use displaysettings.xml, DisplaySettings.smali and layout file (that you must insert in layout folder) for one image and one text.
In displaysettings.xml or other file of xml folder, insert this line (the position of the text is determined by the position in which you insert the line in the xml file):

<Preference android:key="statusbar_help" />
Like this, in this way the text appears on the top:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen android:title="@string/statusbar_settings"
    <Preference android:key="statusbar_help" />

In DisplaySettings or other smali file, you have insert this modification:
-Insert an instance fields, like this:
# instance fields
.field mHelpStatusBarPref:Landroid/preference/Preference;
-Insert a lines in this method:
.method public onCreate(Landroid/os/Bundle;)V
const-string v1, "statusbar_help"

    invoke-virtual {p0, v1}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v1

    iput-object v1, p0, Lcom/android/settings/DisplaySettings;->mHelpStatusBarPref:Landroid/preference/Preference;

    invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getActivity()Landroid/app/Activity;

    move-result-object v1

    invoke-static {v1}, Lcom/android/settings/Utils;->isVoiceCapable(Landroid/content/Context;)Z

    move-result v1

    iget-object v1, p0, Lcom/android/settings/DisplaySettings;->mHelpStatusBarPref:Landroid/preference/Preference;

    const v4, 0x7f04013b

    invoke-virtual {v1, v4}, Landroid/preference/Preference;->setLayoutResource(I)V

    goto/16 :goto_00

    iget-object v1, p0, Lcom/android/settings/DisplaySettings;->mHelpStatusBarPref:Landroid/preference/Preference;

    invoke-virtual {v1, v3}, Landroid/preference/Preference;->setSelectable(Z)V
0x7f04013b is the public id of the layout file

Now you have create a layout file xml and insert this file in layout folder for text and a layout file for image.
For text create a xml file and insert this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content"
    <TextView android:textSize="18.0sp" android:textColor="?android:twTextColorPrimary" android:id="@id/textView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="16.0dip" android:layout_marginTop="9.0dip" android:layout_marginRight="12.0dip" android:layout_marginBottom="9.0dip" android:text="@string/how_csc_use_summary" />
Use android:text="@string/how_csc_use_summary" for insert a custom text

For image create another xml file and insert this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content"
    <ImageView android:layout_gravity="center_horizontal" android:visibility="visible" android:background="@drawable/natale" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5.0dip" android:layout_marginBottom="5.0dip" />
Use android:background="@drawable/natale" for insert the image.

I hope I have been helpful with this mod
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2014-01-24-17-21-31.png
Views:	838
Size:	121.3 KB
ID:	2536654  
The Following 5 Users Say Thank You to gerryS2 For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes