Skip to content
Browse files

Add Tizen plugin.

  • Loading branch information...
1 parent dc07961 commit 5f16245e703dee5e15fef928c4645897c9fcd5f1 @siovene siovene committed
Showing with 33 additions and 1 deletion.
  1. +7 −1 plugin.xml
  2. +26 −0 src/tizen/BatteryStatusProxy.js
View
8 plugin.xml
@@ -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>
View
26 src/tizen/BatteryStatusProxy.js
@@ -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.
Something went wrong with that request. Please try again.