Change Device JS object to include only platform, uuid, version, and phonegap properties as defined in API, and modify Device Java class to implement plugin interface.

This commit is contained in:
Bryce Curtis
2010-09-15 14:27:46 -05:00
parent c050e00b8f
commit 705b8f6874
4 changed files with 231 additions and 103 deletions
+35 -34
View File
@@ -1,59 +1,60 @@
/**
* this represents the mobile device, and provides properties for inspecting the model, version, UUID of the
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
* phone, etc.
* @constructor
*/
function Device() {
this.available = PhoneGap.available;
this.platform = null;
this.version = null;
this.name = null;
this.gap = null;
this.uuid = null;
try {
if (window.DroidGap) {
this.available = true;
this.uuid = window.DroidGap.getUuid();
this.version = window.DroidGap.getOSVersion();
this.gapVersion = window.DroidGap.getVersion();
this.platform = window.DroidGap.getPlatform();
this.name = window.DroidGap.getProductName();
this.line1Number = window.DroidGap.getLine1Number();
this.deviceId = window.DroidGap.getDeviceId();
this.simSerialNumber = window.DroidGap.getSimSerialNumber();
this.subscriberId = window.DroidGap.getSubscriberId();
}
} catch(e) {
this.available = false;
}
this.version = null;
this.name = null;
this.uuid = null;
this.phonegap = null;
var me = this;
PhoneGap.execAsync(
function(info) {
me.available = true;
me.platform = info.platform;
me.version = info.version;
me.uuid = info.uuid;
me.phonegap = info.phonegap;
},
function(e) {
me.available = false;
console.log("Error initializing PhoneGap: " + e);
alert("Error initializing PhoneGap: "+e);
},
"Device", "getDeviceInfo", []);
}
/*
* You must explicitly override the back button.
* This is only for Android.
*
* You must explicitly override the back button.
*/
Device.prototype.overrideBackButton = function()
{
BackButton.override();
Device.prototype.overrideBackButton = function() {
BackButton.override();
}
/*
* This is only for Android.
*
* This resets the back button to the default behaviour
*/
Device.prototype.resetBackButton = function()
{
BackButton.reset();
Device.prototype.resetBackButton = function() {
BackButton.reset();
}
/*
* This is only for Android.
*
* This terminates the activity!
*/
Device.prototype.exitApp = function()
{
BackButton.exitApp();
Device.prototype.exitApp = function() {
BackButton.exitApp();
}
PhoneGap.addConstructor(function() {
navigator.device = window.device = new Device();
});
});