Menu Technique

revver

New member
Is there a recognized technique to create a menu and respond to the user's choice.

What I am trying to achieve is: a trigger fires and code displays a list of choices and behaves according to the choice.
 

thisismyshine

New member
You could use UiTask - set up a list, which gives you the menu prompt you want, then associate each selection to a variable that you use to determine action. That's what I've done, anyway.
 

revver

New member
I have installed UiTask but I can't figure how to make MacroDroid understand that it is there now and how to invoke it.
When I run UiTask itself, no option offered seems appropriate.
Is there online help for such things?
 

revver

New member
Perhaps you can refer me to a template which uses UiTask (or even a different plugin) so that I can install it and use that to figure out how it works.
 

thisismyshine

New member
You should be able to run it from the application section, clicking locale/tasker plugin, then select uiTask. Are you saying it doesn't run from there for you?
 

revver

New member
I found a trigger option under Applications called tasker/locale. I presumed that's what you meant and added that as a trigger, choosing the first option only to arrive at a point of even more bewildering choices. Much exploring to be done! Pity there is no documentation. My understanding/experience of locale limits it to language/geography customization. Is it also the name of an app similar to Tasker?
Thanks for your guidance.
 

thisismyshine

New member
So the list menu ...
- Window is where you decide the color scheme of the menu.
- Title, what you want the title of the menu to be. [Can also set color scheme etc.]
- Text is the formatting of the text; color, alignment, size, etc.
- List options is your actual menu. It looks like this, play around with it to really understand it
Screenshot_20210420-095024.png

To give you an idea of how that translates, here's a menu I did to change fonts for messages
Screenshot_20210420-095255.png

And here is what it looks like in actionScreenshot_20210420-095324.png


I recommend having a Cancel button in case you don't do anything with the menu once it's open. That would be under the Button section, negative. You then do a cancel macro action after the menu with a constraint of the variable changing to negative.

Hope that helps!
 

dsnz

Well-known member
@thisismyshine your post made me try ui tasker,
it's nice indeed but in the vertical list dialog there is big spacing between list items (about double spacing which is awkward and wastes a lot of screen)
do you happen to know how to control the vertical spacing ? I haven't found an obvious option for this
 

revver

New member
@thisismyshine thank you. I don't feel quite so silly now. I hadn't got past trying to find meaningful stuff in the plugin which would trigger an event. I thought, first trigger something, right? And all it seemed to want was names of variables. Huh?? And no point going any further if I couldn't trigger it. So that's where I was stuck.
Reading your post, when I didn't see Window, Title, Text etc I figured my install must be faulty. But I went further afield and found List Dialog and then List Options. It's coming together now. Thanks.
Now I have found your screens under actions and I presume that any trigger will do to display the menu. I still have to figure out variables though. I figure your [lv=...] is just an alternative to typing the comma-separated actual text.
Also, I didn't see where you entered "Choose Font". My tentative menu has a blank top line.
 

thisismyshine

New member
@thisismyshine your post made me try ui tasker,
it's nice indeed but in the vertical list dialog there is big spacing between list items (about double spacing which is awkward and wastes a lot of screen)
do you happen to know how to control the vertical spacing ? I haven't found an obvious option for this

I haven't found a way to control that line spacing, no, but I haven't put a whole lot of time into it either. I mostly use this function of my list of options is many. Otherwise there's a simpler macrodroid list that does 3.
 

thisismyshine

New member
@thisismyshine thank you. I don't feel quite so silly now. I hadn't got past trying to find meaningful stuff in the plugin which would trigger an event. I thought, first trigger something, right? And all it seemed to want was names of variables. Huh?? And no point going any further if I couldn't trigger it. So that's where I was stuck.
Reading your post, when I didn't see Window, Title, Text etc I figured my install must be faulty. But I went further afield and found List Dialog and then List Options. It's coming together now. Thanks.
Now I have found your screens under actions and I presume that any trigger will do to display the menu. I still have to figure out variables though. I figure your [lv=...] is just an alternative to typing the comma-separated actual text.
Also, I didn't see where you entered "Choose Font". My tentative menu has a blank top line.


First thing is first - there is no 'choose font' in the list menu dialog. That choose font, is what /my/ menu does. It's a quick and easy way for me to use special fonts for texts or emails etc. So that image shows what my menu of options that I created looks like.

Now, [lv=] is a reference to macrodroid variables, specifically local variables (hence the lv). This is in contrast to global variables. Global variables can be accessed by any and all macros you make. Local variables are only within that specific macro. Each variable, you have to create for it to exist and it needs to exist for you to use it, obviously.

Hope that helps!
 

revver

New member
First thing is first - there is no 'choose font' in the list menu dialog. That choose font, is what /my/ menu does. It's a quick and easy way for me to use special fonts for texts or emails etc. So that image shows what my menu of options that I created looks like.

Now, [lv=] is a reference to macrodroid variables, specifically local variables (hence the lv). This is in contrast to global variables. Global variables can be accessed by any and all macros you make. Local variables are only within that specific macro. Each variable, you have to create for it to exist and it needs to exist for you to use it, obviously.

Hope that helps!
I'm sorry I didn't express myself well. When I said "your [lv=[...] is an alternative" I did understand that lv= is a reference to a local variable and I understood the concept of variable scope. I was just saying that I got it that the list of lv items was functionally equivalent to a list of quoted strings to create the menu.
 

tanutanu

Well-known member
So the list menu ...
- Window is where you decide the color scheme of the menu.
- Title, what you want the title of the menu to be. [Can also set color scheme etc.]
- Text is the formatting of the text; color, alignment, size, etc.
- List options is your actual menu. It looks like this, play around with it to really understand it
View attachment 319

To give you an idea of how that translates, here's a menu I did to change fonts for messages
View attachment 320

And here is what it looks like in actionView attachment 321


I recommend having a Cancel button in case you don't do anything with the menu once it's open. That would be under the Button section, negative. You then do a cancel macro action after the menu with a constraint of the variable changing to negative.

Hope that helps!
Hi @revver,

Would you tell me how to change the background color of the element when it selected?
I'm trying to make a multi-selectable window and yes, each element could be selected when I tapped, however the background color was still as it were, no changing at all.
Probably, the array named "List Item's data" has an attribute to change. I would like to know full details of its format. I was googling several times but couldn't find it😭
 

tanutanu

Well-known member
Hi @revver,

Would you tell me how to change the background color of the element when it selected?
I'm trying to make a multi-selectable window and yes, each element could be selected when I tapped, however the background color was still as it were, no changing at all.
Probably, the array named "List Item's data" has an attribute to change. I would like to know full details of its format. I was googling several times but couldn't find it😭
I got it by myself:)
 

Attachments

  • Screenshot_20211023-004819_copy_1080x2049.png
    Screenshot_20211023-004819_copy_1080x2049.png
    116.3 KB · Views: 21
  • Screenshot_20211023-005008~2.png
    Screenshot_20211023-005008~2.png
    104.8 KB · Views: 22
  • Like
Reactions: 420

tanutanu

Well-known member
I got it by myself:)
well, the UITask list respond me super slowly, around 5 to 8 seconds, even though less than 100 options 🙃 Is it normal? And sometimes it gave up and returned another value I got few seconds ago on another plugin function call. It seems to have hidden bugs...
 

FrameXX

Well-known member
well, the UITask list respond me super slowly, around 5 to 8 seconds, even though less than 100 options 🙃 Is it normal? And sometimes it gave up and returned another value I got few seconds ago on another plugin function call. It seems to have hidden bugs...

I also encountered these delays when using it. It's really not perfect.
 

tanutanu

Well-known member
I also encountered these delays when using it. It's really not perfect.
Yeah, its file selector is nicer but the user defined list is crazy:(
Now I made the macro extractor from .mdr file as MD macro. It can processed around 1 .macro file a second, 90 to 120 seconds for 100 macros entirely extract mode. However it caused serious slow down, the following Turmux function call was involved the issue, so total running time was almost quadruple...
Umm, extract and replace_all MD actions are slow, jq and shell script loop on Termux are also slow and the UITask is super slow...😤
 
Last edited:

tanutanu

Well-known member
Yeah, its file selector is nicer but the user defined list is crazy:(
Now I made the macro extractor from .mdr file as MD macro. It can processed around 1 .macro file a seconds, 90 to 120 seconds for 100 macros entirely extract mode. However it caused serious slow down, the following Turmux function call was involved the issue, so total running time was almost quadruple...
Umm, extract and replace_all MD actions are slow, jq and shell script loop on Termux are also slow and the UITask is super slow...😤
I just replaced almost all text extract and replace_all actions to Android standard mksh shell script to work as function call backs. I consider it means the macro returns the task to MD main as many as possible. The stupid BSD sed is painful but it's ok.
However, the short mksh shell scripts and individual text manipulation actions of MD are same or MD internal action is better, and the total performance is stayed on the same level ss well. The overhead of shell script calling doesn't seems to small even though processing only few hundreds bytes of data with sed/awk.

Well...plugin call of MD is something strange. When onky 20 to 30 actions are stacked without any wait action, at least 50ms to 100ms for each, it causes serious slow downs. Especially for plugin call, just 2 or 3 times, incontinuously, with enough brief breaking time between each call, it makes the plugin have a 5 to 6 seconds hooky play.
I suspect MD is busy just waiting or trying to run the next stacked actions and failure loop with another task blocking, still keep on sharing all cpu load for normal apps, even though it needs the return value from plugin side. If the plugin can take enough time to processed, it doesn't need so much time. It reality needs the call back feature just same as shell script action or receive Intent trigger. Wait until action is not working good for plugins just same as another internal trigger events such as changing variables.
 
Last edited:
Top