Pierre Hébert  b7 bug: addition of box bindings seems to have distorted scripts that refer to box properties

Pierre Hébert  b7 bug: addition of box bindings seems to have distorted scripts that refer to box properties

getBox(“i.box”).setSize(string, int) is not working for me in b7 while it worked fine in b5 and non-beta versions

]]>
« (Previous Post)

10 Commentsto Pierre Hébert  b7 bug: addition of box bindings seems to have distorted scripts that refer to box properties

  1. Anonymous says:

    < ![CDATA[

    Here’s my script if it’s useful for debugging: it’s a clock that also shows battery level and charging status (think of a glass half full being filled up)



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


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


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


    var ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);


    var batteryStatus = LL.getContext().registerReceiver(null, ifilter);


    var level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);


    var scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);


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


    var top = Math.floor(480+100*(scale-level)/scale);


    var pad = Math.floor(100*(level-scale)/scale);


    var s = level.toString().substring(0,1);


    var barray = [‘H1b’, ‘H2b’, ‘M1b’, ‘M2b’, ‘Sb’]



    function refresh() {


      var now=new Date();


      var h=now.getHours();


      if (h>12) {h -= 12};


      if (h === 0) {h = 12};


      if (h<10) {h = "0" + h};


      var m=now.getMinutes();


      if (m<10) {m = "0" + m};


      var h1=h.toString().substring(0,1);


      var h2=h.toString().substring(2,1);


      var m1=m.toString().substring(0,1);


      var m2=m.toString().substring(2,1);


      LL.getCurrentDesktop().getItemByName(‘H1’).setLabel(h1, true);  


      LL.getCurrentDesktop().getItemByName(‘H2’).setLabel(h2, true);  


      LL.getCurrentDesktop().getItemByName(‘M1’).setLabel(m1, true);  


      LL.getCurrentDesktop().getItemByName(‘M2’).setLabel(m2, true);  


      LL.getCurrentDesktop().getItemByName(‘S’).setLabel(s, true);  


      LL.getCurrentDesktop().getItemByName(‘H1b’).setLabel(h1, true);  


      LL.getCurrentDesktop().getItemByName(‘H2b’).setLabel(h2, true);  


      LL.getCurrentDesktop().getItemByName(‘M1b’).setLabel(m1, true);  


      LL.getCurrentDesktop().getItemByName(‘M2b’).setLabel(m2, true);  


      LL.getCurrentDesktop().getItemByName(‘Sb’).setLabel(s, true);  


      var left = 60


      for (var i in barray) { 


        var editor = LL.getCurrentDesktop().getItemByName(barray[i]).getProperties().edit();


        editor.getBox(“i.box”).setSize(“pt”, pad);


        editor.commit();


        LL.getCurrentDesktop().getItemByName(barray[i]).setPosition(left, top);


        left = left+125;


      }


      if (status == BatteryManager.BATTERY_STATUS_CHARGING) {


        pad = pad+5;


        top = top-5;


        if (pad > 0) {pad = Math.floor(100*(level-scale)/scale); top = Math.floor(480+100*(scale-level)/scale)}


      }


      LL.getCurrentDesktop().getItemByName(‘S’).setTag(setTimeout(refresh, 1000));


    }


    refresh();

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Could you try with a fixed integer value for pad instead of Math.floor(100*(level-scale)/scale); ?


    I believe the floating point value cannot be converted to an integer as it should be.

    ]]>

  3. Anonymous says:

    < ![CDATA[

    Not sure how to do that … I do need the variable pad to be based on a dynamic number (battery %) though. Can you suggest?


    The script worked exactly as intended (no changes from above) in the b5, but got broken in b7

    ]]>

  4. Anonymous says:

    < ![CDATA[

    If you replace pad with 50, just to test, does it work ?


    I ask this because I can’t test the script as is because of the items it requires. I tested the setSize call, it seems to work in all my unitary tests so I believe it has to do with the value.

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Ah, I understand. Yes, 50 (or any fixed value for pad) seems to work


    When not charging, pad value works too


    Somehow when charging is active, “pad = pad+5;” does not get committed by editor

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Not sure if this helps, but pad is usually a negative value. Has something changed between b5 and b7 on how LL treats padding with negative values?

    ]]>

  7. Anonymous says:

    < ![CDATA[

    No, negative values are processed the same way.


    I modified your script so that it works with a single item, remove the setPosition call, etc, and it seems to work as expected, padding moves from N to 0 and comes back to N, N being -43 for 57% for instance.

    ]]>

  8. Anonymous says:

    < ![CDATA[

    Thanks, that was a good troubleshooting tip. I simply changed the order of the script, put the setPosition before the edit.commit, and it works as intended now. Not sure why the previous script worked on b5 and not b7 though …



    Appreciate all your help!

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Hum, since I disabled this setPosition call I couldn’t see the bad behavior. I will re-enable it now.

    ]]>

  10. Anonymous says:

    < ![CDATA[

    No luck, with the setPosition call it works too 🙁

    ]]>

Leave a Reply

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