Post Reply

[GUIDE][MOD][GB]Settings Shortcut in StatusBar [New method] 25/02/2013

22nd September 2012, 02:22 PM   |  #1  
b16h22's Avatar
OP Recognized Themer
Flag Intercooler piping
Thanks Meter: 2,016
 
1,113 posts
Join Date:Joined: Apr 2012
More
Quote:

Well,this new method is much much easier than the old method.Minimal smali editing is involved.So even newbies can follow it.

Quote:

You are going to need

1.SystemUI.apk
2.Apk manager,virtuos ten studio or any apk compiling/decompiling tool
3.Notepad++
4.Patience and some time.



STEP 1Decompile your SystemUI.apk and go to status_bar_expanded.xml.Open the file and look for this (stock systemUI).


Code:
<com.android.systemui.statusbar.CarrierLabel android:textSize="17.659973dip" android:textColor="#ffffffff" android:layout_gravity="center_vertical" android:orientation="vertical" android:paddingBottom="1.0dip" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_marginLeft="5.0dip" android:layout_marginTop="1.0dip" android:layout_weight="1.0" />
paste this code below that


Code:
<ImageView android:layout_gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="fill_parent" android:src="@drawable/ic_notify_quicksettings" android:onClick="settingsButton" />

Now save the file.

Code:
 android:onClick="settingsButton"
is an xml attribute used to call a method when pressing something.Now the settingsButton is the name of the method.

Note;It doesnt matter where you put the code for settings button in statusbar expanded.The above steps are for sgy users.You can put that code anywhere you want.But think logical and use common sense.


STEP 2 Now we can add the method settingsButton to StatusBarService.smali.Open the file and look for the code


Code:
# virtual methods
Paste this method below

Code:
.method public settingsButton(Landroid/view/View;)V
    .locals 3
    .parameter "v"

    .prologue
    .line 1717
    invoke-virtual {p1}, Landroid/view/View;->getContext()Landroid/content/Context;

    move-result-object v0

    new-instance v1, Landroid/content/Intent;

    const-string v2, "android.settings.SETTINGS"

    invoke-direct {v1, v2}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    const/high16 v2, 0x1000

    invoke-virtual {v1, v2}, Landroid/content/Intent;->setFlags(I)Landroid/content/Intent;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V

    invoke-virtual {p0}, Lcom/android/systemui/statusbar/StatusBarService;->animateCollapse()V
	
    .line 1720
    return-void
.end method
Now save the file.

android.settings.SETTINGS is the intent for calling settings app activity.You can change the intent to call diffrent activities.For example


Quote:

android.settings.WIRELESS_SETTINGS -wireless and network settings
android.settings.WIFI_SETTINGS -Wifi settings
android.intent.action.POWER_USAGE_SUMMARY -Battery usage summary


STEP 3Now download and extract this Settings_shortcut_drawables.zip.Put the ic_notify_quicksettings.xml inside your drawable folder and the the other two pngs inside drawable-ldpi folder.


STEP 4Now compile and push.


Quote:

Before asking doubts think twice always.If there is any error in the codes,do let me know.Happy to help.







Old method
Actually this mod is not made by me.I've just ported it and found the way to implement this in other roms.I've studied the SystemUI.apk from the theme by C.O.D.<D.J> for creed's rom.So all credit goes to him

Quote:

EDIT:There is a small correction in the code

Code:
invoke-direct {v0, p0}, Lcom/android/systemui/statusbar/StatusBarService$8;-><init>(Lcom/android/systemui/statusbar/StatusBarService;)V
.I've forgot to add <init> after 'StatusBarService$8;->' in the guide.Thanks to 'chevanlol360' for pointing out this error.


It's easy if you follow every step correctly

STEP 1: Decompile the SystemUI.apk.There are several threads around xda to show you how to decompile an apk.Navigate to res/layout/ and find status_bar_expanded.xml.Find the following code in the file

Code:
<com.android.systemui.statusbar.CarrierLabel android:textSize="17.659973dip" android:textColor="#ffffffff" android:layout_gravity="center_vertical" android:orientation="vertical" android:paddingBottom="1.0dip" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_marginLeft="5.0dip" android:layout_marginTop="1.0dip" android:layout_weight="1.0" />
Paste this code just below it

Code:
<ImageView android:layout_gravity="center_vertical" android:id="@id/settings_button" android:paddingLeft="0.0dip" android:paddingTop="0.0dip" android:paddingRight="8.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:src="@drawable/ic_notify_quicksettings" android:contentDescription="@string/accessibility_settings_button" />
Now save and close the file.

STEP 2.Open res/values/strings.xml.And add this line at the end

Code:
<string name="accessibility_settings_button">System settings.</string>
Save and close the file

STEP 3.Open res/values/ids.xml and paste this code at the end

Code:
<item type="id" name="settings_button">false</item>
Save and close the file.

STEP 4.Now extract the files from the attached zip.Take "ic_notify_quicksettings.xml' and put it in res/drawable/.Take 'ic_settings_normal.png' and 'ic_settings_pressed.png' and put it in res/drawable-ldpi/.


Now recompile the apk and push it to system/app to make sure the settings button is there and everything look right.Now decompile that systemUI.apk again.Navigate to res/values/ .We need to find an id from public.xml

STEP 5.Now open public.xml and find this line

Code:
<public type="id" name="settings_button" id="0x7f090027" />
Remember the id highlighted in red above.We need to use it.


STEP 6.Open StatusBarService.smali and find this line of code

Code:
.field mScrollView:Landroid/widget/ScrollView;
Paste this code below it

Code:
.field mSettingsBut:Landroid/view/View;

.field private mSettingsButListener:Landroid/view/View$OnClickListener;
Now find this code

Code:
    iput-object v0, p0, Lcom/android/systemui/statusbar/StatusBarService;->mStopTracing:Ljava/lang/Runnable;
Paste this code below

Code:
    .line 1703
    new-instance v0, Lcom/android/systemui/statusbar/StatusBarService$8;

    invoke-direct {v0, p0}, Lcom/android/systemui/statusbar/StatusBarService$8;-><init>(Lcom/android/systemui/statusbar/StatusBarService;)V

    iput-object v0, p0, Lcom/android/systemui/statusbar/StatusBarService;->mSettingsButListener:Landroid/view/View$OnClickListener;

    return-void
Now again find this code

Code:
    iput v7, p0, Lcom/android/systemui/statusbar/StatusBarService;->mEdgeBorder:I
And paste this code below

Code:
    .line 333
    const v7, 0x7f090027

    invoke-virtual {v1, v7}, Lcom/android/systemui/statusbar/ExpandedView;->findViewById(I)Landroid/view/View;

    move-result-object v7

    iput-object v7, p0, Lcom/android/systemui/statusbar/StatusBarService;->mSettingsBut:Landroid/view/View;

    .line 334
    iget-object v7, p0, Lcom/android/systemui/statusbar/StatusBarService;->mSettingsBut:Landroid/view/View;

    iget-object v8, p0, Lcom/android/systemui/statusbar/StatusBarService;->mSettingsButListener:Landroid/view/View$OnClickListener;

    invoke-virtual {v7, v8}, Landroid/view/View;->setOnClickListener(Landroid/view/View$OnClickListener;)V

The id highlighted in red must be the same as the id from public.xml.So make sure it's the same.Now save and close the file.

STEP 7.Take 'StatusBarService$8.smali' from the attached zip an put it in com/android/systemui/statusbar/.

STEP 8.Now recompile the apk and push it to system/app/ and put the permission rw--r--r--.


If you want to get the feel of it in your stock statusbar i've made one for you just in case. Download it from here:

DOWNLOAD



Flash it through recovery.If you are running an odexed rom,delete SystemUI.odex from system/app before you flash the zip.
Attached Files
File Type: zip settings_shortcut_files.zip - [Click for QR Code] (8.0 KB, 1622 views)
Last edited by b16h22; 25th February 2013 at 03:44 PM.
The Following 70 Users Say Thank You to b16h22 For This Useful Post: [ View ]
22nd September 2012, 02:23 PM   |  #2  
The_animaToR's Avatar
Senior Member
Flag Delhi
Thanks Meter: 52
 
315 posts
Join Date:Joined: Jul 2012
More
Awesome tutorial....
Will impliment this in my upcoming custom rom....lol
Last edited by The_animaToR; 22nd September 2012 at 02:27 PM.
The Following User Says Thank You to The_animaToR For This Useful Post: [ View ]
22nd September 2012, 02:51 PM   |  #3  
Senior Member
Flag Toronto
Thanks Meter: 628
 
932 posts
Join Date:Joined: Apr 2012
More
Thumbs up
great tutorial, but stuck on first step as i cant find those lines in my statusbarexpanded.xml , btw i have a galaxy gio but here is my systemui, can you take a look?
Attached Files
File Type: apk SystemUI.apk - [Click for QR Code] (441.0 KB, 156 views)
22nd September 2012, 02:57 PM   |  #4  
b16h22's Avatar
OP Recognized Themer
Flag Intercooler piping
Thanks Meter: 2,016
 
1,113 posts
Join Date:Joined: Apr 2012
More
Quote:
Originally Posted by alkspo

great tutorial, but stuck on first step as i cant find those lines in my statusbarexpanded.xml , btw i have a galaxy gio but here is my systemui, can you take a look?

I'll look into it.I'm not near my pc.Actually step 1 puts the settings left to carrier text.You can add that code before the code for clear button.

sent while doin' some burnouts
22nd September 2012, 03:12 PM   |  #5  
Senior Member
Flag Toronto
Thanks Meter: 628
 
932 posts
Join Date:Joined: Apr 2012
More
alright, will tr, thanks
22nd September 2012, 03:24 PM   |  #6  
YudhiezChitilieaz's Avatar
Senior Member
Flag INDONESIA
Thanks Meter: 470
 
283 posts
Join Date:Joined: Mar 2012
Donate to Me
More
How to move 15toogle to down settings button
Quote:
Originally Posted by alkspo

great tutorial, but stuck on first step as i cant find those lines in my statusbarexpanded.xml , btw i have a galaxy gio but here is my systemui, can you take a look?

if the Statusbar have this code :

Code:
    .line 338
    .local v4, qsv:Lcom/android/systemui/statusbar/quickpanel/QuickSettingsView;
    const-string v8, "ro.csc.sales_code"

    invoke-static {v8}, Landroid/os/SystemProperties;->get(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    .line 339
    .local v1, code:Ljava/lang/String;
    const-string v8, "XEC"

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

    move-result v8

    if-eqz v8, :cond_1
you can delete it ,

If the statusbar have this :

Code:
    .line 340
    const v8, 0x7f030003

    invoke-static {p1, v8, v10}, Landroid/view/View;->inflate(Landroid/content/Context;ILandroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v4

    .end local v4           #qsv:Lcom/android/systemui/statusbar/quickpanel/QuickSettingsView;
    check-cast v4, Lcom/android/systemui/statusbar/quickpanel/QuickSettingsView;

    .line 348
    .restart local v4       #qsv:Lcom/android/systemui/statusbar/quickpanel/QuickSettingsView;
    :goto_0
    iget-object v8, p0, Lcom/android/systemui/statusbar/StatusBarService;->mExpandedView:Lcom/android/systemui/statusbar/ExpandedView;

    invoke-virtual {v8, v4, v13}, Lcom/android/systemui/statusbar/ExpandedView;->addView(Landroid/view/View;I)V
and delete this :
Code:
    .line 344
    :cond_1
    const v8, 0x3030003

    invoke-static {p1, v8, v10}, Landroid/view/View;->inflate(Landroid/content/Context;ILandroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v4

    check-cast v4, Lcom/lidroid/systemui/quickpanel/PowerWidget;

    .local v4, qsv:Lcom/lidroid/systemui/quickpanel/PowerWidget;
    invoke-virtual {v4}, Lcom/lidroid/systemui/quickpanel/PowerWidget;->setupWidget()V

    goto :goto_0
you can change into :

so the line like as :

Code:
    .line 337
    const/4 v4, 0x0

    .line 344
    const v8, 0x3030003

    invoke-static {p1, v8, v10}, Landroid/view/View;->inflate(Landroid/content/Context;ILandroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v4

    check-cast v4, Lcom/lidroid/systemui/quickpanel/PowerWidget;

    .line 348
    .local v4, qsv:Lcom/lidroid/systemui/quickpanel/PowerWidget;
    const/4 v9, 0x1

    invoke-virtual {v4}, Lcom/lidroid/systemui/quickpanel/PowerWidget;->setupWidget()V

    iget-object v8, p0, Lcom/android/systemui/statusbar/StatusBarService;->mExpandedView:Lcom/android/systemui/statusbar/ExpandedView;

    invoke-virtual {v8, v4, v9}, Lcom/android/systemui/statusbar/ExpandedView;->addView(Landroid/view/View;I)V

    .line 352
    new-instance v8, Landroid/widget/LinearLayout;

    invoke-direct {v8, p1}, Landroid/widget/LinearLayout;-><init>(Landroid/content/Context;)V

    iput-object v8, p0, Lcom/android/systemui/statusbar/StatusBarService;->mMiniCon:Landroid/widget/LinearLayout;

    .line 353
    iget-object v8, p0, Lcom/android/systemui/statusbar/StatusBarService;->mMiniCon:Landroid/widget/LinearLayout;

    const/4 v9, 0x1

    invoke-virtual {v8, v9}, Landroid/widget/LinearLayout;->setOrientation(I)V

    .line 354
    iget-object v8, p0, Lcom/android/systemui/statusbar/StatusBarService;->mExpandedView:Lcom/android/systemui/statusbar/ExpandedView;

    invoke-virtual {v8, v12}, Lcom/android/systemui/statusbar/ExpandedView;->findViewById(I)Landroid/view/View;

    move-result-object v8

    check-cast v8, Landroid/widget/LinearLayout;

    iget-object v9, p0, Lcom/android/systemui/statusbar/StatusBarService;->mMiniCon:Landroid/widget/LinearLayout;

    invoke-virtual {v8, v9, v13}, Landroid/widget/LinearLayout;->addView(Landroid/view/View;I)V

    .line 358
    const v8, 0x7f030005

    invoke-static {p1, v8, v10}, Landroid/view/View;->inflate(Landroid/content/Context;ILandroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v8

    check-cast v8, Lcom/android/systemui/statusbar/CallOnGoingView;

    iput-object v8, p0, Lcom/android/systemui/statusbar/StatusBarService;->mCallOnGoingView:Lcom/android/systemui/statusbar/CallOnGoingView;

    .line 359
    iget-object v8, p0, Lcom/android/systemui/statusbar/StatusBarService;->mCallOnGoingView:Lcom/android/systemui/statusbar/CallOnGoingView;

    iput-object p0, v8, Lcom/android/systemui/statusbar/CallOnGoingView;->mService:Lcom/android/systemui/statusbar/StatusBarService;

    .line 361
    return-void
.end method
Here you go , iam modify you systemui . view you new systemui . and Trying to Experiment xD . view my attatch

and i thinks the Guide not working on CM .
Thanks you, AWESOME Guide
Attached Files
File Type: apk SystemUI.apk - [Click for QR Code] (442.4 KB, 126 views)
Last edited by YudhiezChitilieaz; 22nd September 2012 at 03:33 PM.
The Following 2 Users Say Thank You to YudhiezChitilieaz For This Useful Post: [ View ]
22nd September 2012, 03:31 PM   |  #7  
Deadly's Avatar
Recognized Contributor
Flag Bangalore
Thanks Meter: 3,944
 
10,186 posts
Join Date:Joined: Jul 2012
Donate to Me
More
Thanks for this tutorial mate! awesome as always will try this after i come back..
Last edited by Deadly; 22nd September 2012 at 04:01 PM.
The Following 2 Users Say Thank You to Deadly For This Useful Post: [ View ]
22nd September 2012, 03:48 PM   |  #8  
kentoi me's Avatar
Senior Member
Flag lost city
Thanks Meter: 38
 
410 posts
Join Date:Joined: Feb 2012
More
Boooom..! Pin! Thanks for this great tut bro... now i know.. i really mis the smalis.. haha i really hate smali...
____________________________________
Reserve for future use..

send thru postal codes supported with busybox command again
22nd September 2012, 03:59 PM   |  #9  
Senior Member
Flag Toronto
Thanks Meter: 628
 
932 posts
Join Date:Joined: Apr 2012
More
thanks for doing it for me, but my device is mdpi not hdpi, so will not work, can you make it again?
22nd September 2012, 04:28 PM   |  #10  
YudhiezChitilieaz's Avatar
Senior Member
Flag INDONESIA
Thanks Meter: 470
 
283 posts
Join Date:Joined: Mar 2012
Donate to Me
More
Quote:
Originally Posted by alkspo

thanks for doing it for me, but my device is mdpi not hdpi, so will not work, can you make it again?

If the resolution png (too small) with a resolution of handle you then I rename a ldpi, if png (fit) with a screen resolution of your handle then I rename a mdpi, if the png does not fit the screen resolution of your handle (too big) then I rename a hdpi .
thats trick to make png no zoom ( big or small icon ) . and make to past you screen resolution .
try my mods . push to system/app

sorry for bad english
Last edited by YudhiezChitilieaz; 22nd September 2012 at 04:34 PM.

The Following 2 Users Say Thank You to YudhiezChitilieaz For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools
Display Modes


Top Threads in Galaxy Y GT-S5360 Themes and Apps by ThreadRank