I need a simple Switch-Widget for Flightmode

Share and discuss your flows and ideas with other users.

Moderator: Martin

lazyI
Posts: 5
Joined: 19 Jul 2016 21:04

I need a simple Switch-Widget for Flightmode

Post by lazyI » 20 Jul 2016 07:39

Hi,
I'm new with Automagic, therefore I need a little help to start. I want to build a simple Switch to activate and deactivate the Flightmode with one click (I have root). To indicate the activation I want a blue bar at the bottom of the widget.

Can someone help me with this?

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: I need a simple Switch-Widget for Flightmode

Post by Bushmills » 20 Jul 2016 09:47

What have you tried as far, and what is the problem you encountered which prevents you from building such a widget?
Without more details about where you failed, you run the risk that you're told where the menu item for the widget builder can be found. I'm sure that you want to focus on the actual problem, not on things you already know.
A green bar instead of a blue bar may simplify construction, btw.

lazyI
Posts: 5
Joined: 19 Jul 2016 21:04

Re: I need a simple Switch-Widget for Flightmode

Post by lazyI » 20 Jul 2016 10:22

@Bushmills
Thank you for your answer! I already made some simple flows, but I never used scripts.
My problem is basically in wich way I have to insert a bar in the widget and then how to switch the green/blue bar on and off when a function like the Flightmode is activated or for axample the Systemsound is deactivated.

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: I need a simple Switch-Widget for Flightmode

Post by Bushmills » 20 Jul 2016 10:50

So I can assume you managed to put the widget together, but need a way to change colour of an element.
To an action "Script", a function "SetWidgetElementProperty()" can be added. When doing so, it will come up with a dialog, allowing you to choose widget, element, and property. fillcolour of the indicator bar is what you want to change, according flight mode state.
To determine state, I'd create a flow with two triggers: flight mode on and flight mode off. This flow will catch all changes to flight mode, even when not caused by your widget. The widget action would then just toggle flight mode.

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: I need a simple Switch-Widget for Flightmode

Post by Bushmills » 20 Jul 2016 11:01

Should a green bar do, consider to use the built-in toggle widget instead. Indicator colour is controlled through a global variable, which is also toggled by tapping the widget. Using one of those makes constructing your own widget unnecessary, but flow logic would change a bit as consequence, but widget appearance can't be modified much. Especially the pre-set background colour may make them look ugly and not well integrated, depending on your display background. With your own widget, much more control can be exerted about appearance.

lazyI
Posts: 5
Joined: 19 Jul 2016 21:04

Re: I need a simple Switch-Widget for Flightmode

Post by lazyI » 21 Jul 2016 11:55

THX! !
I tried it with a flow and "Airplane Mode" as the trigger for the Script with the function "SetWidgetElementProperty()", but it didn't work, so I used the "Modem Status" trigger and it's working!

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: I need a simple Switch-Widget for Flightmode

Post by MURTUMA » 21 Jul 2016 12:11

Set airplane mode action is known not to work on some devices and it might affect the trigger as well. Good you got it working anyway.

lazyI
Posts: 5
Joined: 19 Jul 2016 21:04

Re: I need a simple Switch-Widget for Flightmode

Post by lazyI » 21 Jul 2016 13:49

Now a tried to build the same Widget with the function to activate and deactivate the "Automatic Screen Rotation", but there is no trigger to initialize the script (SetWidgetElementProperty)!? Is there a possibility?
What ist the global variable for the "Automatic Screen Rotation" so I could try the built-in toggle widget?

Thanks for help!

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: I need a simple Switch-Widget for Flightmode

Post by Bushmills » 21 Jul 2016 13:55

Beg your pardon?
There are no global variables unless created by you, an expression or script of yours, or otherwise specifying a (global) variable to assign a value to.
If you want a global variable to carry some piece of data, you must undertake effort to put it there first.

A trigger, responding to screen rotation, exists.

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: I need a simple Switch-Widget for Flightmode

Post by MURTUMA » 21 Jul 2016 13:57

Try searching for trigger Screen orientation.

Post Reply