====== Differences ====== This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
script_battery_charging_state [2015/01/25 14:41] ajasei |
script_battery_charging_state [2015/03/15 13:23] (current) jappie Script-name and tag-name |
||
---|---|---|---|
Line 8: | Line 8: | ||
This script will NOT showing anything when the power cable unplugged, just change the batstat value (in variable declaration or onReceive function) to change this. :D | This script will NOT showing anything when the power cable unplugged, just change the batstat value (in variable declaration or onReceive function) to change this. :D | ||
- | Create shortcut "Lightning Action - Do Nothing" to run this script. | + | * Create shortcut "Lightning Action - Do Nothing" to run this script. |
+ | * Disable Icon | ||
+ | * Set 'BattStatus-resume' script to event resume | ||
+ | * Set 'BattStatus-pause' script to event pause | ||
This version edited by Pierre to minimize resource usage + updated without user intervention, | This version edited by Pierre to minimize resource usage + updated without user intervention, | ||
Line 15: | Line 18: | ||
====== Script code ====== | ====== Script code ====== | ||
- | ======= Item resume script ======= | + | ======= BattStatus-resume ======= |
<code> | <code> | ||
LL.bindClass("android.os.BatteryManager"); | LL.bindClass("android.os.BatteryManager"); | ||
Line 53: | Line 56: | ||
item.setLabel(batstat); | item.setLabel(batstat); | ||
- | item.setTag(setTimeout(refresh, PERIOD)); | + | item.setTag("battSt", setTimeout(refresh, PERIOD)); |
} | } | ||
Line 59: | Line 62: | ||
</code> | </code> | ||
- | ======= Item pause script ======= | + | ======= BattStatus-pause ======= |
<code> | <code> | ||
// important: preserve the battery life and clear timeouts when the item is paused to avoid useless background activity | // important: preserve the battery life and clear timeouts when the item is paused to avoid useless background activity | ||
- | var id = LL.getEvent().getItem().getTag(); | + | var id = LL.getEvent().getItem().getTag("battSt"); |
if(id != null) { | if(id != null) { | ||
clearTimeout(parseInt(id)); | clearTimeout(parseInt(id)); | ||
} | } | ||
</code> | </code> |