widget (status)

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
OhLeut
Posts: 14
Joined: 06 Apr 2019 10:21

widget (status)

Post by OhLeut » 05 May 2019 07:23

widget

I have created a widget that shows me the date and time In addition, when I click Date, the calendar appears and when I click notes, Google Notes appears.
Widget.jpg
Widget.jpg (7.97 KiB) Viewed 7759 times
everything okay until here


I would like to extend or add something new

1. I want to see the status of the ringer volume in the ... Widget example (level 1-20).

2. I want to show the status of WiFi and Bluetooth. Example (ON or OFF)

Is there a solution (variable)?

Is there a kind of variable list or command list?

under text (...) I find only the following variable (date)
variable.jpg
variable.jpg (10.51 KiB) Viewed 7759 times
country: Germany
language: German

:!: Writing & Read via Google Translate :!:



Samsung S10+ (SM-G975F)
Android 9.0.0
One UI-Version 1.1
* NO ROOT *
*Status Offiziell *

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: widget (status)

Post by Desmanto » 05 May 2019 16:05

To trigger based on volume change, use trigger audio volume, on changes. For wifi and bluetooth, use the trigger wifi state and bluetooth state, tick enabled and disabled. You then check the variable provided, and save it to glovar. This glovar can be used in widget and will be updated immediately.

But it is even better, that after the trigger, you simply use setWidget element property to change the visibility of the prepared icon. Example you put icon wifi off and wifi on in the same spot. When trigger wifi state enabled, show wifi on icon and hide the wifi off icon. Vice versa for wifi disabled. Do the same for bluetooth. For audio volume, using the text value is enough.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
OhLeut
Posts: 14
Joined: 06 Apr 2019 10:21

Re: widget (status)

Post by OhLeut » 10 May 2019 18:53

can you show me an example? , I do not know exactly where to start.
is the variable (bluetooth_state) as text correct?
country: Germany
language: German

:!: Writing & Read via Google Translate :!:



Samsung S10+ (SM-G975F)
Android 9.0.0
One UI-Version 1.1
* NO ROOT *
*Status Offiziell *

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: widget (status)

Post by Desmanto » 11 May 2019 07:25

Yes, use {bluetooth_state}.

Create a flow
Trigger : Bluetooth State On, Off (tick On and Off)
Action : Script

Code: Select all

global_bluetooth_state = bluetooth_state;
In your widget, create at text, and put {global_bluetooth_state}. Everytime the bluetooth is switch on/off, the text element's text will change to on/off accordingly. But this require 1 glovar space per state. So for wifi state and audio volume, you need another 2 glovar, which is inefficient.

Better idea is to use setWidget directly.
Trigger : Bluetooth State On, Off (tick On and Off)
Action : Script

Code: Select all

setWidgetElementProperty("Widget1", "Text_1", "text", bluetooth_state);
Of course, replace "Widget1" with your widget name. "Text_1" with the text element, bluetooth_state with the wifi_state and volume. For wifi state, you might need to map the code 1 to "off" and code 3 to "on". You can also use setWidget to change image (icon) to indicate the on/off. But you need to use if() or map value for easier management.

After all finished, you can also combine all triggers into single flow and use multiple if() to separate the triggers. (you don't have to do this)
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply