cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [1/2] git commit: Add Tizen plugin.
Date Tue, 28 Jan 2014 07:02:33 GMT
Updated Branches:
  refs/heads/dev f0311ae85 -> 60ff55a09


Add Tizen plugin.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/commit/5f16245e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/tree/5f16245e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/diff/5f16245e

Branch: refs/heads/dev
Commit: 5f16245e703dee5e15fef928c4645897c9fcd5f1
Parents: dc07961
Author: Salvatore Iovene <salvatore@iovene.com>
Authored: Tue Dec 31 12:18:54 2013 +0200
Committer: Salvatore Iovene <salvatore@iovene.com>
Committed: Tue Dec 31 12:18:54 2013 +0200

----------------------------------------------------------------------
 plugin.xml                      |  8 +++++++-
 src/tizen/BatteryStatusProxy.js | 26 ++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/5f16245e/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 16f175c..5827ba4 100644
--- a/plugin.xml
+++ b/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>

http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/5f16245e/src/tizen/BatteryStatusProxy.js
----------------------------------------------------------------------
diff --git a/src/tizen/BatteryStatusProxy.js b/src/tizen/BatteryStatusProxy.js
new file mode 100644
index 0000000..728acd2
--- /dev/null
+++ b/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);


Mime
View raw message