You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/07/11 23:30:49 UTC
js commit: [CB-1013] First pass at refactoring device to a common
plugin.
Updated Branches:
refs/heads/device [created] f520e3ee9
[CB-1013] First pass at refactoring device to a common plugin.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/f520e3ee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/f520e3ee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/f520e3ee
Branch: refs/heads/device
Commit: f520e3ee90a0e5340de03981409db98b721b88d2
Parents: df936f6
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Jul 11 14:32:43 2012 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Wed Jul 11 14:32:43 2012 -0700
----------------------------------------------------------------------
lib/android/platform.js | 6 +-
lib/android/plugin/android/device.js | 124 ++++++++---------------------
lib/common/channel.js | 1 -
lib/common/common.js | 3 +
4 files changed, 41 insertions(+), 93 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f520e3ee/lib/android/platform.js
----------------------------------------------------------------------
diff --git a/lib/android/platform.js b/lib/android/platform.js
index fa18481..4439d30 100644
--- a/lib/android/platform.js
+++ b/lib/android/platform.js
@@ -116,9 +116,6 @@ module.exports = {
}
}
},
- device:{
- path: "cordova/plugin/android/device"
- },
File: { // exists natively on Android WebView, override
path: "cordova/plugin/File"
},
@@ -133,6 +130,9 @@ module.exports = {
}
},
merges: {
+ device: {
+ path: 'cordova/plugin/android/device'
+ },
navigator: {
children: {
notification: {
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f520e3ee/lib/android/plugin/android/device.js
----------------------------------------------------------------------
diff --git a/lib/android/plugin/android/device.js b/lib/android/plugin/android/device.js
index fd30d50..9962dbb 100644
--- a/lib/android/plugin/android/device.js
+++ b/lib/android/plugin/android/device.js
@@ -1,93 +1,39 @@
var channel = require('cordova/channel'),
utils = require('cordova/utils'),
- exec = require('cordova/exec');
-
-/**
- * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
- * phone, etc.
- * @constructor
- */
-function Device() {
- this.available = false;
- this.platform = null;
- this.version = null;
- this.name = null;
- this.uuid = null;
- this.cordova = null;
-
- var me = this;
-
- channel.onCordovaReady.subscribeOnce(function() {
- me.getInfo(function(info) {
- me.available = true;
- me.platform = info.platform;
- me.version = info.version;
- me.name = info.name;
- me.uuid = info.uuid;
- me.cordova = info.cordova;
- channel.onCordovaInfoReady.fire();
- },function(e) {
- me.available = false;
- utils.alert("[ERROR] Error initializing Cordova: " + e);
- });
- });
-}
-
-/**
- * Get device info
- *
- * @param {Function} successCallback The function to call when the heading data is available
- * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
- */
-Device.prototype.getInfo = function(successCallback, errorCallback) {
-
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Device Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Device Error: errorCallback is not a function");
- return;
+ exec = require('cordova/exec'),
+ app = require('cordova/plugin/android/app');
+
+module.exports = {
+ /*
+ * DEPRECATED
+ * This is only for Android.
+ *
+ * You must explicitly override the back button.
+ */
+ overrideBackButton:function() {
+ console.log("Device.overrideBackButton() is deprecated. Use App.overrideBackbutton(true).");
+ app.overrideBackbutton(true);
+ },
+
+ /*
+ * DEPRECATED
+ * This is only for Android.
+ *
+ * This resets the back button to the default behaviour
+ */
+ resetBackButton:function() {
+ console.log("Device.resetBackButton() is deprecated. Use App.overrideBackbutton(false).");
+ app.overrideBackbutton(false);
+ },
+
+ /*
+ * DEPRECATED
+ * This is only for Android.
+ *
+ * This terminates the activity!
+ */
+ exitApp:function() {
+ console.log("Device.exitApp() is deprecated. Use App.exitApp().");
+ app.exitApp();
}
-
- // Get info
- exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
};
-
-/*
- * DEPRECATED
- * This is only for Android.
- *
- * You must explicitly override the back button.
- */
-Device.prototype.overrideBackButton = function() {
- console.log("Device.overrideBackButton() is deprecated. Use App.overrideBackbutton(true).");
- navigator.app.overrideBackbutton(true);
-};
-
-/*
- * DEPRECATED
- * This is only for Android.
- *
- * This resets the back button to the default behaviour
- */
-Device.prototype.resetBackButton = function() {
- console.log("Device.resetBackButton() is deprecated. Use App.overrideBackbutton(false).");
- navigator.app.overrideBackbutton(false);
-};
-
-/*
- * DEPRECATED
- * This is only for Android.
- *
- * This terminates the activity!
- */
-Device.prototype.exitApp = function() {
- console.log("Device.exitApp() is deprecated. Use App.exitApp().");
- navigator.app.exitApp();
-};
-
-module.exports = new Device();
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f520e3ee/lib/common/channel.js
----------------------------------------------------------------------
diff --git a/lib/common/channel.js b/lib/common/channel.js
index 62662d5..f839a29 100755
--- a/lib/common/channel.js
+++ b/lib/common/channel.js
@@ -251,7 +251,6 @@ channel.create('onDestroy');
// Channels that must fire before "deviceready" is fired.
channel.waitForInitialization('onCordovaReady');
-channel.waitForInitialization('onCordovaInfoReady');
channel.waitForInitialization('onCordovaConnectionReady');
module.exports = channel;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f520e3ee/lib/common/common.js
----------------------------------------------------------------------
diff --git a/lib/common/common.js b/lib/common/common.js
index 25a921d..b3b4686 100644
--- a/lib/common/common.js
+++ b/lib/common/common.js
@@ -124,6 +124,9 @@ module.exports = {
Coordinates: {
path: 'cordova/plugin/Coordinates'
},
+ device: {
+ path: 'cordova/plugin/device'
+ },
DirectoryEntry: {
path: 'cordova/plugin/DirectoryEntry'
},