Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,812,470 Members 41,522 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
b16h22
Old
(Last edited by b16h22; 25th February 2013 at 03:44 PM.)
#1  
b16h22's Avatar
Recognized Themer - OP
Thanks Meter 2,010
Posts: 1,111
Join Date: Apr 2012
Location: Intercooler piping
Default [GUIDE][MOD][GB]Settings Shortcut in StatusBar [New method] 25/02/2013

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, 1616 views)
The Following 70 Users Say Thank You to b16h22 For This Useful Post: [ Click to Expand ]
 
The_animaToR
Old
(Last edited by The_animaToR; 22nd September 2012 at 02:27 PM.)
#2  
The_animaToR's Avatar
Senior Member
Thanks Meter 52
Posts: 315
Join Date: Jul 2012
Location: Delhi
Awesome tutorial....
Will impliment this in my upcoming custom rom....lol
The Following User Says Thank You to The_animaToR For This Useful Post: [ Click to Expand ]
 
alkspo
Old
#3  
Senior Member
Thanks Meter 627
Posts: 932
Join Date: Apr 2012
Location: Toronto
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)
 
b16h22
Old
#4  
b16h22's Avatar
Recognized Themer - OP
Thanks Meter 2,010
Posts: 1,111
Join Date: Apr 2012
Location: Intercooler piping
Quote:
Originally Posted by alkspo View Post
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
 
alkspo
Old
#5  
Senior Member
Thanks Meter 627
Posts: 932
Join Date: Apr 2012
Location: Toronto
alright, will tr, thanks
 
YudhiezChitilieaz
Old
(Last edited by YudhiezChitilieaz; 22nd September 2012 at 03:33 PM.)
#6  
YudhiezChitilieaz's Avatar
Senior Member
Thanks Meter 470
Posts: 283
Join Date: Mar 2012
Location: INDONESIA

 
DONATE TO ME
Default How to move 15toogle to down settings button

Quote:
Originally Posted by alkspo View Post
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)
The Following 2 Users Say Thank You to YudhiezChitilieaz For This Useful Post: [ Click to Expand ]
 
Deadly
Old
(Last edited by Deadly; 22nd September 2012 at 04:01 PM.)
#7  
Deadly's Avatar
Recognized Contributor
Thanks Meter 3,942
Posts: 10,182
Join Date: Jul 2012
Location: Bangalore

 
DONATE TO ME
Thanks for this tutorial mate! awesome as always will try this after i come back..
"Thanks button is just to avoid "thanks" posts in threads. Nothing more than that. Don't ask in signature or post for it and defeat the purpose why it was introduced"
The Following 2 Users Say Thank You to Deadly For This Useful Post: [ Click to Expand ]
 
kentoi me
Old
#8  
kentoi me's Avatar
Senior Member
Thanks Meter 38
Posts: 410
Join Date: Feb 2012
Location: lost city
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
....waiting for improvement... good job guys and more power..

 
alkspo
Old
#9  
Senior Member
Thanks Meter 627
Posts: 932
Join Date: Apr 2012
Location: Toronto
thanks for doing it for me, but my device is mdpi not hdpi, so will not work, can you make it again?
 
YudhiezChitilieaz
Old
(Last edited by YudhiezChitilieaz; 22nd September 2012 at 04:34 PM.)
#10  
YudhiezChitilieaz's Avatar
Senior Member
Thanks Meter 470
Posts: 283
Join Date: Mar 2012
Location: INDONESIA

 
DONATE TO ME
Quote:
Originally Posted by alkspo View Post
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

The Following 2 Users Say Thank You to YudhiezChitilieaz For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes