Page 1 of 1

UI interaction

Posted: 23 Nov 2017 21:37
by Wibbly
The UI event trigger doesn't detect every possible event such as a simple screen tap, and as a trigger can generate a lot of flow activity anyway. Instead of using a trigger, is there a global sydtem variable that could be provided that indicates the time of the last tap? I could then test it periodically to see how long ago the last screen tap was...

Re: UI interaction

Posted: 24 Nov 2017 07:02
by Desmanto
UI Event can only detect clicking on button/component that can be clicked and has event attached to. So clicking on label / UI element which only show text, won't triggger anything.

What is your usage case? I guess you wanna make something like pickone has asked before. I have made the flow if that is the case.
viewtopic.php?f=3&t=6963

If it is not, tell us your example usage. Maybe there are other ways to do it. Or you can look my index first to see if anything similar

Re: UI interaction

Posted: 24 Nov 2017 09:15
by Wibbly
Wow, it is the same use case and I developed a very similar approach in my own flows! I like your idea of the DMS, but I avoided it by having a separate 'Stop screensaver' flow that's run when you tap the active overlay and called from the UI Event flow (which is is the one likely to be stopped unexpectedly for some reason) :-)

I noticed your screensave widget overlay, although 'stretched', will not cover on-screen navigation buttons at the bottom of the screen, which is a danger for OLED displays. I overcame this in my flows by activating immersive mode at the same time whilst the screen saver is active. This seem to work so far - you may want to try it :-)

So my question is about avoiding the UI event trigger altogether, and instead using a different approach which could reliably detect ANY touch and not have a flow executing for every single touch... (not if you do a lot of typing and have an extra trigger for that)

I'm asking if there in an Android OS function or variable that can be exposed in Automagic, that just provides the timestamp of the last touch on the screen, in any way. My flow could just compare this with the current time and do the comparison, say, once a second or so whilst the screen is on. This may be much more efficient and reliable than using UI event trigger.

Re: UI interaction

Posted: 24 Nov 2017 16:28
by Desmanto
My phone has hardware capacitive keys, so it is always full block. But yeah, you can turn immersive mode first.

I can't find another way with spamming too many input to the flow. Since you want every single touch to be register, so you should prepared to process each touch in the flow. I don't see any way to detect the touch without a flow running to process it.

But I have found out another way to detect the touch without using Trigger UI event, and it will work without clicking on elements that has event. But you must have root to do it. Simply use Action Execute Root Command.

Code: Select all

getevent -c 1 /dev/input/event0
With the timeout of the command set to the time you wanna wait before continuing to the next element. event0 should be replaced by the device number of the touchscreen, can be check by using the getevent command only, touch the screen and you can see which event number register the touch.

Connect this command to sleep 1 second or any delay you want. Then this sleep loopback to the command again, creating infinite loop. Create another connection from the Root command, and change the connection to exception. After timeout (example 10s), the Execute root command will produce error, and it will branch to the exception. Which then can be continued to the main branch to execute the things you want.

This method still will register every touch as two elements (the root command and the sleep). So the result is the same spamming flow as the UI event. The plus side is it doesn't need widget, the downside is it needs root. And you can adjust the sleep to longer value, so it won't register so frequently. Example 5 seconds. So after the first touch, it won't check for any touch for 5 seconds. But the minus is if you touch furiously during the first 5 seconds and do nothing during the 10 seconds, the flow still continues to the main branch (exception). So need to balance the sleep and the timeout.

I am aware there is java function onTouch listener to detect the touch. But i can't get it work in Automagic, my java skill is still very limited.

Re: UI interaction

Posted: 24 Nov 2017 17:16
by Wibbly
Thanks. Maybe Martin will be along to give us some more wisdom ;-)

Re: UI interaction

Posted: 25 Nov 2017 20:21
by Martin
Unfortunately I'm not aware about a direct way to get the last touchscreen interaction time. There has to be something like this since Android has to track this on its own to properly turn the screen off after the desired inactivity time. I'll add a todo item to see if this time can be retrieved somehow by a regular app but I doubt that there's an easy solution.

Regards,
Martin

Re: UI interaction

Posted: 25 Nov 2017 22:18
by Wibbly
Thanks Martin

Re: UI interaction

Posted: 27 Nov 2017 15:23
by Wibbly
Part of the same use case/set of flows (for a screen saver) but a different question, hence different thread
http://automagic4android.com/forum/view ... f=5&t=7098

Re: UI interaction

Posted: 04 Dec 2017 13:37
by Wibbly
If I'm NOT using a widget, is UI Event supposed to work in immersive mode? With immersive mode switched on it doesn't seem to trigger. But with immersive mode off it does. Is that a bug?

Android Oreo 8.0 on Pixel 2.