Post Reply

[TUT][MOD] Add A Brightness Bar To Stock 4.4.2 And 4.4.4!

OP Ticklefish

15th September 2014, 05:21 PM   |  #1  
Ticklefish's Avatar
OP Recognized Themer
Flag UK
Thanks Meter: 3,599
 
4,052 posts
Join Date:Joined: Oct 2011
More

Are you running a stock 4.4.2 or 4.4.4 Xperia rom? Or even a rom based on stock like MoonWalker or Ultimate PureXZ?

Yes?

Would you like to add a brightness bar to your pull-down screen?

Yes?

Then read on and I'll tell you how to do it!

For this mod, you need to decompile your rom's SystemUI.apk. If you don't know how to do that, I suggest finding out before you go any further.
Have a look at Tickle My Android (tinyurl.com/ticklemyandroid) if you want to use one of the best decompiling tools on the planet..

Once you've decompiled SystemUI.apk, edit res\layout\somc_quick_settings_tab.xml..

Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <com.sonymobile.systemui.statusbar.tools.LayoutAnimationView android:orientation="vertical" android:id="@id/quick_settings_tab" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layoutDirection="ltr">
        <GridLayout android:id="@id/tools_rows" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/notification_panel_tools_padding_top" android:animateLayoutChanges="true" />
        <View android:id="@id/divider" android:background="@android:drawable/divider_horizontal_dark" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="1.0dip" />
        <HorizontalScrollView android:scrollbarStyle="insideOverlay" android:id="@id/unused_tools_scroll_view" android:background="@drawable/somc_quick_settings_edit" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="wrap_content" android:minHeight="@dimen/unused_tools_minimum_height">
            <GridLayout android:id="@id/unused_tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minHeight="@dimen/unused_tools_minimum_height" android:animateLayoutChanges="true" android:rowCount="1" />
        </HorizontalScrollView>
        <View android:id="@id/divider_bottom" android:background="@drawable/somc_statusbar_edit_close" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="1.0dip" />
    </com.sonymobile.systemui.statusbar.tools.LayoutAnimationView>
</FrameLayout>
Add this line above the GridLayout:

Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <com.sonymobile.systemui.statusbar.tools.LayoutAnimationView android:orientation="vertical" android:id="@id/quick_settings_tab" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layoutDirection="ltr">
        <include android:layout_width="fill_parent" android:layout_height="wrap_content" layout="@layout/ticklefish_brightness_dialog" />
	<GridLayout android:id="@id/tools_rows" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/notification_panel_tools_padding_top" android:animateLayoutChanges="true" />
        <View android:id="@id/divider" android:background="@android:drawable/divider_horizontal_dark" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="1.0dip" />
        <HorizontalScrollView android:scrollbarStyle="insideOverlay" android:id="@id/unused_tools_scroll_view" android:background="@drawable/somc_quick_settings_edit" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="wrap_content" android:minHeight="@dimen/unused_tools_minimum_height">
            <GridLayout android:id="@id/unused_tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minHeight="@dimen/unused_tools_minimum_height" android:animateLayoutChanges="true" android:rowCount="1" />
        </HorizontalScrollView>
        <View android:id="@id/divider_bottom" android:background="@drawable/somc_statusbar_edit_close" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="1.0dip" />
    </com.sonymobile.systemui.statusbar.tools.LayoutAnimationView>
</FrameLayout>
This will now put a brightness bar above the grid with all the quick settings. However, it doesn't actually do anything. Yet...

Now edit smali\com\android\systemui\statusbar\phone\PhoneSt atusBar.smali.

After the last .field line, insert the line in red..

Code:
.field private mUserSetupObserver:Landroid/database/ContentObserver;

.field private mBrightnessController:Lcom/android/systemui/settings/BrightnessController;
Then, under # direct methods, insert this code..

Code:
# direct methods
.method private setUpBrightnessSlider()V
    .locals 4

    .prologue
    .line 196
    iget-object v2, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mNotificationPanel:Lcom/android/systemui/statusbar/phone/NotificationPanelView;

    const v0, 0x7f08004c

    invoke-virtual {v2, v0}, Lcom/android/systemui/statusbar/phone/NotificationPanelView;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/ImageView;

    const v1, 0x7f08004d

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

    move-result-object v1

    check-cast v1, Lcom/android/systemui/settings/ToggleSlider;

    new-instance v2, Lcom/android/systemui/settings/BrightnessController;
	
    iget-object v3, p0, Lcom/android/systemui/SystemUI;->mContext:Landroid/content/Context;
	
    invoke-direct {v2, v3, v0, v1}, Lcom/android/systemui/settings/BrightnessController;-><init>(Landroid/content/Context;Landroid/widget/ImageView;Lcom/android/systemui/settings/ToggleSlider;)V

    .line 199
    iput-object v2, p0, Lcom/android/systemui/settings/BrightnessDialog;->mBrightnessController:Lcom/android/systemui/settings/BrightnessController;
	
    .line 201
    return-void
.end method
Open up res\values\public.xml, look up the reference for brightness_icon and replace 0x7f08004c in the code above with it.

Then look up the reference for brightness_slider and replace 0x7f08004d with it in the code above.

Finally, find this code in your smali:

Code:
    const-string v0, "com.sonymobile.notes.NEW_SKETCH"

    invoke-direct {p0, v0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->isAppInstalled(Ljava/lang/String;)Z

    move-result v0

    iput-boolean v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mRightVisible:Z
Directly underneath that code, put this line:

Code:
    const-string v0, "com.sonymobile.notes.NEW_SKETCH"

    invoke-direct {p0, v0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->isAppInstalled(Ljava/lang/String;)Z

    move-result v0

    iput-boolean v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mRightVisible:Z

    invoke-direct {p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->setUpBrightnessSlider()V
The last thing you need to do is extract the xml from the attached zip file and copy it into your SystemUI.apk\res\layout\ folder.

Save everything, recompile and flash back to your phone, wait for everything to load and...there's your brightness bar!

(Please note, this is meant for stock Xperia 4.4.2 and 4.4.4 roms only. If you have something else, this mod probably won't work for you. And please don't ask me to make it work.)

Credits for this mod entirely go to The Master, @serajr, for his help with the smali. Get well soon, my friend!
Attached Files
File Type: zip ticklefish_brightness_dialog.zip - [Click for QR Code] (656 Bytes, 15 views)
Last edited by Ticklefish; 18th September 2014 at 12:51 PM.
The Following 4 Users Say Thank You to Ticklefish For This Useful Post: [ View ]
15th September 2014, 06:31 PM   |  #2  
serajr's Avatar
Recognized Developer / Recognized Themer
Flag Rafard - SP
Thanks Meter: 10,169
 
2,658 posts
Join Date:Joined: Apr 2011
Donate to Me
More
Thumbs up Great sharing!!
Awesome and very well written my friend! Congrats!!!
The Following User Says Thank You to serajr For This Useful Post: [ View ]
15th September 2014, 10:12 PM   |  #3  
Pandemic's Avatar
Senior Member
Flag MePpEl
Thanks Meter: 11,922
 
15,698 posts
Join Date:Joined: Aug 2010
Donate to Me
More
nice tut bro
heads off
The Following User Says Thank You to Pandemic For This Useful Post: [ View ]
16th September 2014, 05:32 AM   |  #4  
rer3's Avatar
Senior Member
Flag Bandung
Thanks Meter: 51
 
179 posts
Join Date:Joined: Aug 2013
More
thanks mate, but how to get rid of the "adapt to lighting conditions" tick box ?
The Following User Says Thank You to rer3 For This Useful Post: [ View ]
16th September 2014, 07:38 AM   |  #5  
Ticklefish's Avatar
OP Recognized Themer
Flag UK
Thanks Meter: 3,599
 
4,052 posts
Join Date:Joined: Oct 2011
More
Quote:
Originally Posted by rer3

thanks mate, but how to get rid of the "adapt to lighting conditions" tick box ?

You just need to edit 'quick_settings_brightness_dialog.xml'.. [emoji1]

--------------------------------
Sent via Tapatalk
---------------------------
The Following User Says Thank You to Ticklefish For This Useful Post: [ View ]
16th September 2014, 08:46 AM   |  #6  
rer3's Avatar
Senior Member
Flag Bandung
Thanks Meter: 51
 
179 posts
Join Date:Joined: Aug 2013
More
Quote:
Originally Posted by Ticklefish

You just need to edit 'quick_settings_brightness_dialog.xml'.. [emoji1]

--------------------------------
Sent via Tapatalk
---------------------------

It's gone, but whenever I touch brightness' quick setting tile, the systemui crashed.

EDIT:
solved, just create another "quick_settings_brightness_dialog.xml". one for the quick setting tile, and one for the statusbar's brightness slider.
Last edited by rer3; 16th September 2014 at 08:59 AM.
The Following User Says Thank You to rer3 For This Useful Post: [ View ]
16th September 2014, 11:04 AM   |  #7  
Ticklefish's Avatar
OP Recognized Themer
Flag UK
Thanks Meter: 3,599
 
4,052 posts
Join Date:Joined: Oct 2011
More
Quote:
Originally Posted by rer3

It's gone, but whenever I touch brightness' quick setting tile, the systemui crashed.

EDIT:
solved, just create another "quick_settings_brightness_dialog.xml". one for the quick setting tile, and one for the statusbar's brightness slider.

Hmm..I didn't know that. On my setup I used a different xml for the brightness bar as well. I didn't put that in the OP to keep it simple.
I'll have to update the OP with a separate xml file for those who like to mod it.

Many thanks for bringing it to my attention! ☺

--------------------------------
Sent via Tapatalk
---------------------------
16th September 2014, 12:17 PM   |  #8  
rer3's Avatar
Senior Member
Flag Bandung
Thanks Meter: 51
 
179 posts
Join Date:Joined: Aug 2013
More
Quote:
Originally Posted by Ticklefish

Hmm..I didn't know that. On my setup I used a different xml for the brightness bar as well. I didn't put that in the OP to keep it simple.
I'll have to update the OP with a separate xml file for those who like to mod it.

Many thanks for bringing it to my attention! ☺

--------------------------------
Sent via Tapatalk
---------------------------

No problem mate, I'm still searching for a way to make the slider thinner, to save some place.

Sent from my C6603 using XDA Free mobile app
17th September 2014, 01:34 AM   |  #9  
Junior Member
Thanks Meter: 3
 
11 posts
Join Date:Joined: Sep 2014
Ticklefish hello:
Thank you for everything you have done for a very, my phone is z1,4.4.4, attempts to modify SystemUI.apk file according to your approach leads to boot error, I uploaded my cell phone PhoneStatusBar.smali.
File, can you help me to check under it? I need this brightness slider, thank you!
Attached Files
File Type: zip PhoneStatusBar.zip - [Click for QR Code] (815.0 KB, 3 views)
The Following User Says Thank You to liwenfei For This Useful Post: [ View ]
17th September 2014, 08:18 AM   |  #10  
Ticklefish's Avatar
OP Recognized Themer
Flag UK
Thanks Meter: 3,599
 
4,052 posts
Join Date:Joined: Oct 2011
More
Quote:
Originally Posted by liwenfei

Ticklefish hello:
Thank you for everything you have done for a very, my phone is z1,4.4.4, attempts to modify SystemUI.apk file according to your approach leads to boot error, I uploaded my cell phone PhoneStatusBar.smali.
File, can you help me to check under it? I need this brightness slider, thank you!

It would be very helpful if you can share your molded smali and a logcat if possible. That way I can see why your mod didn't work.
Otherwise I might just make the same changes and it'd take longer to fix..

--------------------------------
Sent via Tapatalk
---------------------------

Post Reply Subscribe to Thread

Tags
brightness bar, serajr, smali
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Sony Cross-Device Development Themes and Apps by ThreadRank