Create your own quick setting tile on Marshmallow

Share and discuss your flows and ideas with other users.

Moderator: Martin

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Create your own quick setting tile on Marshmallow

Post by Martin » 31 Oct 2015 06:34

Hi,

Adding a custom quick settings tile was possible on Lollipop (Android 5) with the power of root. On Marshmallow (Android 6) the same procedure still works but there's now even a way to achieve it without root:
  1. enable the System UI Tuner: http://www.androidpolice.com/2015/10/05 ... tivate-it/
  2. open system settings->System UI Tuner->Quick Settings
  3. click Add tile at the bottom of the screen
  4. select Broadcast Tile
  5. set a unique name to identify this tile like MyTile1 (note that it seems not to like underscores in the name). Note the the tile will be invisible initially.
  6. open Automagic
  7. create a new flow to show and customize the tile
    1. add an action Init Variable Image File to load a small image into variable image_data. (Optionally use action Modify Image to scale down the image)
    2. add an action Send Broadcast, set field Action to MyTile1 and add following Extras:

      Code: Select all

      putBoolean("visible", true);
      putString("label", "Automagic");
      putString("contentDescription", "This is my own tile.");//optional
      putString("onClickUri", "intent:#Intent;action=automagic.MyTile1;end");
      putString("onLongClickUri", "intent:#Intent;action=automagic.MyTile1Longclick;end");
      putByteArray("iconBitmap", image_data);
      The onClickUri-Extra is used to define what broadcast intent should be sent when the tile is clicked.
  8. create a new flow to execute a flow when the tile is clicked
    1. add a trigger General Broadcast, set field Action to automagic.MyTile1 (this one has to match the value defined in the onClickUri above)
    2. add whatever actions/conditions you would like to execute when the tile is clicked
Regards,
Martin

evebrea
Posts: 116
Joined: 12 Aug 2013 15:28

Re: Create your own quick setting tile on Marshmallow

Post by evebrea » 28 Jul 2016 17:01

I have an lg stylo on marshamallow 6.0 and i don't see the same menu as in these videos.. also holding my gear for settings doesn't make it spin or enable systemui tuner...

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Create your own quick setting tile on Marshmallow

Post by Martin » 28 Jul 2016 19:21

I'm not sure but I think that LG does not support the system UI tuner so it's probably not possible to add QS tiles.

ariloc
Posts: 109
Joined: 05 Jun 2016 21:36

Re: Create your own quick setting tile on Marshmallow

Post by ariloc » 29 Jul 2016 10:03

Thanks! It works on my Moto E 2nd Gen!

User avatar
heilong
Posts: 77
Joined: 18 Oct 2016 15:20

Re: Create your own quick setting tile on Marshmallow

Post by heilong » 09 Nov 2016 23:53

On my ROM there's no Quick Settings in System UI Tuner. I guess because the ROM provides their own QS customization UI.
Unfortunately, that UI doesn't provide support for broadcast tiles.
I've tried following your QS Tile on Lollipop idea.
Looks like my ROM has a bug in `settings` command - it can list secure settings which shows sysui_qs_tiles exist, but get/put for this property doesn't work.
I had to run `sed -i 's/caffeine/&,intent(automagic.TILE_1)/' /data/system/users/0/settings_secure.xml` as root (caffeine was the name of the last QS tile on the list) to add a new tile. I was not sure if it was safe to do while the system is running, so just in case I rebooted to recovery and did the settings_secure.xml editing from recovery.
Rebooted, executed the flow which broadcasts automagic.TILE_1, and the tile appeared! What a bunch of work for a custom QS tile, huh?
Now I want to know how many things I can do with this? Where can I read about all the options I can put into TILE_1 broadcast, and which info I can get from ACTION_1 general broadcast? E.g. I'm curious if I can have a separate action for long-tap?

Update: I have since modified my ROM's settings command (modified SettingsCmd.java and recompiled settings.jar), so the `settings get/put secure sysui_qs_tiles` work for me now.
http://forum.xda-developers.com/showpos ... tcount=968

But Automagic's actions Init Variable System Setting or Set System Setting still don't work. E.g.:

Code: Select all

10.11.2016 21:59:12.321 [ShowTile] Start executing action 'Init Variable System Setting: Secure sysui_qs_tiles to tiles'
10.11.2016 21:59:12.336 [ShowTile] Action 'Init Variable System Setting: Secure sysui_qs_tiles to tiles' Setting Secure 'sysui_qs_tiles' contains ''.
10.11.2016 21:59:12.364 [ShowTile] End executing action 'Init Variable System Setting: Secure sysui_qs_tiles to tiles'
Do these actions use native Java code, and decide whether to access Settings or CMSettings based on hardcoded arrays of settings names? If so, would it be too much to add some sort of overriding this? E.g. I specifically need to access sysui_qs_tiles from Settings, not CMSettings. For now, I'll just use "Execute Root Command" and use the `settings` command.
http://automagic4android.com/forum/view ... 308#p16308

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Create your own quick setting tile on Marshmallow

Post by Martin » 10 Nov 2016 21:06

Automagic uses the regular Java API to get/set system settings. Automagic itself has no logic to handle CMSettings at all.

Regards,
Martin

User avatar
heilong
Posts: 77
Joined: 18 Oct 2016 15:20

Re: Create your own quick setting tile on Marshmallow

Post by heilong » 10 Nov 2016 23:16

Strangely, it works now.
And I see there are no CM settings available in the settings-related actions. Would you consider adding them for CM roms?

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Create your own quick setting tile on Marshmallow

Post by Martin » 11 Nov 2016 20:59

I can add it to the todo-list but it will be low priority since the potential user base is quite small.

User avatar
heilong
Posts: 77
Joined: 18 Oct 2016 15:20

Re: Create your own quick setting tile on Marshmallow

Post by heilong » 11 Nov 2016 23:40

Thanks. I completely understand.
If you gave me the class that handles your existing "Set System Setting" and "Init Variable System Setting" actions, I could make a new one for CM - all you'd have to do is to test it, or give me a test build with the new class in.

Looking at the source for settings, basically CMSettings and Settings have the same API.
Most of the code for list/get/put is common, difference is in provider init

Code: Select all

ContentProviderHolder holder = activityManager.getContentProviderExternal(
				mUseCMSettingsProvider ? CMSETTINGS_AUTHORITY : SETTINGS_AUTHORITY,
				UserHandle.USER_OWNER, token);
if (holder == null) {
		throw new IllegalStateException("Could not find settings provider");
}
provider = holder.provider;
And appropriate URIs

Code: Select all

    private List<String> listForUser(IContentProvider provider, int userHandle, String table) {
        final Uri systemUri = mUseCMSettingsProvider ? CMSettings.System.CONTENT_URI
                : Settings.System.CONTENT_URI;
        final Uri secureUri = mUseCMSettingsProvider ? CMSettings.Secure.CONTENT_URI
                : Settings.Secure.CONTENT_URI;
        final Uri globalUri = mUseCMSettingsProvider ? CMSettings.Global.CONTENT_URI
: Settings.Global.CONTENT_URI;

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Create your own quick setting tile on Marshmallow

Post by Martin » 13 Nov 2016 21:25

I see that it does not look complicated to make the necessary changes. I just don't add such actions for specific ROMs in general since I have to test, update and fix the features when the ROMs are updated and the features are changed.
You could write a plugin that allows to change the CM system settings: Main doc: http://www.twofortyfouram.com/developer, Tasker extensions: http://tasker.dinglisch.net/plugins.html
Such a plugin has the advantage that users of other automation tools can also use the plugin.

Regards,
Martin

Post Reply