lundi 10 mars 2014

[MOD][Guide]Change Toggles Icon Theme "on the fly" topic




GUIDE TO CHANGE QUICKSETTING TOGGLES ICON THEME



work perfectly in my JB rom 4.1.2 xwlsd based

Before modding do a Nandroid Backup

thanks and credit to Goldie for his help to achieve this mod:good:
thanks and credit to Didact74 for how to add a listpreference:good:
thanks and credit to CNexus for his shared observer code:good:

To achieve you need:
SecSettings.apk
SystemUI.apk
tool for decompile and compile like apktool 1.5.2;
tool for text edit like notepad++:

Start with SecSettings.apk:
Decompile SecSettings.apk ,go in res/xml ,open with text editor display_settings.xml and add the red line

 





Code:


<PreferenceCategory android:title="@string/statusbar_options" android:key="statusbar_options">
  <ListPreference android:persistent="false" android:entries="@array/toggles_chooser_entries" android:title="@string/icon_toggles_chooser" android:key="toggles_chooser" android:summary="@string/icon_toggles_chooser_summary" android:entryValues="@array/toggles_chooser_values" />
        </PreferenceCategory>






Go in res/value open with text editor arrays.xml and add at the end the red line

 





Code:


        <string-array name="toggles_chooser_entries">
        <item>S2 Stock Toggles</item>
        <item>S5 Stock Toggles</item>
                <item>Green Toggles</item>
    </string-array>
        <string-array name="toggles_chooser_values">
        <item>0</item>
        <item>1</item>
                <item>2</item>
        </string-array>

</resources>






Go in res/value open with text editor strings.xml and add at the end this line

 





Code:


       
        <string name="statusbar_options">Statusbar Options</string>
        <string name="icon_toggles_chooser">Toggles Theme</string>
        <string name="icon_toggles_chooser_summary">Select toggles\'s icons theme</string>
</resources>






Go in smali\com\android\settings\DisplaySettings.smal i and add the following lines in RED

 





Code:


.field mSupportFolderType:Z

.field private mTogglesTheme:Landroid/preference/ListPreference;

.field private mTouchKeyLight:Landroid/preference/ListPreference;






In the same file find .method public onCreate and add the following lines in RED

 





Code:


iput-object v12, p0, Lcom/android/settings/DisplaySettings;->mFontSizePref:Landroid/preference/ListPreference;

    .line 424
    iget-object v12, p0, Lcom/android/settings/DisplaySettings;->mFontSizePref:Landroid/preference/ListPreference;

    invoke-virtual {v12, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
const-string v12, "toggles_chooser"

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

    move-result-object v12

    check-cast v12, Landroid/preference/ListPreference;

    iput-object v12, p0, Lcom/android/settings/DisplaySettings;->mTogglesTheme:Landroid/preference/ListPreference;

    const-string v12, "toggles_chooser"

    const/4 v13, 0x0

    invoke-static {v8, v12, v13}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v12

    iget-object v13, p0, Lcom/android/settings/DisplaySettings;->mTogglesTheme:Landroid/preference/ListPreference;

    invoke-static {v12}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v12

    invoke-virtual {v13, v12}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V

    iget-object v13, p0, Lcom/android/settings/DisplaySettings;->mTogglesTheme:Landroid/preference/ListPreference;

    invoke-virtual {v13, p0}, Landroid/preference/SwitchPreferenceScreen;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V


    .line 426






In the same file find .method public onPreferenceChange then find this code and add the red lines ,in blue line some explanation

 





Code:


  const-string v2, "contextualpage_settings"

    invoke-virtual {v2, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_togglestheme change this from cond_2 to cond_togglestheme

    .line 1089
    check-cast p2, Ljava/lang/Boolean;

    invoke-virtual {p2}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v0

    if-eqz v0, :cond_e







 





Code:


.line 1100
    const-string v1, "DisplaySettings"

    const-string v3, "CONTEXTUALPAGE_SWITCH_CHANGED changed = false"

    invoke-static {v1, v3}, Landroid/util/Log;->secD(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_7

    :cond_11
    move-wide v0, v4

    goto/16 :goto_3

    :cond_togglestheme
    iget-object v1, p0, Lcom/android/settings/DisplaySettings;->mTogglesTheme:Landroid/preference/ListPreference;

    if-ne p1, v1, :cond_2

    check-cast p2, Ljava/lang/String;

    invoke-static {p2}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/Integer;->intValue()I

    move-result v0

    invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    const-string v2, "toggles_chooser"

    invoke-static {v1, v2, v0}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

    goto/16 :goto_4

.end method






Save all changes and compile SecSettings

SystemUI part
Decompile SystemUI.apk ,download this zip Attachment 2623550 and put the drawable png in res\drawable-hdpi
Compile SystemUI and decompile the new SystemUI.apk to obtain the new ids of the new pngs
So open SystemUI\res\value\public and leave it open

Go in SystemUI\smali\com\android\systemui\statusbar\poli cy\quicksetting and open AirplaneModeQuickSettingButton,smali and add the following red lines, in blue lines some explanation
change the code from this

 





Code:


.method public constructor <init>(Landroid/content/Context;)V
    .locals 9
    .parameter "context"

    .prologue
    const/4 v7, 0x0

    .line 112
    const/4 v2, 0x0

    const v3, 0x7f0a00f5

    const v4, 0x7f0201ba

    const v5, 0x7f0201b9

    const v6, 0x7f0201b8

    move-object v0, p0

    move-object v1, p1

    move v8, v7

    invoke-direct/range {v0 .. v8}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;IIIIII)V

    .line 53






to this

 





Code:


.method public constructor <init>(Landroid/content/Context;)V
    .locals 9
    .parameter "context"

    .prologue
        invoke-virtual {p1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    const-string v2, "toggles_chooser"

    const v3, 0x0

    invoke-static {v1, v2, v3}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v1

    const v2, 0x1
       
    if-eq v2, v1, :cond_themes5
       
    const v2, 0x2
       
    if-eq v2, v1, :cond_green
       
    const v3, 0x7f0a00f5   <--this is id of text show under the icon, this remain the same in each theme

    const v4, 0x7f0201ba  <--this id id of stock tw_quick_panel_icon_airplane_on, check if it's the same of you public

    const v5, 0x7f0201b9  <--this id id of stock tw_quick_panel_icon_airplane_off, check if it's the same of you public

    const v6, 0x7f0201b8  <--this id id of stock tw_quick_panel_icon_airplane_dim, check if it's the same of you public

    goto :goto_new

    :cond_themes5

        const v3, 0x7f0a00f5
 
    const v4, 0x7f021104  <--this id id of s5stock tw_quick_panel_icon_airplane_on, check if it's the same of you public

    const v5, 0x7f021103  <--this id id of stock s5tw_quick_panel_icon_airplane_off, check if it's the same of you public

    const v6, 0x7f021102  <--this id id of stock s5tw_quick_panel_icon_airplane_dim, check if it's the same of you public
       
    goto :goto_new
       
    :cond_green
       
        const v3, 0x7f0a00f5
       
    const v4, 0x7f0210d2  <--this id id of stock greentw_quick_panel_icon_airplane_on, check if it's the same of you public

    const v5, 0x7f0210d1  <--this id id of stock greentw_quick_panel_icon_airplane_off, check if it's the same of you public

    const v6, 0x7f0210d0  <--this id id of stock greentw_quick_panel_icon_airplane_dim, check if it's the same of you public
       
    :goto_new

       
    const/4 v7, 0x0

    .line 112
    const/4 v2, 0x0

    move-object v0, p0

    move-object v1, p1

    move v8, v7

    invoke-direct/range {v0 .. v8}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;IIIIII)V

    .line 53






then apply the same code for these others smali file:
AllShareCastQuickSettingButton
AutoRotateQuickSettingButton
BluetoothQuickSettingButton
DoNotDisturbQuickSettingButton
DormantModeQuickSettingButton
DrivingModeQuickSettingButton
LocationQuickSettingButton
MobileDataQuickSettingButton
MultiWindowQuickSettingButton
NfcP2pQuickSettingButton
PowerSavingQuickSettingButton
SBeamQuickSettingButton
SilentModeQuickSettingButton
SmartStayQuickSettingButton
SyncQuickSettingButton
WifiQuickSettingButton

In the SilentModeQuickSettingButton.smali change code from this

 





Code:


.method public constructor <init>(Landroid/content/Context;)V
    .locals 9
    .parameter "context"

    .prologue
    const/4 v2, 0x0

    const v5, 0x7f0201ed

    .line 53
    const v3, 0x7f0a00ed

    const v4, 0x7f0201ec

    const/4 v6, 0x0

    const v7, 0x7f0201eb

    move-object v0, p0

    move-object v1, p1

    move v8, v5

    invoke-direct/range {v0 .. v8}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;IIIIII)V

    .line 36
    iput-object v2, p0, Lcom/android/systemui/statusbar/policy/quicksetting/SilentModeQuickSettingButton;->mAudioManager:Landroid/media/AudioManager;






to this

 





Code:


.method public constructor <init>(Landroid/content/Context;)V
    .locals 9
    .parameter "context"

    .prologue
        invoke-virtual {p1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    const-string v2, "toggles_chooser"

    const v3, 0x0

    invoke-static {v1, v2, v3}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v1

    const v2, 0x1
       
    if-eq v2, v1, :cond_themes5
       
    const v2, 0x2
       
    if-eq v2, v1, :cond_green
       
        const v5, 0x7f0201ed [COLOR="Blue"  ]this id is tw_quick_panel_icon_silent_on [/COLOR]
       
        const v3, 0x7f0a00ed  this id is for the text

    const v4, 0x7f0201ec  this id is tw_quick_panel_icon_silent_off
       
        const v7, 0x7f0201eb  this id is tw_quick_panel_icon_silent_on_on

    goto :goto_new

    :cond_themes5

        const v5, 0x7f02112a  this id is s5tw_quick_panel_icon_silent_on
       
        const v3, 0x7f0a00ed

    const v4, 0x7f021128  this id is s5tw_quick_panel_icon_silent_on
       
        const v7, 0x7f021127  this id is s5tw_quick_panel_icon_silent_on
       
    goto :goto_new
       
    :cond_green
       
        const v5, 0x7f0210f8    this id is greentw_quick_panel_icon_silent_on
       
        const v3, 0x7f0a00ed

    const v4, 0x7f0210f7  this id is greentw_quick_panel_icon_silent_on
       
        const v7, 0x7f0210f6  this id is greentw_quick_panel_icon_silent_on
       
    :goto_new[/COLOR]
       
    const/4 v2, 0x0

    .line 53
    const/4 v6, 0x0

    move-object v0, p0

    move-object v1, p1

    move v8, v5

    invoke-direct/range {v0 .. v8}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;IIIIII)V

    .line 36
    iput-object v2, p0, Lcom/android/systemui/statusbar/policy/quicksetting/SilentModeQuickSettingButton;->mAudioManager:Landroid/media/AudioManager;






For each smali files check each ids with yours in your public.xml

This part add the observer, is to change the icons theme in real time, whitout this part you need to restart device to show the changes
Go in SystemUI\smali\com\android\systemui\statusbar\poli cy\quicksetting and open QuickSettingPanel
find .method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V and add the following red lines at the end

 





Code:


    .line 99
    invoke-direct {p0}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingPanel;->update()V

    .line 100
        iget-object v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingPanel;->mContext:Landroid/content/Context;

    invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v0

    invoke-direct {p0, v0}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingPanel;->regObserver(Landroid/content/ContentResolver;)V[/COLOR]

    return-void
.end method






then add this entire in red method like this

 





Code:


.method static synthetic access0(Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingPanel;)I
    .locals 1
    .parameter "x0"

    .prologue
    .line 51
    iget v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingPanel;->mButtonCnt:I

    return v0
.end method

.method static synthetic access0(Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingPanel;)V
    .locals 0
    .parameter

    .prologue
    .line 83
    invoke-direct {p0}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingPanel;->refreshView()V

    return-void
.end method[/COLOR]

.method private disableQuickSettingButton([Ljava/lang/String;)[Ljava/lang/String;
    .locals 3






then add this entire in red method like this

 





Code:


  :cond_2
    invoke-virtual {p0, v11}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingPanel;->prepareTranslationX(Z)V

    .line 345
    return-void
.end method

.method private regObserver(Landroid/content/ContentResolver;)V
    .locals 3
    .parameter "cs"

    .prologue
    const/4 v2, 0x0

    new-instance v0, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingPanel$SettingsObserver;

    new-instance v1, Landroid/os/Handler;

    invoke-direct {v1}, Landroid/os/Handler;-><init>()V

    invoke-direct {v0, p0, p0, v1}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingPanel$SettingsObserver;-><init>(Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingPanel;Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingPanel;Landroid/os/Handler;)V

    .local v0, ob:Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingPanel$SettingsObserver;
    const-string v1, "toggles_chooser"

    invoke-static {v1}, Landroid/provider/Settings$System;->getUriFor(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    invoke-virtual {p1, v1, v2, v0}, Landroid/content/ContentResolver;->registerContentObserver(Landroid/net/Uri;ZLandroid/database/ContentObserver;)V

    return-void
.end method[/COLOR]

.method private setViewWidth()I
    .locals 5






then add this smali file Attachment 2623605 in SystemUI\smali\com\android\systemui\statusbar\poli cy\quicksetting
Save all changes and compile SystemUI, the put SecSettings.apk and SystemUI.apk in your device.









10 commentaires:

  1. This post is genuinely a pleasant one it helps new internet viewers, who are wishing for blogging.

    RépondreSupprimer
  2. I am in fact grateful to the owner of this web site who has shared this wonderful piece of writing at at this time.

    RépondreSupprimer
  3. Pretty nice post. I just stumbled upon your blog and wanted to say that I've truly enjoyed browsing your blog posts. In any case I'll be subscribing to your feed and I hope you write again very soon!

    RépondreSupprimer
  4. Do you mind if I quote a few of your articles as long as I provide credit and sources back to your site? My blog is in the very same niche as yours and my users would really benefit from a lot of the information you present here. Please let me know if this alright with you. Appreciate it!

    RépondreSupprimer
  5. Hi Dear, are you genuinely visiting this web page regularly, if so then you will without doubt take nice knowledge.

    RépondreSupprimer
  6. Very soon this web page will be famous among all blog people, due to it's good posts

    RépondreSupprimer
  7. Greetings! I know this is somewhat off topic but I was wondering which blog platform are you using for this site? I'm getting tired of Wordpress because I've had problems with hackers and I'm looking at alternatives for another platform. I would be awesome if you could point me in the direction of a good platform.

    RépondreSupprimer
  8. Hmm it seems like your site ate my first comment (it was super long) so I guess I'll just sum it up what I had written and say, I'm thoroughly enjoying your blog. I as well am an aspiring blog blogger but I'm still new to everything. Do you have any points for rookie blog writers? I'd certainly appreciate it.

    RépondreSupprimer
  9. Attractive component to content. I simply stumbled upon your weblog and in accession capital to say that I acquire actually loved account your blog posts. Anyway I will be subscribing on your feeds or even I achievement you access persistently fast.

    RépondreSupprimer