[Android General] Grouxho:
Advanced Power Menu - Up to 15 Toggles, custom colors...

This guide is only for Samsung Oreo device. Tested in S7e and s9

This guide is based on s7e firmware. However in the attached file you will also have all the modifications for s9

1.- Features:

A.- Toggles

- Select up to 15 toggles: power, restart, download, recovery, emergency, data mode, airplane mode, screen capture, screen recording, sound mode, flash light, settings, voice assist, google assist and customizable toggle

- Customizable toggles order

- Select what toggles will require confirmation (power, restar, recovery, download)

- In those toggles where icons in framework-res were ugly the icons were fixed by adding them to ui.

- For existing settings, voice assistant and google assistant toggles the exceptions when the corresponding app is not installed are catched. Added code to try to unlock in these toggles.

- Flash light toggle using systemui flash controller

- Screen Recording toggle obviusly requieres samsung screen recorder to be installed.

- Sound mode toggle has been designed for not to dismiss the dialog when a new mode is selected. I think this is more useful

- Airplane mode toggle fixed (at least for s7e) in order to make data mode toggle to work properly when we are in airplane mode

- long press in screen capture launches partical screen capture

- Custom Toggle: selectable icon (among 20+ choices) and selectable text. The user will be able to launch an application, an activity belongning to an application or any available shortcut (direct call to a contact, open selected whatsapp chat...)

B.- Stock Effects Mods

- Dim amount: When the dialog is shown the screen is dimmed. If we go to a confirmation screen, this is more dimmed. With this mod the user can select the % of the stock dim amount to be applied

- Blur amount for stock background.

C.- Custom Background Image

- No need to modify framework-res layout

- Selectable image, image blur ratio and image tint color

- The logic has been modified in order to calculate properly when we are in a dark or light background. Stock behaviour change text colors depending on backgrouond darkness. With this mod this calculation is done from custom image when this is selected.

- The image is kept in memory. Instead of reading and decoding the image every time the dialog is shown we get it from memory, so we save bat.

D.- Custom Colors

- Enable/Disable Custom Colors

- Per Toggle Icon Color when in dark backgrounds

- Per Toggle Icon Color when in light backgrouonds

- Main Text Color: option to use same color than toggle or customizable text color (common) for both dark and light backgrounds.

- Status Text Color / Secondary text color : selectable color for both dark and light backgrouonds (common to all toggles). Secondary text color is the one appearing in confirmation dialogs under the main text.

2.- GUIDE

Attached you will find a zip file. Extract the files to a folder.

A.- First thing to do is to add support for recovery and download toggles in services.jar as it is described in the mini-guide inside services_jar folder

Here the only thing to be careful is to find out which is your dock receiver in phonewindowmanager adapting that part of the guide if neccessary. The idea is simple, register an action to that receiver. When this action is received we get the extra value which tell us what to do, if to got to recovery or to download.

B.- The rest of the mod is done in systemui. So, decompile it

- Add all supplied pngs in SystemUI\s7E/Mod\SystemUI\res\drawable-xxhdpi to your ui

- Add the supplied strings in SystemUI\s7E/Mod\SystemUI\res\values and SystemUI\Mod\SystemUI\res\values-es to your ui (add the translations you need using those string names)

- Add the 2 smalies supplied in ystemUI\s7E/Mod\SystemUI\smali\com\mods\grx to your ui, Create same paths.

- Add all the smalies provided in SystemUI\s7E\Mod\SystemUI\smali\com\android\systemui\globalactions\smaliestoadd to your ui SystemUI\Mod\SystemUI\smali\com\android\systemui\globalactions\ folder

Now we have to make the hard part of the mod. Have a look into the SystemUI\se7\Mod\SystemUI\smali\com\android\systemui\globalactions\smaliestomod and compare with supplied original smalies

- You will see into the modded files all the changes i have made and a quick explanation looking for ## . So, look for ## into the modded smalies, taking into account that this guide is for s7e (also works on ports with minor changes):

. Mod for Voice Assist: Look for .method private getVoiceAssistAction()Lcom/android/systemui/globalactions/GlobalActionsDialog$Action; to make sure that GlobalActionsDialog$35.smali is the voice assistant action. If it is not, look in your original smalie, look for the method and inside the method you will see which one is.

Inside this method i have changed the code in the way i am using the toggle icon i have added to ui.

Inside the toogle code, this is $35 smali i have modded 2 things: the toggle is always available by forcing to always return a true value in the method showConditional()Z. The mod to show or not a toggle is done in other way, through the toggles selected by the user.

Not all toggles are created always but when the user selected them

The other change i added was to catch the exception in case the app is not installed

. Do same changes for settings actions, in this case in are $33.smali ( have a look to getSettingsAction()Lcom/android/systemui/globalactions/GlobalActionsDialog$Action; method in your GlobalActionsDialog.smal) to make sure is this one, if not adpat changes to yours)

. Do same changes for assust actions, in this case in are $34.smali ( have a look to getAssistAction()Lcom/android/systemui/globalactions/GlobalActionsDialog$Action; method in your GlobalActionsDialog.smal) to make sure is this one, if not adpat changes to yours)

- Now let´s mod the toggle click listener. We need to mod the click listener because of the sound mode toggle. We do not want the dialog to be dismissed when the toggle is pressed. In the moment of writting this guide the clicl listener smali is GlobalActionsDialog$18.smali

Make sure it is by looking in GlobalActionsDialog smali this line: Landroid/widget/FrameLayout;->setOnClickListener(Landroid/view/View$OnClickListener;)V . It should be only one and above it you will see which is the click listener.

Do the changes written in provided $18 smali. These modifications allow us to stop the dialog dismissing when we press a toggle. In this case i did it for the sound mode toggle

- Now let´s add support for long press in Screen Capture toggle

We have to mod longcliclick listener. in stock s7e oreo it is $20, so, add the changes you see in there. To match your $ smali look in global actions for this instruction

Landroid/widget/FrameLayout;->setOnLongClickListener(Landroid/view/View$OnLongClickListener;)V

some lines above it you will see which smali you have to mod. In this guide it is $20 for s7e.

- Data Mode toggle, it is GlobalActionsDialog$21.smali

Look for something like this (iput-object ... mDataModeAction...)

iput-object v0, p0, Lcom/android/systemui/globalactions/GlobalActionsDialog;->mDataModeAction:Lcom/android/systemui/globalactions/GlobalActionsDialog$ToggleAction;

and above it you will see which one is yours. Have a look into provided $21 smali, look for ## and adapt changes to yours. Basically i am forcing to return true to the method showConditional()Z

- Airplane mode, we will do same, forcing it to be always available for the adapter when the user selected it. In this mod Airplane mode smali is GlobalActionsDialog$22.smali

As before, look for an instruction in your globalactionsdialog smali similar to iput-object .....mAirplaneModeAction... and above it you will see which is your smali.

iput-object v0, p0, Lcom/android/systemui/globalactions/GlobalActionsDialog;->mAirplaneModeAction:Lcom/android/systemui/globalactions/GlobalActionsDialog$ToggleAction;

Do the changes provided in my modded smalies in your smali for airplane mode (basically is to retur true in showconditional method)

- Now we are going to add another part of the needed support for sound mode toggle. We do this in GlobalActionsDialog$UIUpdateHandler.smali

Look for ## and adapt the changes to your smali. What we are doing is to remove stock sound mode toggle (which does not works fine even if we force to enable it) and we are adding 3 lines to call our new toggle sound mode in order to get it updated when a sound mode change is received.

- Now let´s add main mods for custom colors and other support needed in toggle super classes

. GlobalActionsDialog$SinglePressAction.smali

. GlobalActionsDialog$ToggleAction.smali

Look for ## in both provided modded smalies and adapt the changes to yours. It is easy. Detailed explanation inside SinglePressAction smali. Similar (not exactly the same) changes in ToggleAction smali.

- Finally lets do all changes for all mods to work.

Open modded GlobalActionsDialog.smali and look for ## you will find a small description of what every change does. Compare with yours and add the changes.

C.- StatusBar.smali

. Open provided modded smali and add all changes you will find by looking for ##

If you already did some of my previous mods you will ned just to adapt few things.

. Add provided StatusBar$GrxObserver.smali to your ui or if you already did some of my mods using this observer, just add what you need. We are observing only 2 Uris for this mod.

I recommend you to do this mod on a clean systemui and adding the changes in the order i have writteng here, testing every few smali changes... This is not a complex mod, but it is very laborious because of the featuress added to it.

D.- GrxSettings v2

For this mod to have all the features added you will need to use GrxSettings v2 apk.

Inside the zip you will see all the changes / resources you need to add to it. I am using buttons to confirm and apply user selections, because there are many preferences. If you want to remove them, just add to every preference its corresponding group key.

Pay attention: some provided files are txt this means you have to add their content to the existing xmls!!

FOR S9

Read comments in added toggle actions, please. May be you need to match some static calls

Use provided smalies. In grx actions i had to change some -getXX calls to match them with GlobalActionsDialgo.smali (to get the context from these subclasses)

- onclick listener is $19

- onLongClick listener is $21

- data mode action is $22

- airplane mode is $23

- settings action is $34

- assist action is $35

- voice assist is $36

(pay atteintion in next firm updates, the provided modded smalies can be used at the moment of this gude was written,)

Enjoy