Excuse me..

Excuse me..

Can we make customized “dynamic text” to show event or notification without being pressed or triggered by user?

For example displaying “charging…” when phone is in charging state..

#dynamic_text

]]>
(Next Post) »

18 Commentsto Excuse me..

  1. Anonymous says:

    < ![CDATA[

    The best way would be to use a third party automation app that would collect data (charging status, notification text, other), and update a normal shortcut through a script. That’s a bit of work because you need to setup two apps together, but that could be more efficient than a customizable widget.

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Is that possible to achieve automation only by script? Because I am avoiding third party usage not due to its complexity, but due to memory usage from other app’s monitoring activity



    (I have memory low notification from tasker when I use audioSwitcher-toogle so I turn off the tasker and use LLX script instead)

    ]]>

  3. Anonymous says:

    < ![CDATA[

    For some data yes, but no for other because Lightning has not the permission to access them.


    For instance you may get access to battery status because it is public, however you won’t be able to toggle all settings (wifi, bluetooth, etc) because it needs specific permission.


    There is no general solution, each case need to be studied separately. That’s the benefit of an automation app which already includes a lot of bridges.

    ]]>

  4. Anonymous says:

    < ![CDATA[

    Thank you Pierre Hébert , …. so, that’s mean automaton is possible but I need to search a method to automate task with LLX script by myself?


    🙂

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Maybe not yourself, but ask for a specific event instead, since all events will have their own implementation.

    ]]>

  6. Anonymous says:

    < ![CDATA[

    For now I just want to put battery charging state (maybe use ACTION_POWER_CONNECTED or DISCONNECTED ?) on LLX lockscreen,


    the most important thing for me is getting that state without triggering anything.. So will you help me with automation syntax?


    🙂



    I’m sorry for asking this though you have bugs to deal with from latest beta

    ]]>

  7. Anonymous says:

    < ![CDATA[

    Can we use this


    http://developer.android.com/training/monitoring-device-state/battery-monitoring.html


    on LLX Script?



    Intent… BroadcastReceiver……..

    ]]>

  8. Anonymous says:

    < ![CDATA[

    Yes, this needs to be translated into JavaScript but basically this is the way to do it.



    You can get a context using LL.getContext().


    You can run the script at regular interval to update the battery status and level, or you can register a BroadcastReceiver once, for instance on item resume: this way you don’t have to set a timer to update the text.


    In all cases, if you update the text through a timer or a broadcast receiver, you need to initiate it in some onResume event and don’t forget to stop it in onPause event. Best is to use the shortcut item’s pause/resume events.

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Set timer to update or broadcast receiver?



    So basically LL can execute script without user’s intervention?


    o_o



    Will help me with very simple code that show proper usage of resume or pause event?

    ]]>

  10. Anonymous says:

    < ![CDATA[

    There is a sample script at this address: http://www.pierrox.net/android/applications/lightning_launcher/apk_script/Clock-1.0.tar.gz


    This is a good example because it shows how to handle periodic update. In this archive there are two files in app/src/main/res/raw called clock_resumed.js and clock_paused.js. If you look inside clock_resumed  there is an important function called “refresh”. In this sample this function draws a clock, but you can remove almost everything and replace it with something to update the item label.



    The important part is the last line of the refresh function: it sets a timeout so that the refresh function is called once again in 1000ms. By calling refresh() once, you start the regular update loop.



    A simpler script would look similar:


    var item = LL.getEvent().getItem();



    function refresh() {


      var text = “your_text_here “+new Date();


      item.setLabel(text);


      item.setTag(setTimeout(refresh, 1000));


    }


     


    refresh();



    You can reuse the clock_paused.js script as is to end the loop.

    ]]>

  11. Anonymous says:

    < ![CDATA[

    Thank you, I’ll try editing “charging_state” script later and will post the result here.


    🙂

    ]]>

  12. Anonymous says:

    < ![CDATA[

    batstas script:



    Line 11:



    IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);



    Always getting error message: At Line 11: missing; before statement (batstas#11)


    Pierre Hébert 

    ]]>

  13. Anonymous says:

    < ![CDATA[

    Using JavaScript the syntax is a bit different: instead of


    IntentFilter ifilter = new IntentFilter(…


    use:


    var ifilter = new IntentFilter(…



    (Unlike Java there is no strong typing in JS, just variables)

    ]]>

  14. Anonymous says:

    < ![CDATA[

    Thank you again Pierre Hébert,


    here my usable script, maybe There’s better method to do this:



    LL.bindClass(“android.os.BatteryManager”);


    LL.bindClass(“android.content.BroadcastReceiver”);


    LL.bindClass(“android.content.Intent”);


    LL.bindClass(“android.content.Context”);


    LL.bindClass(“android.content.IntentFilter”);



    var item = LL.getEvent().getItem();


    var batstat = “”;


    var batcon = LL.getContext();


    var curd = LL.getCurrentDesktop();


    var curi = curd.getItemByName(“batv”);




    var ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);


    var batteryStatus = batcon.registerReceiver(null, ifilter);



    function onReceive(context, intent)


    {


    var status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);


    var isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||  status == BatteryManager.BATTERY_STATUS_FULL;



    var chargePlug = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);


    var usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB;


    var acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC;




    if (isCharging)


    { if (usbCharge) { batstat = “usb charging . . .”; }


    else


    { batstat = “AC charging . . .”; } }


    else


    { batstat = “”; }


    }



    function manref()


    {


      var text = batstat;


      curi.setLabel(text);


    }


    onReceive(LL.getContext(), batteryStatus);


    manref();



    I put this script on “item CLICK event” and “LockScreen RESUME event” so whenever lockscreen displayed it’ll check battery status, but it’ll not updated until I run the script again either by click or reload lockscreen page.



    Pierre Hébert  if you have time please correct my script from uneeded line and inappropriate usage.


    🙂

    ]]>

  15. Anonymous says:

    < ![CDATA[

    Great, that seems fine!


    For the lock screen it will run correctly but I would suggest to use polling too and item pause/resume event so that it can be used elsewhere. If you wish, you could add it to the script repository on the wiki and I will add the polling loop (it will work for the lock screen too)

    ]]>

  16. Anonymous says:

    < ![CDATA[

    Pierre Hébert thank you very much for your guide and effort to checking my script.. Now, I think better to post it on wiki and have you adding polling loop part.. But I’m sorry, I really don’t know how to post anything to wiki or repository..


    XD



    So… How to post something to script repository?


    😀

    ]]>

  17. Anonymous says:

    < ![CDATA[

    No problem 😉 You need to register first (to avoid spamming…) then you will be able to add or edit content. At the right side of the page there will be a “pen” button to edit or view page source. The script repository page is http://www.pierrox.net/android/applications/lightning_launcher/wiki/doku.php?id=script_repository . Copy the script template as a new page that you can modify with your script.

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *