Skip to content
Permalink
Browse files
…ery-status into dev
  • Loading branch information
Anis Kadri committed Jan 28, 2014
2 parents f0311ae + 5f16245 commit 60ff55a095e54b2bde56c0cd360e462dc75a8c14
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
@@ -83,5 +83,11 @@

<source-file src="src/wp/Battery.cs" />
</platform>


<!-- tizen -->
<platform name="tizen">
<js-module src="src/tizen/BatteryStatusProxy.js" name="BatteryStatusProxy">
<runs/>
</js-module>
</platform>
</plugin>
@@ -0,0 +1,26 @@
var cordova = require('cordova');

var batteryListenerId = null;

module.exports = {
start: function(successCallback, errorCallback) {
var batterySuccessCallback = function(power) {
if (successCallback) {
successCallback({level: Math.round(power.level * 100), isPlugged: power.isCharging});
}
};

if (batteryListenerId === null) {
batteryListenerId = tizen.systeminfo.addPropertyValueChangeListener("BATTERY", batterySuccessCallback);
}

tizen.systeminfo.getPropertyValue("BATTERY", batterySuccessCallback, errorCallback);
},

stop: function(successCallback, errorCallback) {
tizen.systeminfo.removePropertyValueChangeListener(batteryListenerId);
batteryListenerId = null;
}
};

require("cordova/tizen/commandProxy").add("Battery", module.exports);

0 comments on commit 60ff55a

Please sign in to comment.