Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,808,657 Members 43,264 Now Online
XDA Developers Android and Mobile Development Forum

[Guide][How To] Adding Brightness Bar Slider to Status Bar

Tip us?
 
accts
Old
(Last edited by accts; 10th July 2013 at 07:56 PM.)
#1  
accts's Avatar
Senior Member - OP
Thanks Meter 233
Posts: 463
Join Date: Feb 2012
Location: Evergreen State
Post [Guide][How To] Adding Brightness Bar Slider to Status Bar


++++++++++++++++++++++++++++++++++

UPDATED July 10, 2013: This GUIDE was written back for ICS firmware, although it might still work for JB - I couldn't confirm that due to the fact I had stopped developing/modding. Keep in mind you need to use the latest APKtool - From Here - for JB system. Also don't forget to copy from original apk "AndroidManifest.xml" file and "META-INF" folder for the New "modded" SystemUI.apk to work.

++++++++++++++++++++++++++++++++++



I was helping a member learn how to add the brightness bar slider to his/her status bar. Since I spend a good amount of time typing it up. So I might as well post it here for everyone

General KnowledgePART I: Download resource file here: SystemX.zip

Decompile your SystemUI

Copy from the file/folder in SystemX to same location on your SystemUI:
  1. icon: /res/drawable-hdpi/quickpanel_brightness_icon.png
    (could be different folder based on your device, where ever your toggle icons put it there)
  2. file: res/layout/quickpanel_brightness_settings.xml
  3. folder: /smali/com/android/systemui/statusbar/quickpanel folder

PART II: Now you need to declare all added variants:

Ids - Open /res/values/ids.xml - Add these three lines at the end. Close & save.
Code:
    <item type="id" name="title">false</item>
    <item type="id" name="brightness_slider">false</item>
    <item type="id" name="automatic">false</item>
Strings - Open /res/values/strings.xml - Add these two lines at the end. Close & save.
Code:
    <string name="brightness_settings_title">Brightness</string>
    <string name="brightness_settings_automatic">Fixed</string>
Public - Open /res/values/public.xml - Add to end of each section - Continue with the last id called out.
Code:
....
<public type="drawable" name="quickpanel_brightness_icon" id="0x7f020166" />
....
<public type="layout" name="quickpanel_brightness_settings" id="0x7f03001e" />
...
<public type="string" name="brightness_settings_title" id="0x7f08009e" />
<public type="string" name="brightness_settings_automatic" id="0x7f08009f" />
...
<public type="id" name="title" id="0x7f0e009d" />
<public type="id" name="brightness_slider" id="0x7f0e009e" />
<public type="id" name="automatic" id="0x7f0e009f" />
*Change those in red per your ids - best open public.xml in Excel, sort by id - you will see the last number was used in each section.

PART III: Now we need to edit the Smali associated with your Public.xml Id's:

Open /smali/com/android/systemui/statusbar/quickpanel/BrightnessSettingsView.smali in Notepad++ (or similar) - Change if needed:

@ line 201
Code:
const v1, 0x7f08009e
ID associated with public.xml string section name="brightness_setting_title"
@ line 207
Code:
const v1, 0x7f08009f
ID associated with public.xml string section name="brightness_settings_automatic"
@ line 257
Code:
const v1, 0x7f0e009d
ID associated with public.xml id section name="title"
@ line 267
Code:
const v1, 0x7f0e009e
ID associated with public.xml id section name="brightness_slider"
@ line 308
Code:
const v1, 0x7f0e009f
ID associated with public.xml id section name="automatic"

Save & Close.

Open /smali/com/android/systemui/statusbar/phone/PhoneStatusBar.smali in Notepad++ (or similar)

Find this Section:
Code:
....
.method protected makeStatusBarView()Landroid/view/View;
    .locals 13

    .prologue
    const/16 v12, 0x8
.....
(very long find the last line in this section)
.....
    .line 382
    return-object v4

    .line 311
    .end local v2           #filter:Landroid/content/IntentFilter;
    .end local v6           #signalCluster:Lcom/android/systemui/statusbar/SignalClusterView;
    .end local v7           #statSysNoSim:Landroid/widget/ImageView;
    .end local v8           #tickerView:Lcom/android/systemui/statusbar/phone/TickerView;
    :catch_0
    move-exception v9

    goto/16 :goto_0
.end method
.method onBarViewAttached()V
......
In between .line 382 (this line number is not important - ignore whatever it is, only make sure it's the last line in this section) and return-object v4 - Add:
Code:
    .line 382
    const v6, 0x7f03001e

    invoke-static {v0, v6, v11}, Landroid/view/View;->inflate(Landroid/content/Context;ILandroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v5

    check-cast v5, Lcom/android/systemui/statusbar/quickpanel/BrightnessSettingsView;

    invoke-virtual {v5}, Lcom/android/systemui/statusbar/quickpanel/BrightnessSettingsView;->init()V

    iget-object v6, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mExpandedView:Lcom/android/systemui/statusbar/phone/ExpandedView;

    const/4 p0, 0x1

    invoke-virtual {v6, v5, p0}, Lcom/android/systemui/statusbar/phone/ExpandedView;->addView(Landroid/view/View;I)V

    return-object v4
ID associated with public.xml layout section name="quickpanel_brightness_settings"

Note: If you already had Toggle Mod - It should look like this:
Code:
    .line 382
    iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBroadcastReceiver:Landroid/content/BroadcastReceiver;

    invoke-virtual {v0, v9, v2}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    const v6, 0x7f03001c

    invoke-static {v0, v6, v11}, Landroid/view/View;->inflate(Landroid/content/Context;ILandroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v5

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

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

    iget-object v6, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mExpandedView:Lcom/android/systemui/statusbar/phone/ExpandedView;

    invoke-virtual {v6, v5, v11}, Lcom/android/systemui/statusbar/phone/ExpandedView;->addView(Landroid/view/View;I)V

    const v6, 0x7f03001e

    invoke-static {v0, v6, v11}, Landroid/view/View;->inflate(Landroid/content/Context;ILandroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v5

    check-cast v5, Lcom/android/systemui/statusbar/quickpanel/BrightnessSettingsView;

    invoke-virtual {v5}, Lcom/android/systemui/statusbar/quickpanel/BrightnessSettingsView;->init()V

    iget-object v6, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mExpandedView:Lcom/android/systemui/statusbar/phone/ExpandedView;

    const/4 p0, 0x1

    invoke-virtual {v6, v5, p0}, Lcom/android/systemui/statusbar/phone/ExpandedView;->addView(Landroid/view/View;I)V

     return-object v4
Save & Close

PART IV: Compile & push to your system, don't forget to set your permission to rw-r--r-- ! DONE.

The End: That's all - Wasn't that hard, wasn't it ? .... Good Luck !!!

Disclaimer:
Quote:
I didn't write up the code for quickpanel brightness settings, it has been pass on from forum to forum - I do not know the original author. If it's your please let me know so we all can give proper thanks.
The Following 42 Users Say Thank You to accts For This Useful Post: [ Click to Expand ]
 
accts
Old
#2  
accts's Avatar
Senior Member - OP
Thanks Meter 233
Posts: 463
Join Date: Feb 2012
Location: Evergreen State
+1
The Following 3 Users Say Thank You to accts For This Useful Post: [ Click to Expand ]
 
panchuckles
Old
#3  
panchuckles's Avatar
Senior Member
Thanks Meter 23
Posts: 191
Join Date: Jun 2011
Location: antofagasta
+thanks for you.

Yeeeah, I think we need more people like you
 
Warren87
Old
#4  
Senior Member
Thanks Meter 108
Posts: 532
Join Date: May 2012
thanks for the tutorial.
I’ve learned… That life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
 
fcb13
Old
#5  
fcb13's Avatar
Senior Member
Thanks Meter 101
Posts: 589
Join Date: Nov 2010
How would you go about removing the brightness bar (manually)?
 
accts
Old
#6  
accts's Avatar
Senior Member - OP
Thanks Meter 233
Posts: 463
Join Date: Feb 2012
Location: Evergreen State
Quote:
Originally Posted by fcb13 View Post
How would you go about removing the brightness bar (manually)?
The quickest way is take out the Added code in the PhoneStatusBar.smali. You can ignore the rest. But it would be more clean if you reverse the guide.
 
d3cka
Old
#7  
d3cka's Avatar
Senior Member
Thanks Meter 338
Posts: 546
Join Date: Jul 2012
is it working on other phone such samsung or only xperia??
 
accts
Old
#8  
accts's Avatar
Senior Member - OP
Thanks Meter 233
Posts: 463
Join Date: Feb 2012
Location: Evergreen State
Quote:
Originally Posted by d3cka View Post
is it working on other phone such samsung or only xperia??
NO, this guide is for Xperia - Samsung had a different layout in SystemUI
 
d3cka
Old
#9  
d3cka's Avatar
Senior Member
Thanks Meter 338
Posts: 546
Join Date: Jul 2012
Ohh thanks for the answer

Sent from my GT-S5360 using xda premium
 
pillum
Old
#10  
Member
Thanks Meter 10
Posts: 96
Join Date: Nov 2012
can someuone upload the edited SystemUI? I dont have a pc right now only phone

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes