Skip to content
Permalink
Browse files
Add Tizen plugin.
  • Loading branch information
siovene committed Dec 31, 2013
1 parent dc07961 commit 5f16245e703dee5e15fef928c4645897c9fcd5f1
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 5f16245

Please sign in to comment.