Don't reset tab to the first tab after coming back to the controller
This sounds oddly specific, but it's kind of very obvious and somewhat annoying. On Android, if you press the square button, to see all open apps, and from this menu hop into another app, and then come back to the controller, the selected tab will always be the first one, instead of whatever tab was the one you had open when you left.
Yes, its a PITA.
You can do logic in the remote.lua
So you can set variables when buttons are pressed, and use them to set constraints.
But I think when you return to a remote it is re-opened....... not sure..... and then the variables would be lost.
However, there is a "settings" library......
which suggests that settings can be cached within the remote and saved in the server. That might be the only way to return to a previous state when the remote is re-loaded.
In the remote you can use logic like this........ (obviously your actions would be different, and your logic).....
local task = libs.timer local task = libs.task; local device = libs.device last = "zero" events.blur = function () if (last == "one") then -- help toggle SKY on/off libs.server.run ("@irsend", "@irsend", "0000 0073 0018 0000 0A26 03B1 0194 0208 0192 0208 0194 03B6 0192 03B8 0340 0208 0192 0208 0194 0208 0194 0208 0192 0208 0192 020A 0190 020A 0192 0208 033D 020A 0192 03B6 0194 0208 0194 0208 0192 0208 0192 020A 0190 020A 033D 020A 0190 03B6 0194 0208 0192 2000" ); print("SKY off"); id = libs.timer.timeout (function() -- help toggle Akira AUX on/off libs.server.run ("@irsend", "@irsend", "0000 0073 0022 0000 225F 1195 01FC 026F 0210 0268 0210 026F 01F9 026F 0210 0268 01F6 0288 01F9 026F 0212 0268 0212 06B5 0212 06C5 01F9 06C8 0210 06B5 0212 06C5 01FC 026F 0212 0268 01F4 06D0 0212 026A 020E 06B5 0212 026A 01F4 028A 01F7 06C8 0210 026F 01F9 026F 0210 0268 01F6 06D0 0212 0268 0210 06B5 0213 06C5 01FC 026D 0212 06C5 01F9 06C8 01F7 06CE 0213 2000" ); end, 500); print ("Closing remote from SKY"); print("Akira AUX off"); last = "zero" elseif (last == "two") then -- help PreAmp input Sat 1 libs.server.run ("@irsend", "@
So for each button press set "last" or whatever variable name you choose, and then when the remote opens ("focus"...... ?) check the value of "last" for every action using an "if / elseif" and use the result to toggle the correct button....... maybe....... without re-doing the action...
I hope that makes sense.
Honestly that is way too complicated for me to fully grasp, but I semi-understand what you're talking about. I'm really surprised at this though, you're good. So you think this would work in theory with what we currently have or do we need more features?
I have used variables to do logic as in the above example...... so it works. But you prompted me to look deeper. I had the same problem as you....... that when the remote re-opened the variables were lost. This meant that toggles were a problem, as the toggle state was lost and so toggles were "inverted" or not...... not satisfactory.
But you made me find the "settings" library.
You will see that some standard remotes have a settings.prop file in their folder........
and you should be able to write and read that file by for example......
settings.last one sets last=="one" so for every button/toggle etc. you can tell "settings" the value of last if you include that line in its action like this...... (it will automatically generate the settings.prop file in the remote folder)......
actions.my_toggle_three = function () do_something(already_programmed); local last = settings.last; -- the above line can be stated once at the beginning of the remote settings.last = "3"; end
and then when the remote is re-opened you can use that setting......
so in the layout add an id...
-- onlaunch below is a maybe...... it depends whether the remote re-opens or not. <layout onresume="resume" onlaunch="resume"> <row> <toggle id="3" checked="false" something whatever /> </row>
And the in the remote.......
actions.resume() for id=0,16 do -- line above....... 16 is number of buttons less 1 (first button id == 0) if (layout.id == settings.last) then layout.id.checked = true; else layout.id.checked = false; end end actions.something = function () do_something(already_programmed); local last = settings.last; -- the above line can be stated once at the beginning of the remote settings.last = "3"; end
You made me search further.....
See "onlaunch" and "onresume" ..... https://github.com/unifiedremote/Docs/blob/master/controls/layout.md#onlaunch
I am getting old, and unreliable, so there will be errors. Copy in @nathan323 to fix the above code!
I gotta leave now and just saw this. I'm terribly impressed on a first look. If this works you're the king, thanks!