mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-04 00:02:03 +08:00
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:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* This class provides access to notifications on the device.
|
||||
*/
|
||||
function Notification() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,7 +33,7 @@ Notification.prototype.activityStop = function() {
|
||||
* @param {String} colour The colour of the light.
|
||||
*/
|
||||
Notification.prototype.blink = function(count, colour) {
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -42,16 +41,17 @@ Notification.prototype.blink = function(count, colour) {
|
||||
* @param {Integer} mills The number of milliseconds to vibrate for.
|
||||
*/
|
||||
Notification.prototype.vibrate = function(mills) {
|
||||
|
||||
PhoneGap.execAsync(null, null, "Device", "vibrate", [mills]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Causes the device to beep.
|
||||
* On Android, the default notification ringtone is played.
|
||||
*
|
||||
* @param {Integer} count The number of beeps.
|
||||
* @param {Integer} volume The volume of the beep.
|
||||
*/
|
||||
Notification.prototype.beep = function(count, volume) {
|
||||
|
||||
Notification.prototype.beep = function(count) {
|
||||
PhoneGap.execAsync(null, null, "Device", "beep", [count]);
|
||||
};
|
||||
|
||||
// TODO: of course on Blackberry and Android there notifications in the UI as well
|
||||
@@ -60,18 +60,3 @@ PhoneGap.addConstructor(function() {
|
||||
if (typeof navigator.notification == "undefined") navigator.notification = new Notification();
|
||||
});
|
||||
|
||||
Notification.prototype.vibrate = function(mills)
|
||||
{
|
||||
DroidGap.vibrate(mills);
|
||||
}
|
||||
|
||||
/*
|
||||
* On the Android, we don't beep, we notify you with your
|
||||
* notification! We shouldn't keep hammering on this, and should
|
||||
* review what we want beep to do.
|
||||
*/
|
||||
|
||||
Notification.prototype.beep = function(count, volume)
|
||||
{
|
||||
DroidGap.beep(count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user