LightBlog

lundi 18 avril 2016

[MOD/TUTORIAL] [LP] Add reboot option for Systemui (the easy way)

I got asked a few times on how to add reboot option for SystemUI just like in my ROM.

Here's how it looks like: (the button next to the battery icon)



Q: Why this is the easy way?
A: Basically there are two ways to make your SystemuI restart - the one is using java/smali and the other, the easier way, is using xml editing only.
Q: How does it work?
A: In xml language for Android every element has it's own attributes, for example the button that we're going to use has an
Code:

android:onClick
attribute, this specific attribute allows to call a method from java/smali in order to start a certain function. But if no method is found the SystemUI app will force close and then automatically start again - which is what we want.


Requirements:
--- you know what compile/decompile is
--- you know what odex/deodex is
--- you have experience with flashing stuff
Warning! This mod might work on odexed roms since it doesn't mess with smali. For odexed users it is highly recommended that a back up is created.

Installation:
--- locate your SystemUI. It's in system>priv-app>SystemUI>SystemUI.apk
--- decompile
--- go to res>layout and open status_bar_expanded_header.xml
--- find the following line of code:
Code:

<TextView android:textSize="@dimen/battery_level_text_size" android:textColor="#ffffffff" android:layout_gravity="center_vertical" android:id="@id/battery_level" android:layout_width="wrap_content" android:layout_height="wrap_content" android:importantForAccessibility="noHideDescendants" android:paddingEnd="@dimen/battery_level_padding_end" android:layout_marginStart="@dimen/header_battery_margin_expanded" />
    </LinearLayout>

--- paste this code after it:
Code:

<ImageButton
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:background="@drawable/systemui_restart"
    android:layout_toStartOf="@id/multi_user_switch"
    android:onClick="selfDestruct"
    android:layout_marginRight="160dip"
    android:layout_marginTop="19dip"/>

--- save the xml file
--- the hard parts is over
--- download the attached systemUI_drawables.zip archive (non-flashable!) and put the extracted files into your systemui
--- compile and flash


When your phone reboots you should now have a reboot SystemUI option!
Happy play!

Attached Files
File Type: zip systemUI_drawables.zip - [Click for QR Code] (6.4 KB)


from xda-developers http://ift.tt/1TejKe8
via IFTTT

Aucun commentaire:

Enregistrer un commentaire