User Tools

Site Tools


script_battery_charging_state

====== Differences ====== This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
script_battery_charging_state [2015/01/24 17:09]
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,+This version edited by Pierre to minimize resource usage + updated without user intervention,
 The old version can be found here: https://​www.dropbox.com/​s/​c0hews7f01b7l01/​_AJS_script_oldBATSTATE.txt?​dl=0 The old version can be found here: https://​www.dropbox.com/​s/​c0hews7f01b7l01/​_AJS_script_oldBATSTATE.txt?​dl=0
 :) :)
  
 ====== 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>​
script_battery_charging_state.1422119368.txt.gz · Last modified: 2015/01/24 17:09 by ajasei