mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-12 18:56:11 +08:00
![macdonst](/assets/img/avatar_default.png)
An implementation of the W3C Media Capture spec: http://dev.w3.org/2009/dap/camera/Overview-API Capture operations are supported for audio, video, and images. Each capture operation launches the native audio recorder, video recorder, or camera application, respectively.
106 lines
2.9 KiB
JavaScript
Executable File
106 lines
2.9 KiB
JavaScript
Executable File
/*
|
|
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
|
|
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
|
|
*
|
|
* Copyright (c) 2005-2010, Nitobi Software Inc.
|
|
* Copyright (c) 2010-2011, IBM Corporation
|
|
*/
|
|
|
|
if (!PhoneGap.hasResource("device")) {
|
|
PhoneGap.addResource("device");
|
|
|
|
/**
|
|
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
|
|
* phone, etc.
|
|
* @constructor
|
|
*/
|
|
Device = function() {
|
|
this.available = PhoneGap.available;
|
|
this.platform = null;
|
|
this.version = null;
|
|
this.name = null;
|
|
this.uuid = null;
|
|
this.phonegap = null;
|
|
|
|
var me = this;
|
|
this.getInfo(
|
|
function(info) {
|
|
me.available = true;
|
|
me.platform = info.platform;
|
|
me.version = info.version;
|
|
me.name = info.name;
|
|
me.uuid = info.uuid;
|
|
me.phonegap = info.phonegap;
|
|
PhoneGap.onPhoneGapInfoReady.fire();
|
|
},
|
|
function(e) {
|
|
me.available = false;
|
|
console.log("Error initializing PhoneGap: " + e);
|
|
alert("Error initializing PhoneGap: "+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;
|
|
}
|
|
|
|
// Get info
|
|
PhoneGap.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).");
|
|
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).");
|
|
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().");
|
|
app.exitApp();
|
|
};
|
|
|
|
PhoneGap.addConstructor(function() {
|
|
if (typeof navigator.device === "undefined") {
|
|
navigator.device = window.device = new Device();
|
|
}
|
|
});
|
|
};
|