Post Reply
Angry

[TUTORIAL] How to transform your settings.apk in perfect Honami Settings UPDATE 27/11

17th November 2013, 10:45 PM   |  #1  
niaboc79's Avatar
OP Recognized Developer / Themer
Flag Enghien
Thanks Meter: 31,682
 
6,467 posts
Join Date:Joined: Sep 2007
Donate to Me
More
Many people are asking me how to clone Honami settings. Changing some png is not difficult at all but when we need to edit the smali files it's different.

So I will explain some differents parts such:
  • How to have black text on google account settings.
  • How to add Auto Synch Switcher.
  • How to add your personal sub menu settings.
  • How to add any applications in settings.

How to have black text on google account settings.

Many are thinking that the color of this text is defined by an xml in styles.xml or with a color. That's why no body exepting me as been able to have the correct text color.

This text color is in fact defined by the google account and the color is white by default. Modding the text color inside google applications is not a good solution for Sony dev as an update would have change the color again.

Sony have choose to convert the white text color to black inside the smali files of settings, so even if the user update the google app, the text will always have the right color.




Instructions

1) Copy GenericSettingsFragment.smali in smali/com/sonymobile/settings

2) Copy ProxyPreferenceRootAdapter in smali/com/sonymobile/settings/preference

3) In smali/com/android/settings/accounts/ManageAccountsSettings.smali

Replace full method addAuthenticatorSettings()V

Code:
.method private addAuthenticatorSettings()V
    .locals 3

    .prologue
    .line 357
    iget-object v1, p0, Lcom/android/settings/accounts/ManageAccountsSettings;->mAccountType:Ljava/lang/String;

    invoke-virtual {p0}, Lcom/android/settings/accounts/ManageAccountsSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;

    move-result-object v2

    invoke-virtual {p0, v1, v2}, Lcom/android/settings/accounts/ManageAccountsSettings;->addPreferencesForType(Ljava/lang/String;Landroid/preference/PreferenceScreen;)Landroid/preference/PreferenceScreen;

    move-result-object v0

    .line 358
    .local v0, prefs:Landroid/preference/PreferenceScreen;
    if-eqz v0, :cond_0

    .line 359
    invoke-direct {p0, v0}, Lcom/android/settings/accounts/ManageAccountsSettings;->updatePreferenceIntents(Landroid/preference/PreferenceScreen;)V

    .line 361
    :cond_0
    return-void
.end method
by

Code:
.method private addAuthenticatorSettings()V
    .locals 4

    .prologue
    .line 364
    iget-object v2, p0, Lcom/android/settings/accounts/ManageAccountsSettings;->mAccountType:Ljava/lang/String;

    invoke-virtual {p0}, Lcom/android/settings/accounts/ManageAccountsSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;

    move-result-object v3

    invoke-virtual {p0, v2, v3}, Lcom/android/settings/accounts/ManageAccountsSettings;->addPreferencesForType(Ljava/lang/String;Landroid/preference/PreferenceScreen;)Landroid/preference/PreferenceScreen;

    move-result-object v0

    .line 365
    .local v0, prefs:Landroid/preference/PreferenceScreen;
    if-eqz v0, :cond_0

    .line 366
    invoke-direct {p0, v0}, Lcom/android/settings/accounts/ManageAccountsSettings;->updatePreferenceIntents(Landroid/preference/PreferenceScreen;)V

    .line 372
    :cond_0
    new-instance v1, Lcom/sonymobile/settings/preference/ProxyPreferenceRootAdapter;

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

    move-result-object v2

    invoke-virtual {p0}, Lcom/android/settings/accounts/ManageAccountsSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;

    move-result-object v3

    invoke-virtual {v3}, Landroid/preference/PreferenceScreen;->getRootAdapter()Landroid/widget/ListAdapter;

    move-result-object v3

    invoke-direct {v1, v2, v3}, Lcom/sonymobile/settings/preference/ProxyPreferenceRootAdapter;-><init>(Landroid/content/Context;Landroid/widget/ListAdapter;)V

    .line 375
    .local v1, proxyAdapter:Lcom/sonymobile/settings/preference/ProxyPreferenceRootAdapter;
    invoke-virtual {p0}, Lcom/android/settings/accounts/ManageAccountsSettings;->getListView()Landroid/widget/ListView;

    move-result-object v2

    invoke-virtual {v2, v1}, Landroid/widget/ListView;->setAdapter(Landroid/widget/ListAdapter;)V

    .line 376
    return-void
.end method
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2013-11-17-23-20-07.png
Views:	12230
Size:	220.7 KB
ID:	2398472  
Attached Files
File Type: zip Honamisettings.zip - [Click for QR Code] (2.6 KB, 363 views)
Last edited by niaboc79; 27th November 2013 at 11:31 AM.
The Following 28 Users Say Thank You to niaboc79 For This Useful Post: [ View ]
17th November 2013, 10:45 PM   |  #2  
niaboc79's Avatar
OP Recognized Developer / Themer
Flag Enghien
Thanks Meter: 31,682
 
6,467 posts
Join Date:Joined: Sep 2007
Donate to Me
More
Talking
How to add Auto Synch Switcher

The Honami settings introduce a new switcher that you can use the same way as Wifi and Bluetooth, the Auto Synch Switcher.
I will show you an easy way to add it but I will have to teach you how are working the ID first




Little introduction to ID

What are the ID?

To tell you what they are, first I must tell you where they are... Open public.xml found in res/value and you will see something like that:

Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <public type="attr" name="state_encrypted" id="0x7f010000" />
    <public type="attr" name="icon" id="0x7f010001" />
    <public type="attr" name="emptyColor" id="0x7f010002" />
    <public type="attr" name="minTickWidth" id="0x7f010003" />
    <public type="attr" name="optimalWidth" id="0x7f010004" />
    <public type="attr" name="optimalWidthWeight" id="0x7f010005" />
    <public type="attr" name="sweepDrawable" id="0x7f010006" />
    <public type="attr" name="followAxis" id="0x7f010007" />
    <public type="drawable" name="preview" id="0x7f0200b8" />
    <public type="drawable" name="appwidget_button_center" id="0x7f020001" />
    <public type="drawable" name="appwidget_button_left" id="0x7f020002" />
    <public type="drawable" name="appwidget_button_right" id="0x7f020003" />
    <public type="drawable" name="btn_check_buttonless_on" id="0x7f020014" />
    <public type="drawable" name="data_sweep_left" id="0x7f020018" />
    <public type="mipmap" name="ic_launcher_settings" id="0x7f030000" />
    <public type="layout" name="account_preference" id="0x7f040001" />
    <public type="layout" name="account_sync_screen" id="0x7f040002" />
    <public type="layout" name="add_account_screen" id="0x7f040003" />
I've added some color to explain what are the different parts:

In Red you have the full ID, the long number will be used in the differents smali files as a shortcut.
In Dark Orange you have the type of ID, there are many differents type such as drawable, layout, styles, id, ...
In Lime you can see that the 4 first characters are always 0x7f, all IDs used by an apk who are inside this apk are starting by that.
In Magenta you can see two more characters, these two are related to the type saw earlier, for example type drawable 02, type layout 04, ...
In Silver you have the last 4 characters who are related to different names used for a same type. These numbers are in hexadecimal.


I need to show you an other place where you can find ID, inside framework-res.apk, Open public.xml found in res/value and you will see something like that:

Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <public type="attr" name="theme" id="0x01010000" />
    <public type="attr" name="label" id="0x01010001" />
    <public type="attr" name="icon" id="0x01010002" />
    <public type="attr" name="name" id="0x01010003" />
    <public type="attr" name="manageSpaceActivity" id="0x01010004" />
    <public type="attr" name="allowClearUserData" id="0x01010005" />
    <public type="attr" name="permission" id="0x01010006" />
    <public type="id" name="background" id="0x01020000" />
    <public type="id" name="checkbox" id="0x01020001" />
    <public type="id" name="content" id="0x01020002" />
    <public type="id" name="edit" id="0x01020003" />
    <public type="id" name="empty" id="0x01020004" />
    <public type="style" name="Animation" id="0x01030000" />
    <public type="style" name="Animation.Activity" id="0x01030001" />
    <public type="style" name="Animation.Dialog" id="0x01030002" />
    <public type="style" name="Animation.Translucent" id="0x01030003" />
    <public type="style" name="Animation.Toast" id="0x01030004" />
    <public type="style" name="Theme" id="0x01030005" />
    <public type="style" name="Theme.NoTitleBar" id="0x01030006" />
I have used the same colors as before because this is exactly working the same way with some little variations.

The first characters are now 0x01 instead of 0x7, that means that these ID are inside framework-res.apk

BUT be carefull, when the IDs are used inside the smali files of an APK, the first zero after the x is always removed.

Example: 0x01030002 found in public.xml of framework-res.apk will be wrote inside a smali of an APK -> 0x1030002


Instructions

Now I can finally start

1) Copy AutoSyncEnabler.smali, AutoSyncDialogFragment.smali, AutoSyncDialogFragment$1.smali and AutoSyncDialogFragment$2.smali in smali/com/android/settings/

2) Open AutoSyncDialogFragment.smali with notepad++ and search "0x7" without the quote.

You will found 4 ID as explained, these ID are related to MY Settings.apk, that means that inside your apk, these "Shortcuts" may not be the good one...

I have include the public.xml found in MY settings.apk and called it public-settings.xml, open it too with notepad++ and in the same time open YOUR public.xml found in YOUR settings.apk

Let's do it for the first ID found in the smali: 0x7f0b067a, search now the full ID inside my public.xml, you will found this:

Code:
<public type="string" name="data_usage_auto_sync_off_dialog_title" id="0x7f0b067a" />
So this ID is a shortcut for the "string" named "data_usage_auto_sync_off_dialog_title"

Now search in YOUR public.xml: "data_usage_auto_sync_off_dialog_title" without the quote and check if the full ID is the same. If the ID is different, use this one inside the smali files.

Do the same with all ID starting by 0x7

3) Copy Settings$HeaderAdapter.smali in smali/com/android/settings/ and open it with notepad++

Do a search for all ID starting by 0x7 and check between MY public.xml and YOUR public.xml

Do also a search for all ID starting by 0x1 (ID related to framework-res.apk) (You must found 5 different ID)

The first one found is 0x1010208

As I told you ID related to framework-res.apk found in smali are slightly different when they are in the public.xml of framework-res.apk (Remember the first character after the x ? )

I have include the public.xml found in MY framework-res.apk and called it public-framework-res.xml. Open MY public-framework-res.xml and YOUR public.xml of YOUR framework-res.apk

Do a search for "0x01010208" without the quote (I have added a zero after the x ) in MY public.xml and you will found that:

Code:
<public type="attr" name="listSeparatorTextViewStyle" id="0x01010208" />
Now search "listSeparatorTextViewStyle" inside YOUR public.xml and check if the ID are the same, if different replace with the correct one (Don't forget to remove the zero in the smali).
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2013-11-27-12-25-56.jpg
Views:	7831
Size:	65.4 KB
ID:	2417846  
Attached Files
File Type: zip Honamisettings_AutoSync.zip - [Click for QR Code] (107.4 KB, 147 views)
Last edited by niaboc79; 27th November 2013 at 11:29 AM.
The Following 17 Users Say Thank You to niaboc79 For This Useful Post: [ View ]
17th November 2013, 10:45 PM   |  #3  
niaboc79's Avatar
OP Recognized Developer / Themer
Flag Enghien
Thanks Meter: 31,682
 
6,467 posts
Join Date:Joined: Sep 2007
Donate to Me
More
reserved
The Following 5 Users Say Thank You to niaboc79 For This Useful Post: [ View ]
17th November 2013, 10:46 PM   |  #4  
niaboc79's Avatar
OP Recognized Developer / Themer
Flag Enghien
Thanks Meter: 31,682
 
6,467 posts
Join Date:Joined: Sep 2007
Donate to Me
More
last one
The Following 4 Users Say Thank You to niaboc79 For This Useful Post: [ View ]
18th November 2013, 10:41 AM   |  #5  
serajr's Avatar
Recognized Developer / Recognized Themer
Flag Rafard - SP
Thanks Meter: 9,890
 
2,568 posts
Join Date:Joined: Apr 2011
Donate to Me
More
That´s my friend!!! Awesome bro...
Thank u so much!!
The Following 2 Users Say Thank You to serajr For This Useful Post: [ View ]
18th November 2013, 10:45 PM   |  #6  
Pandemic's Avatar
Senior Member
Flag MePpEl
Thanks Meter: 11,821
 
15,560 posts
Join Date:Joined: Aug 2010
Donate to Me
More
This is a great guide bro @niaboc79
very good
just keep doing your things, im happy with this !!
20th November 2013, 03:33 AM   |  #7  
Member
Thanks Meter: 33
 
95 posts
Join Date:Joined: Feb 2012
Thanks for this.

Quick question, how about porting Quick Settings ?
Reason i'm asking is, i have a Xperia C, it's quick settings are the ancient type, unlike the one from Xperia Z onwards where you can have 2 rows of customizable settings.

I've saw how you can edit the Settings.apk and link it to a Toolsetting.apk, where you can choose which quick setting to appear.
But you will still need to edit SystemUI.apk, which i guess that's the hardest part with all the smali edit.

Hope you can help.
Thanks.
Last edited by takagen; 20th November 2013 at 03:36 AM.
20th November 2013, 07:53 AM   |  #8  
niaboc79's Avatar
OP Recognized Developer / Themer
Flag Enghien
Thanks Meter: 31,682
 
6,467 posts
Join Date:Joined: Sep 2007
Donate to Me
More
Quote:
Originally Posted by Pandemic

This is a great guide bro @niaboc79
very good
just keep doing your things, im happy with this !!

I will complete when time

Envoyé de mon C6603 en utilisant Tapatalk
The Following 2 Users Say Thank You to niaboc79 For This Useful Post: [ View ]
20th November 2013, 07:54 AM   |  #9  
niaboc79's Avatar
OP Recognized Developer / Themer
Flag Enghien
Thanks Meter: 31,682
 
6,467 posts
Join Date:Joined: Sep 2007
Donate to Me
More
Quote:
Originally Posted by takagen

Thanks for this.

Quick question, how about porting Quick Settings ?
Reason i'm asking is, i have a Xperia C, it's quick settings are the ancient type, unlike the one from Xperia Z onwards where you can have 2 rows of customizable settings.

I've saw how you can edit the Settings.apk and link it to a Toolsetting.apk, where you can choose which quick setting to appear.
But you will still need to edit SystemUI.apk, which i guess that's the hardest part with all the smali edit.

Hope you can help.
Thanks.

Are you on JB or ICS?

Envoyé de mon C6603 en utilisant Tapatalk
The Following 2 Users Say Thank You to niaboc79 For This Useful Post: [ View ]
20th November 2013, 08:47 AM   |  #10  
Member
Thanks Meter: 33
 
95 posts
Join Date:Joined: Feb 2012
Quote:
Originally Posted by niaboc79

Are you on JB or ICS?

Envoyé de mon C6603 en utilisant Tapatalk

I'm on JB.

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Sony Cross-Device Development General by ThreadRank