====== Differences ====== This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
script_battery_widget [2015/02/11 14:46] jappie created - copy from Abednego JS - Show Battery State |
script_battery_widget [2015/11/02 23:34] (current) clockworkbastard [How to use the script] |
||
|---|---|---|---|
| Line 7: | Line 7: | ||
| ====== How to use the script ====== | ====== How to use the script ====== | ||
| - | * Create shortcut "Lightning Action - Do Nothing" to run this script. | ||
| - | * Disable Icon | ||
| - | * Set resume-script to event resume | ||
| - | * Set pause-script to event pause | ||
| + | * Install [[https://play.google.com/store/apps/details?id=com.trianguloy.llscript.repository|Repository Importer - LLScript]] to import both script parts (**BattW-resume** and **BattW-pause**) directly from that page | ||
| + | * Create dynamic content - **badge** | ||
| + | * Make sure Expert mode is on in the LL settings (for expert events) | ||
| + | * Set event resumed to run script **BattW-resume** | ||
| + | * Set event paused to run script **BattW-pause** | ||
| + | * Resize to a desired fit | ||
| + | * Decrease upper and bottom **margins** to **-8** to fit a small text on a very thin bar | ||
| ====== Script code ====== | ====== Script code ====== | ||
| - | ======= Item resume script ======= | + | ======= BattW-resume ======= |
| <code> | <code> | ||
| LL.bindClass("android.os.BatteryManager"); | LL.bindClass("android.os.BatteryManager"); | ||
| Line 71: | Line 74: | ||
| img.update(); | img.update(); | ||
| - | item.setTag("batt", setTimeout(refresh, PERIOD)); | + | item.setTag("battW", setTimeout(refresh, PERIOD)); |
| } | } | ||
| Line 77: | Line 80: | ||
| </code> | </code> | ||
| - | ======= Item pause script ======= | + | ======= BattW-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("batt"); | + | var id = LL.getEvent().getItem().getTag("battW"); |
| if(id != null) | if(id != null) | ||
| { clearTimeout(parseInt(id)); | { clearTimeout(parseInt(id)); | ||
| } | } | ||
| </code> | </code> | ||