mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
Fix for Issue #228: Align Compass support with iOS
This commit is contained in:
@@ -9,6 +9,21 @@
|
||||
if (!PhoneGap.hasResource("compass")) {
|
||||
PhoneGap.addResource("compass");
|
||||
|
||||
CompassError = function(){
|
||||
this.code = null;
|
||||
};
|
||||
|
||||
// Capture error codes
|
||||
CompassError.COMPASS_INTERNAL_ERR = 0;
|
||||
CompassError.COMPASS_NOT_SUPPORTED = 20;
|
||||
|
||||
CompassHeading = function() {
|
||||
this.magneticHeading = null;
|
||||
this.trueHeading = null;
|
||||
this.headingAccuracy = null;
|
||||
this.timestamp = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class provides access to device Compass data.
|
||||
* @constructor
|
||||
@@ -111,6 +126,14 @@ Compass.prototype.clearWatch = function(id) {
|
||||
}
|
||||
};
|
||||
|
||||
Compass.prototype._castDate = function(pluginResult) {
|
||||
if (pluginResult.message.timestamp) {
|
||||
var timestamp = new Date(pluginResult.message.timestamp);
|
||||
pluginResult.message.timestamp = timestamp;
|
||||
}
|
||||
return pluginResult;
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
if (typeof navigator.compass === "undefined") {
|
||||
navigator.compass = new Compass();
|
||||
|
||||
Reference in New Issue
Block a user