Custom Widget OnDisplay Event

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

TraianC
Posts: 66
Joined: 24 Oct 2014 13:29

Custom Widget OnDisplay Event

Post by TraianC » 04 Jan 2015 12:24

I want to make a custom widget to display the total data traffic (WiFi and cellular).
It would be great if the content of the custom widget would update automatically when the widget is displayed (when I scroll to the screen that contains the widget).
Right now I have to click on the widget in order to update its content. It would be more elegant to update it automatically when it is displayed.

andy
Posts: 40
Joined: 29 Dec 2014 21:00

Re: Custom Widget OnDisplay Event

Post by andy » 04 Jan 2015 13:32

Hi,

General it is possible to refresh widget each time a global variable value changes in related flow. For this you have to save your traffic in global variable. In your widget you can add a text field. For value you can enter name of global variable between {}

If you can refresh on scroll event depends on your launcher and its provided information. So maybe a broadcast is possible.

Regards

TraianC
Posts: 66
Joined: 24 Oct 2014 13:29

Re: Custom Widget OnDisplay Event

Post by TraianC » 04 Jan 2015 19:46

Hello Andy and thank you for your reply!

I know that a widget is updated when the contents of a global variable is changed. Obviously, in order to update the global variable I need to execute a flow. Now that flow is executed when I click on the widget and also every 15 minutes, using a time trigger.
I would like to optimize the process to be more "battery friendly". If I don't use my phone for 4 hours there is no need to execute the flow. The best option would be to be able to execute the flow when the widget is displayed on the screen.
I looked in General Broadcast but I didn't find any usable option.

Regards

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

Re: Custom Widget OnDisplay Event

Post by MURTUMA » 04 Jan 2015 21:08

When you're talking about battery frienliness I assume you're keeping the screen off when you're not using your phone? You can simply disable the widget updating flow when the screen's off.

TraianC
Posts: 66
Joined: 24 Oct 2014 13:29

Re: Custom Widget OnDisplay Event

Post by TraianC » 04 Jan 2015 21:49

You're right.
I thought also at this as a possible workaround. But still I would prefer to update the widget when it is displayed.

andy
Posts: 40
Joined: 29 Dec 2014 21:00

Re: Custom Widget OnDisplay Event

Post by andy » 04 Jan 2015 21:53

Hi together,

Yes, same I doing for my clock widget and I check if other app is in foreground or better if home screen is in foreground.
It would be nice to get access to Automagics WidgetProvider. So you could read out widget Id. onVisible() should give related result. I dont think that this could be done in Automagic

Regards

Andy

TraianC
Posts: 66
Joined: 24 Oct 2014 13:29

Re: Custom Widget OnDisplay Event

Post by TraianC » 04 Jan 2015 23:29

Hello again,


I found the solution!

I used the trigger UI Event.
For Event Type I used: Component scrolled and for Package Name I used my launcher: com.htc.launcher.
The screen number is stored in to_index variable. It contains "1" for first screen, "2" for second screen etc.

Now all I have to do is to check when I scroll to the screen that contains the widget.


Regards,
TC

andy
Posts: 40
Joined: 29 Dec 2014 21:00

Re: Custom Widget OnDisplay Event

Post by andy » 05 Jan 2015 05:27

Hi

That is what I tried yesterday to. With LLX I did not find a solution yet.

After have read your comment I will try again.

Regards

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

Re: Custom Widget OnDisplay Event

Post by MURTUMA » 05 Jan 2015 07:40

andy wrote:LLX I did not find a solution yet.
With LLX you can do some scripting. I'm not familiar with that part of the launcher but you may find your solution from three. Also the developer has been very helpful for me in the past, so ask away. I know that it is possible to get LLX to talk with Automagic.

andy
Posts: 40
Joined: 29 Dec 2014 21:00

Re: Custom Widget OnDisplay Event

Post by andy » 05 Jan 2015 08:20

Hi Murtuma,

Thank you for your comment.
Tou are right. The scripting interface in LLX is powerfull. Later I will spend some time on it. For the moment it is not so important for me because I only use one single home screen. To get access to all apps I wrote a flow set which one act as a side bar.

But I also played with ui event. At least I could detect my homescreen as opened window.

Regards

Locked