I need a simple Switch-Widget for Flightmode
Moderator: Martin
I need a simple Switch-Widget for Flightmode
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?
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?
Re: I need a simple Switch-Widget for Flightmode
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.
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.
Re: I need a simple Switch-Widget for Flightmode
@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.
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.
Re: I need a simple Switch-Widget for Flightmode
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.
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.
Re: I need a simple Switch-Widget for Flightmode
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.
Re: I need a simple Switch-Widget for Flightmode
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!
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!
Re: I need a simple Switch-Widget for Flightmode
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.
Re: I need a simple Switch-Widget for Flightmode
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!
What ist the global variable for the "Automatic Screen Rotation" so I could try the built-in toggle widget?
Thanks for help!
Re: I need a simple Switch-Widget for Flightmode
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.
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.
Re: I need a simple Switch-Widget for Flightmode
Try searching for trigger Screen orientation.